Housegan
House-GAN Transformers-style package.
HouseGanConfig ¶
Bases: PretrainedConfig
Configuration for the House-GAN graph-conditioned generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Dataset identifier for the vectorized floorplan assets. |
'housegan_floorplan_vectorized'
|
target_set
|
str
|
House-GAN split target set, one of |
'D'
|
checkpoint_step
|
int
|
Original checkpoint training step. |
200000
|
id2label
|
Id2LabelMapping | None
|
Public zero-based room label map. |
None
|
relation_id2label
|
Id2LabelMapping | None
|
Signed relation label map. |
None
|
latent_dim
|
int
|
Per-room latent vector dimension. |
128
|
node_feature_dim
|
int
|
One-hot room feature dimension. |
10
|
graph_edge_values
|
tuple[int, int]
|
Supported signed edge values. |
(-1, 1)
|
mask_size
|
int
|
Generated square room-mask size. |
32
|
canvas_size
|
tuple[int, int]
|
Original floorplan canvas size as |
(256, 256)
|
cmp_channels
|
int
|
CMP feature channel count. |
16
|
num_cmp_layers
|
int
|
Number of CMP layers in the generator. |
2
|
postprocess_threshold
|
float
|
Threshold used by mask-to-box postprocessing. |
0.0
|
bbox_source
|
str
|
Source of public boxes. |
'generated_mask'
|
source_checkpoint
|
str | None
|
Original checkpoint path or name. |
None
|
conversion_report
|
HouseGanConversionReport | None
|
Measured conversion metadata. |
None
|
license_note
|
str
|
Upstream license and research-purpose warning. |
'GPL-3.0 with upstream research-purpose notice'
|
Examples:
>>> config = HouseGanConfig()
>>> config.id2label[0]
'living_room'
Source code in models/housegan/src/housegan/configuration_housegan.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
__init__ ¶
__init__(
*,
dataset_name: str = "housegan_floorplan_vectorized",
target_set: str = "D",
checkpoint_step: int = 200000,
id2label: Id2LabelMapping | None = None,
relation_id2label: Id2LabelMapping | None = None,
latent_dim: int = 128,
node_feature_dim: int = 10,
graph_edge_values: tuple[int, int] = (-1, 1),
mask_size: int = 32,
canvas_size: tuple[int, int] = (256, 256),
cmp_channels: int = 16,
num_cmp_layers: int = 2,
postprocess_threshold: float = 0.0,
bbox_source: str = "generated_mask",
source_checkpoint: str | None = None,
conversion_report: HouseGanConversionReport
| None = None,
license_note: str = "GPL-3.0 with upstream research-purpose notice",
**kwargs: str | int | float | bool | None,
) -> None
Initialize a House-GAN config.
Source code in models/housegan/src/housegan/configuration_housegan.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
HouseGanRelation
dataclass
¶
Adjacency relation between two room nodes.
Source code in models/housegan/src/housegan/graph_schema.py
24 25 26 27 28 29 30 31 | |
HouseGanRoomNode
dataclass
¶
Room node in a House-GAN scene graph.
Source code in models/housegan/src/housegan/graph_schema.py
14 15 16 17 18 19 20 21 | |
HouseGanSceneGraph
dataclass
¶
Flat room relation graph used by House-GAN.
Source code in models/housegan/src/housegan/graph_schema.py
34 35 36 37 38 39 | |
HouseGanGenerator ¶
Bases: PreTrainedModel
Transformers-compatible House-GAN generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
HouseGanConfig
|
House-GAN configuration. |
required |
Examples:
>>> model = HouseGanGenerator(HouseGanConfig())
>>> latents = torch.zeros(2, 128)
>>> nodes = torch.eye(10)[:2]
>>> edges = torch.tensor([[0, 1, 1]])
>>> tuple(model(latents, nodes, edges).masks.shape)
(2, 32, 32)
Source code in models/housegan/src/housegan/modeling_housegan.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
__init__ ¶
__init__(config: HouseGanConfig) -> None
Initialize generator layers.
Source code in models/housegan/src/housegan/modeling_housegan.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
forward ¶
forward(
latents: Float[Tensor, "elements latent"],
node_features: Float[Tensor, "elements room_labels"],
edges: Int[Tensor, "edges 3"],
return_dict: bool | None = None,
) -> (
HouseGanModelOutput
| tuple[Float[torch.Tensor, "elements height width"]]
)
Run a House-GAN forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Float[Tensor, 'elements latent']
|
Per-room latent vectors. |
required |
node_features
|
Float[Tensor, 'elements room_labels']
|
Per-room one-hot room features. |
required |
edges
|
Int[Tensor, 'edges 3']
|
Signed complete graph triples. |
required |
return_dict
|
bool | None
|
Whether to return |
None
|
Returns:
| Type | Description |
|---|---|
HouseGanModelOutput | tuple[Float[Tensor, 'elements height width']]
|
Raw generated room masks. |
Source code in models/housegan/src/housegan/modeling_housegan.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
HouseGanModelOutput
dataclass
¶
Bases: ModelOutput
Raw House-GAN model output.
Source code in models/housegan/src/housegan/modeling_housegan.py
16 17 18 19 20 21 22 | |
HouseGanPipeline ¶
Bases: LayoutGenerationPipeline
Transformers-side House-GAN layout generation pipeline.
Source code in models/housegan/src/housegan/pipeline_housegan.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
__init__ ¶
__init__(
model: HouseGanGenerator,
processor: HouseGanProcessor | None = None,
config: HouseGanConfig | None = None,
device: int | device | None = None,
) -> None
Initialize the pipeline.
Source code in models/housegan/src/housegan/pipeline_housegan.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
__call__ ¶
__call__(
*,
batch_size: int = 1,
seed: int | None = None,
generator: Generator | None = None,
condition_type: ConditionType
| str = ConditionType.relation,
labels: Int[Tensor, "..."]
| Int[ndarray, "..."]
| NestedIntList
| None = None,
bbox: Float[Tensor, "... 4"]
| Float[ndarray, "... 4"]
| NestedFloatList
| None = None,
mask: Bool[Tensor, "..."]
| Bool[ndarray, "..."]
| NestedBoolList
| None = None,
num_elements: int
| list[int]
| Int[Tensor, "..."]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
num_inference_steps: int | None = None,
scene_graph: HouseGanSceneGraph
| HouseGanSceneGraphPayload
| list[HouseGanSceneGraphPayload]
| None = None,
relations: Sequence[HouseGanRelationPayload]
| None = None,
latents: Float[Tensor, "elements latent"] | None = None,
output_type: OutputType = "dataclass",
return_intermediates: bool = False,
) -> (
LayoutGenerationOutput
| dict[
str,
Shaped[torch.Tensor, "..."]
| dict[int, str]
| list[dict[str, str | int | float | bool | None]]
| None,
]
)
Generate a floorplan layout from room relation constraints.
Source code in models/housegan/src/housegan/pipeline_housegan.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
HouseGanProcessor ¶
Bases: ProcessorMixin
Normalize House-GAN scene graphs and decode generated masks.
Source code in models/housegan/src/housegan/processing_housegan.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
__init__ ¶
__init__(
*,
config: HouseGanConfig,
default_missing_relation: Literal[
"not_adjacent", "error"
] = "not_adjacent",
) -> None
Initialize processor metadata.
Source code in models/housegan/src/housegan/processing_housegan.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
save_pretrained ¶
save_pretrained(
save_directory: str | Path,
push_to_hub: bool = False,
**kwargs: str | int | float | bool | None,
) -> None
Save processor metadata.
Source code in models/housegan/src/housegan/processing_housegan.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
from_pretrained
classmethod
¶
from_pretrained(
pretrained_model_name_or_path: str | PathLike[str],
cache_dir: str | PathLike[str] | None = None,
force_download: bool = False,
local_files_only: bool = False,
token: str | bool | None = None,
revision: str = "main",
subfolder: str | None = None,
**kwargs: str | int | float | bool | None,
) -> Self
Load processor metadata from processor_config.json.
Source code in models/housegan/src/housegan/processing_housegan.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
__call__ ¶
__call__(
*,
condition_type: ConditionType
| str = ConditionType.relation,
scene_graph: HouseGanSceneGraph
| HouseGanSceneGraphPayload
| None = None,
relations: Sequence[HouseGanRelationPayload]
| None = None,
labels: Int[Tensor, "..."]
| Int[ndarray, "..."]
| Sequence[Sequence[int]]
| Sequence[int]
| None = None,
bbox: Float[Tensor, "... 4"]
| Float[ndarray, "... 4"]
| Sequence[Sequence[Sequence[float]]]
| Sequence[Sequence[float]]
| Sequence[ArrayLikeInput]
| None = None,
mask: Bool[Tensor, "..."]
| Bool[ndarray, "..."]
| Sequence[Sequence[bool]]
| Sequence[bool]
| Sequence[ArrayLikeInput]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
return_tensors: Literal["pt"] = "pt",
) -> BatchEncoding
Encode public relation inputs into House-GAN tensors.
Source code in models/housegan/src/housegan/processing_housegan.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
normalize_condition_type ¶
normalize_condition_type(
condition_type: ConditionType | str,
) -> ConditionType
Normalize and validate the House-GAN condition type.
Source code in models/housegan/src/housegan/processing_housegan.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
post_process_masks ¶
post_process_masks(
masks: Float[Tensor, "elements height width"],
*,
labels: Int[Tensor, "elements"],
edges: Int[Tensor, "edges 3"] | None = None,
node_features: Float[Tensor, "elements room_labels"]
| None = None,
scene_graph: HouseGanSceneGraph | None = None,
output_type: OutputType = "dataclass",
return_intermediates: bool = False,
) -> (
LayoutGenerationOutput
| dict[
str,
Shaped[torch.Tensor, "..."]
| dict[int, str]
| dict[
str,
Shaped[torch.Tensor, "..."]
| HouseGanSceneGraph
| None,
]
| None,
]
)
Convert generated room masks to public normalized boxes.
Source code in models/housegan/src/housegan/processing_housegan.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
configuration_housegan ¶
Configuration for House-GAN generator conversion.
HouseGanConfig ¶
Bases: PretrainedConfig
Configuration for the House-GAN graph-conditioned generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Dataset identifier for the vectorized floorplan assets. |
'housegan_floorplan_vectorized'
|
target_set
|
str
|
House-GAN split target set, one of |
'D'
|
checkpoint_step
|
int
|
Original checkpoint training step. |
200000
|
id2label
|
Id2LabelMapping | None
|
Public zero-based room label map. |
None
|
relation_id2label
|
Id2LabelMapping | None
|
Signed relation label map. |
None
|
latent_dim
|
int
|
Per-room latent vector dimension. |
128
|
node_feature_dim
|
int
|
One-hot room feature dimension. |
10
|
graph_edge_values
|
tuple[int, int]
|
Supported signed edge values. |
(-1, 1)
|
mask_size
|
int
|
Generated square room-mask size. |
32
|
canvas_size
|
tuple[int, int]
|
Original floorplan canvas size as |
(256, 256)
|
cmp_channels
|
int
|
CMP feature channel count. |
16
|
num_cmp_layers
|
int
|
Number of CMP layers in the generator. |
2
|
postprocess_threshold
|
float
|
Threshold used by mask-to-box postprocessing. |
0.0
|
bbox_source
|
str
|
Source of public boxes. |
'generated_mask'
|
source_checkpoint
|
str | None
|
Original checkpoint path or name. |
None
|
conversion_report
|
HouseGanConversionReport | None
|
Measured conversion metadata. |
None
|
license_note
|
str
|
Upstream license and research-purpose warning. |
'GPL-3.0 with upstream research-purpose notice'
|
Examples:
>>> config = HouseGanConfig()
>>> config.id2label[0]
'living_room'
Source code in models/housegan/src/housegan/configuration_housegan.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
__init__ ¶
__init__(
*,
dataset_name: str = "housegan_floorplan_vectorized",
target_set: str = "D",
checkpoint_step: int = 200000,
id2label: Id2LabelMapping | None = None,
relation_id2label: Id2LabelMapping | None = None,
latent_dim: int = 128,
node_feature_dim: int = 10,
graph_edge_values: tuple[int, int] = (-1, 1),
mask_size: int = 32,
canvas_size: tuple[int, int] = (256, 256),
cmp_channels: int = 16,
num_cmp_layers: int = 2,
postprocess_threshold: float = 0.0,
bbox_source: str = "generated_mask",
source_checkpoint: str | None = None,
conversion_report: HouseGanConversionReport
| None = None,
license_note: str = "GPL-3.0 with upstream research-purpose notice",
**kwargs: str | int | float | bool | None,
) -> None
Initialize a House-GAN config.
Source code in models/housegan/src/housegan/configuration_housegan.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
conversion ¶
Checkpoint conversion utilities for House-GAN.
sha256_file ¶
sha256_file(path: str | Path) -> str
Compute a SHA256 digest for a file.
Source code in models/housegan/src/housegan/conversion.py
18 19 20 21 22 23 24 | |
convert_original_checkpoint ¶
convert_original_checkpoint(
*,
checkpoint: str | Path,
output_dir: str | Path,
target_set: str = "D",
checkpoint_step: int = 200000,
) -> HouseGanConversionReport
Convert a raw House-GAN generator state dict into HF files.
Source code in models/housegan/src/housegan/conversion.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
datasets ¶
Local dataset adapters for House-GAN vectorized floorplan assets.
load_housegan_numpy ¶
load_housegan_numpy(
path: str | Path,
) -> Shaped[np.ndarray, "..."]
Load a local House-GAN .npy asset without downloading data.
Source code in models/housegan/src/housegan/datasets.py
28 29 30 | |
normalize_graph_row ¶
normalize_graph_row(
row: tuple[Sequence[int], Sequence[Sequence[float]]],
*,
canvas_size: tuple[int, int] = (256, 256),
) -> HouseGanSceneGraph
Convert one [room_types, ltrb_boxes] row to a scene graph.
Source code in models/housegan/src/housegan/datasets.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
split_target_set ¶
split_target_set(
graphs: list[HouseGanSceneGraph],
*,
target_set: Literal["A", "B", "C", "D", "E"],
split: Literal["train", "eval"],
) -> list[HouseGanSceneGraph]
Apply House-GAN target-set graph-size splits.
Source code in models/housegan/src/housegan/datasets.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
build_edges_from_bboxes ¶
build_edges_from_bboxes(
bbox_ltrb: Float[ndarray, "elements 4"],
*,
threshold: float = 0.03,
) -> list[HouseGanRelation]
Build public adjacency relations from normalized ltrb boxes.
Source code in models/housegan/src/housegan/datasets.py
72 73 74 75 76 77 78 | |
graph_schema ¶
Scene-graph schema normalization for House-GAN.
HouseGanRoomNode
dataclass
¶
Room node in a House-GAN scene graph.
Source code in models/housegan/src/housegan/graph_schema.py
14 15 16 17 18 19 20 21 | |
HouseGanRelation
dataclass
¶
Adjacency relation between two room nodes.
Source code in models/housegan/src/housegan/graph_schema.py
24 25 26 27 28 29 30 31 | |
HouseGanSceneGraph
dataclass
¶
Flat room relation graph used by House-GAN.
Source code in models/housegan/src/housegan/graph_schema.py
34 35 36 37 38 39 | |
normalize_scene_graph ¶
normalize_scene_graph(
scene_graph: HouseGanSceneGraph
| HouseGanSceneGraphPayload
| None,
*,
labels: Int[Tensor, "..."]
| Int[ndarray, "..."]
| Sequence[int | str]
| Sequence[Sequence[int | str]]
| None,
relations: Sequence[HouseGanRelationPayload] | None,
id2label: Mapping[int, str],
) -> HouseGanSceneGraph
Normalize public scene-graph payloads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene_graph
|
HouseGanSceneGraph | HouseGanSceneGraphPayload | None
|
Dataclass or mapping with |
required |
labels
|
Int[Tensor, '...'] | Int[ndarray, '...'] | Sequence[int | str] | Sequence[Sequence[int | str]] | None
|
Optional labels used when no full scene graph is supplied. |
required |
relations
|
Sequence[HouseGanRelationPayload] | None
|
Optional relation payload. |
required |
id2label
|
Mapping[int, str]
|
Public label map. |
required |
Returns:
| Type | Description |
|---|---|
HouseGanSceneGraph
|
Normalized scene graph preserving node order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no nodes can be resolved or labels are invalid. |
Examples:
>>> graph = normalize_scene_graph(None, labels=[0, 1], relations=[], id2label={0: "a", 1: "b"})
>>> len(graph.nodes)
2
Source code in models/housegan/src/housegan/graph_schema.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
complete_signed_edges ¶
complete_signed_edges(
nodes: Sequence[HouseGanRoomNode],
relations: Sequence[HouseGanRelation] | None,
*,
default_adjacent: bool = False,
device: device | None = None,
) -> Int[torch.Tensor, "edges 3"]
Build signed complete graph triples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
Sequence[HouseGanRoomNode]
|
Room nodes in preserved graph order. |
required |
relations
|
Sequence[HouseGanRelation] | None
|
Sparse public relations. |
required |
default_adjacent
|
bool
|
Whether missing pairs become adjacent. |
False
|
device
|
device | None
|
Optional tensor device. |
None
|
Returns:
| Type | Description |
|---|---|
Int[Tensor, 'edges 3']
|
|
Source code in models/housegan/src/housegan/graph_schema.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
graph_to_node_features ¶
graph_to_node_features(
nodes: Sequence[HouseGanRoomNode],
*,
label2id: Mapping[str, int],
num_labels: int,
device: device | None = None,
) -> Float[torch.Tensor, "elements room_labels"]
Convert public room labels to 10-way one-hot features.
Source code in models/housegan/src/housegan/graph_schema.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
relation_from_bboxes ¶
relation_from_bboxes(
bbox_ltrb: Sequence[Sequence[float]],
*,
threshold: float = 0.03,
) -> tuple[HouseGanRelation, ...]
Derive House-GAN adjacency relations from normalized ltrb boxes.
Source code in models/housegan/src/housegan/graph_schema.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
modeling_housegan ¶
PyTorch House-GAN generator in Transformers PreTrainedModel form.
HouseGanModelOutput
dataclass
¶
Bases: ModelOutput
Raw House-GAN model output.
Source code in models/housegan/src/housegan/modeling_housegan.py
16 17 18 19 20 21 22 | |
CMP ¶
Bases: Module
House-GAN convolutional message passing block.
Source code in models/housegan/src/housegan/modeling_housegan.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
__init__ ¶
__init__(in_channels: int) -> None
Initialize the CMP block.
Source code in models/housegan/src/housegan/modeling_housegan.py
67 68 69 70 71 72 73 74 | |
forward ¶
forward(
feats: Float[Tensor, "elements channels height width"],
edges: Int[Tensor, "edges 3"],
) -> Float[torch.Tensor, "elements channels height width"]
Pool positive and negative edge-neighbor features.
Source code in models/housegan/src/housegan/modeling_housegan.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
HouseGanGenerator ¶
Bases: PreTrainedModel
Transformers-compatible House-GAN generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
HouseGanConfig
|
House-GAN configuration. |
required |
Examples:
>>> model = HouseGanGenerator(HouseGanConfig())
>>> latents = torch.zeros(2, 128)
>>> nodes = torch.eye(10)[:2]
>>> edges = torch.tensor([[0, 1, 1]])
>>> tuple(model(latents, nodes, edges).masks.shape)
(2, 32, 32)
Source code in models/housegan/src/housegan/modeling_housegan.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
__init__ ¶
__init__(config: HouseGanConfig) -> None
Initialize generator layers.
Source code in models/housegan/src/housegan/modeling_housegan.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
forward ¶
forward(
latents: Float[Tensor, "elements latent"],
node_features: Float[Tensor, "elements room_labels"],
edges: Int[Tensor, "edges 3"],
return_dict: bool | None = None,
) -> (
HouseGanModelOutput
| tuple[Float[torch.Tensor, "elements height width"]]
)
Run a House-GAN forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Float[Tensor, 'elements latent']
|
Per-room latent vectors. |
required |
node_features
|
Float[Tensor, 'elements room_labels']
|
Per-room one-hot room features. |
required |
edges
|
Int[Tensor, 'edges 3']
|
Signed complete graph triples. |
required |
return_dict
|
bool | None
|
Whether to return |
None
|
Returns:
| Type | Description |
|---|---|
HouseGanModelOutput | tuple[Float[Tensor, 'elements height width']]
|
Raw generated room masks. |
Source code in models/housegan/src/housegan/modeling_housegan.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
pipeline_housegan ¶
Pipeline interface for House-GAN relation-conditioned generation.
HouseGanPipeline ¶
Bases: LayoutGenerationPipeline
Transformers-side House-GAN layout generation pipeline.
Source code in models/housegan/src/housegan/pipeline_housegan.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
__init__ ¶
__init__(
model: HouseGanGenerator,
processor: HouseGanProcessor | None = None,
config: HouseGanConfig | None = None,
device: int | device | None = None,
) -> None
Initialize the pipeline.
Source code in models/housegan/src/housegan/pipeline_housegan.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
__call__ ¶
__call__(
*,
batch_size: int = 1,
seed: int | None = None,
generator: Generator | None = None,
condition_type: ConditionType
| str = ConditionType.relation,
labels: Int[Tensor, "..."]
| Int[ndarray, "..."]
| NestedIntList
| None = None,
bbox: Float[Tensor, "... 4"]
| Float[ndarray, "... 4"]
| NestedFloatList
| None = None,
mask: Bool[Tensor, "..."]
| Bool[ndarray, "..."]
| NestedBoolList
| None = None,
num_elements: int
| list[int]
| Int[Tensor, "..."]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
num_inference_steps: int | None = None,
scene_graph: HouseGanSceneGraph
| HouseGanSceneGraphPayload
| list[HouseGanSceneGraphPayload]
| None = None,
relations: Sequence[HouseGanRelationPayload]
| None = None,
latents: Float[Tensor, "elements latent"] | None = None,
output_type: OutputType = "dataclass",
return_intermediates: bool = False,
) -> (
LayoutGenerationOutput
| dict[
str,
Shaped[torch.Tensor, "..."]
| dict[int, str]
| list[dict[str, str | int | float | bool | None]]
| None,
]
)
Generate a floorplan layout from room relation constraints.
Source code in models/housegan/src/housegan/pipeline_housegan.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
processing_housegan ¶
Processor for House-GAN relation graphs and mask decoding.
HouseGanProcessor ¶
Bases: ProcessorMixin
Normalize House-GAN scene graphs and decode generated masks.
Source code in models/housegan/src/housegan/processing_housegan.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
__init__ ¶
__init__(
*,
config: HouseGanConfig,
default_missing_relation: Literal[
"not_adjacent", "error"
] = "not_adjacent",
) -> None
Initialize processor metadata.
Source code in models/housegan/src/housegan/processing_housegan.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
save_pretrained ¶
save_pretrained(
save_directory: str | Path,
push_to_hub: bool = False,
**kwargs: str | int | float | bool | None,
) -> None
Save processor metadata.
Source code in models/housegan/src/housegan/processing_housegan.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
from_pretrained
classmethod
¶
from_pretrained(
pretrained_model_name_or_path: str | PathLike[str],
cache_dir: str | PathLike[str] | None = None,
force_download: bool = False,
local_files_only: bool = False,
token: str | bool | None = None,
revision: str = "main",
subfolder: str | None = None,
**kwargs: str | int | float | bool | None,
) -> Self
Load processor metadata from processor_config.json.
Source code in models/housegan/src/housegan/processing_housegan.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
__call__ ¶
__call__(
*,
condition_type: ConditionType
| str = ConditionType.relation,
scene_graph: HouseGanSceneGraph
| HouseGanSceneGraphPayload
| None = None,
relations: Sequence[HouseGanRelationPayload]
| None = None,
labels: Int[Tensor, "..."]
| Int[ndarray, "..."]
| Sequence[Sequence[int]]
| Sequence[int]
| None = None,
bbox: Float[Tensor, "... 4"]
| Float[ndarray, "... 4"]
| Sequence[Sequence[Sequence[float]]]
| Sequence[Sequence[float]]
| Sequence[ArrayLikeInput]
| None = None,
mask: Bool[Tensor, "..."]
| Bool[ndarray, "..."]
| Sequence[Sequence[bool]]
| Sequence[bool]
| Sequence[ArrayLikeInput]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
return_tensors: Literal["pt"] = "pt",
) -> BatchEncoding
Encode public relation inputs into House-GAN tensors.
Source code in models/housegan/src/housegan/processing_housegan.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
normalize_condition_type ¶
normalize_condition_type(
condition_type: ConditionType | str,
) -> ConditionType
Normalize and validate the House-GAN condition type.
Source code in models/housegan/src/housegan/processing_housegan.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
post_process_masks ¶
post_process_masks(
masks: Float[Tensor, "elements height width"],
*,
labels: Int[Tensor, "elements"],
edges: Int[Tensor, "edges 3"] | None = None,
node_features: Float[Tensor, "elements room_labels"]
| None = None,
scene_graph: HouseGanSceneGraph | None = None,
output_type: OutputType = "dataclass",
return_intermediates: bool = False,
) -> (
LayoutGenerationOutput
| dict[
str,
Shaped[torch.Tensor, "..."]
| dict[int, str]
| dict[
str,
Shaped[torch.Tensor, "..."]
| HouseGanSceneGraph
| None,
]
| None,
]
)
Convert generated room masks to public normalized boxes.
Source code in models/housegan/src/housegan/processing_housegan.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
mask_to_ltrb ¶
mask_to_ltrb(
masks: Float[Tensor, "elements height width"],
*,
threshold: float = 0.0,
) -> Float[torch.Tensor, "elements 4"]
Convert thresholded masks to inclusive-exclusive ltrb boxes.
Source code in models/housegan/src/housegan/processing_housegan.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
vendor_state_dict ¶
State-dict validation helpers for original House-GAN checkpoints.
ConversionReport
dataclass
¶
Measured state-dict conversion metadata.
Source code in models/housegan/src/housegan/vendor_state_dict.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
to_dict ¶
to_dict() -> HouseGanConversionReport
Serialize report to JSON-compatible values.
Source code in models/housegan/src/housegan/vendor_state_dict.py
24 25 26 27 28 29 30 31 | |
convert_state_dict ¶
convert_state_dict(
source: Mapping[str, Shaped[Tensor, "..."]],
) -> tuple[
OrderedDict[str, Shaped[torch.Tensor, "..."]],
ConversionReport,
]
Validate and copy an original raw generator state dict.
Source code in models/housegan/src/housegan/vendor_state_dict.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
visualization ¶
Visualization helpers for House-GAN outputs.
render_layout ¶
render_layout(
bbox: Float[Tensor, "elements 4"],
labels: Int[Tensor, "elements"],
*,
id2label: Mapping[int, str],
canvas_size: tuple[int, int] = (256, 256),
) -> Image.Image
Render normalized center xywh boxes for debugging.
Source code in models/housegan/src/housegan/visualization.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |