Validators API
Tools for asset validation, quality control, and conversion.
embodied_gen.validators.aesthetic_predictor
AestheticPredictor
AestheticPredictor(clip_model_dir=None, sac_model_path=None, device='cpu')
Aesthetic Score Predictor using CLIP and a pre-trained MLP.
Checkpoints from https://github.com/christophschuhmann/improved-aesthetic-predictor/tree/main.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clip_model_dir
|
str
|
Path to CLIP model directory. |
None
|
sac_model_path
|
str
|
Path to SAC model weights. |
None
|
device
|
str
|
Device for computation ("cuda" or "cpu"). |
'cpu'
|
Example
from embodied_gen.validators.aesthetic_predictor import AestheticPredictor
predictor = AestheticPredictor(device="cuda")
score = predictor.predict("image.png")
print("Aesthetic score:", score)
Source code in embodied_gen/validators/aesthetic_predictor.py
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 | |
normalized
staticmethod
normalized(a, axis=-1, order=2)
Normalize the array to unit norm.
Source code in embodied_gen/validators/aesthetic_predictor.py
96 97 98 99 100 101 | |
predict
predict(image_path)
Predicts the aesthetic score for a given image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_path
|
str
|
Path to the image file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
Predicted aesthetic score. |
Source code in embodied_gen/validators/aesthetic_predictor.py
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 | |
embodied_gen.validators.quality_checkers
BaseChecker
BaseChecker(prompt: str = None, verbose: bool = False)
Base class for quality checkers using GPT clients.
Provides a common interface for querying and validating responses.
Subclasses must implement the query method.
Attributes:
| Name | Type | Description |
|---|---|---|
prompt |
str
|
The prompt used for queries. |
verbose |
bool
|
Whether to enable verbose logging. |
Source code in embodied_gen/validators/quality_checkers.py
53 54 55 | |
validate
staticmethod
validate(checkers: list[BaseChecker], images_list: list[list[str]]) -> list
Validates a list of checkers against corresponding image lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkers
|
list[BaseChecker]
|
List of checker instances. |
required |
images_list
|
list[list[str]]
|
List of image path lists. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
Validation results with overall outcome. |
Source code in embodied_gen/validators/quality_checkers.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 | |
ImageAestheticChecker
ImageAestheticChecker(clip_model_dir: str = None, sac_model_path: str = None, thresh: float = 4.5, verbose: bool = False)
Bases: BaseChecker
Evaluates the aesthetic quality of images using a CLIP-based predictor.
Attributes:
| Name | Type | Description |
|---|---|---|
clip_model_dir |
str
|
Path to the CLIP model directory. |
sac_model_path |
str
|
Path to the aesthetic predictor model weights. |
thresh |
float
|
Threshold above which images are considered aesthetically acceptable. |
verbose |
bool
|
Whether to print detailed log messages. |
predictor |
AestheticPredictor
|
The model used to predict aesthetic scores. |
Example
from embodied_gen.validators.quality_checkers import ImageAestheticChecker
checker = ImageAestheticChecker(thresh=4.5)
flag, score = checker(["image1.png", "image2.png"])
print("Aesthetic OK:", flag, "Score:", score)
Source code in embodied_gen/validators/quality_checkers.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
ImageSegChecker
ImageSegChecker(gpt_client: GPTclient, prompt: str = None, verbose: bool = False)
Bases: BaseChecker
A segmentation quality checker for 3D assets using GPT-based reasoning.
This class compares an original image with its segmented version to evaluate whether the segmentation successfully isolates the main object with minimal truncation and correct foreground extraction.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
GPT client used for multi-modal image analysis. |
prompt |
str
|
The prompt used to guide the GPT model for evaluation. |
verbose |
bool
|
Whether to enable verbose logging. |
Source code in embodied_gen/validators/quality_checkers.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
MeshGeoChecker
MeshGeoChecker(gpt_client: GPTclient, prompt: str = None, verbose: bool = False)
Bases: BaseChecker
A geometry quality checker for 3D mesh assets using GPT-based reasoning.
This class leverages a multi-modal GPT client to analyze rendered images of a 3D object and determine if its geometry is complete.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
The GPT client used for multi-modal querying. |
prompt |
str
|
The prompt sent to the GPT model. If not provided, a default one is used. |
verbose |
bool
|
Whether to print debug information during evaluation. |
Source code in embodied_gen/validators/quality_checkers.py
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 | |
PanoHeightEstimator
PanoHeightEstimator(gpt_client: GPTclient, default_value: float = 3.5)
Bases: object
Estimate the real ceiling height of an indoor space from a 360° panoramic image.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
The GPT client used to perform image-based reasoning and return height estimates. |
default_value |
float
|
The fallback height in meters if parsing the GPT output fails. |
prompt |
str
|
The textual instruction used to guide the GPT model for height estimation. |
Source code in embodied_gen/validators/quality_checkers.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
PanoImageGenChecker
PanoImageGenChecker(gpt_client: GPTclient, prompt: str = None, verbose: bool = False)
Bases: BaseChecker
A checker class that validates the quality and realism of generated panoramic indoor images.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
A GPT client instance used to query for image validation. |
prompt |
str
|
The instruction prompt passed to the GPT model. If None, a default prompt is used. |
verbose |
bool
|
Whether to print internal processing information for debugging. |
Source code in embodied_gen/validators/quality_checkers.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
PanoImageOccChecker
PanoImageOccChecker(gpt_client: GPTclient, box_hw: tuple[int, int], prompt: str = None, verbose: bool = False)
Bases: BaseChecker
Checks for physical obstacles in the bottom-center region of a panoramic image.
This class crops a specified region from the input panoramic image and uses a GPT client to determine whether any physical obstacles there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gpt_client
|
GPTclient
|
The GPT-based client used for visual reasoning. |
required |
box_hw
|
tuple[int, int]
|
The height and width of the crop box. |
required |
prompt
|
str
|
Custom prompt for the GPT client. Defaults to a predefined one. |
None
|
verbose
|
bool
|
Whether to print verbose logs. Defaults to False. |
False
|
Source code in embodied_gen/validators/quality_checkers.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | |
SemanticConsistChecker
SemanticConsistChecker(gpt_client: GPTclient, prompt: str = None, verbose: bool = False)
Bases: BaseChecker
Checks semantic consistency between text descriptions and segmented images.
Uses GPT to evaluate if the image matches the text in object type, geometry, and color.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
GPT client for queries. |
prompt |
str
|
Prompt for consistency evaluation. |
verbose |
bool
|
Whether to enable verbose logging. |
Source code in embodied_gen/validators/quality_checkers.py
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 300 301 302 303 304 305 | |
SemanticMatcher
SemanticMatcher(gpt_client: GPTclient, prompt: str = None, verbose: bool = False, seed: int = None)
Bases: BaseChecker
Matches query text to semantically similar scene descriptions.
Uses GPT to find the most similar scene IDs from a dictionary.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
GPT client for queries. |
prompt |
str
|
Prompt for semantic matching. |
verbose |
bool
|
Whether to enable verbose logging. |
seed |
int
|
Random seed for selection. |
Source code in embodied_gen/validators/quality_checkers.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
query
query(text: str, context: dict, rand: bool = True, params: dict = None) -> str
Queries for semantically similar scene IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Query text. |
required |
context
|
dict
|
Dictionary of scene descriptions. |
required |
rand
|
bool
|
Whether to randomly select from top matches. |
True
|
params
|
dict
|
Additional GPT parameters. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Matched scene ID. |
Source code in embodied_gen/validators/quality_checkers.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | |
TextGenAlignChecker
TextGenAlignChecker(gpt_client: GPTclient, prompt: str = None, verbose: bool = False)
Bases: BaseChecker
Evaluates alignment between text prompts and generated 3D asset images.
Assesses if the rendered images match the text description in category and geometry.
Attributes:
| Name | Type | Description |
|---|---|---|
gpt_client |
GPTclient
|
GPT client for queries. |
prompt |
str
|
Prompt for alignment evaluation. |
verbose |
bool
|
Whether to enable verbose logging. |
Source code in embodied_gen/validators/quality_checkers.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
embodied_gen.validators.urdf_convertor
URDFGenerator
URDFGenerator(gpt_client: GPTclient, mesh_file_list: list[str] = ['material_0.png', 'material.mtl'], prompt_template: str = None, attrs_name: list[str] = None, render_dir: str = 'urdf_renders', render_view_num: int = 4, decompose_convex: bool = False, rotate_xyzw: list[float] = (0.7071, 0, 0, 0.7071))
Bases: object
Generates URDF files for 3D assets with physical and semantic attributes.
Uses GPT to estimate object properties and generates a URDF file with mesh, friction, mass, and metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gpt_client
|
GPTclient
|
GPT client for attribute estimation. |
required |
mesh_file_list
|
list[str]
|
Additional mesh files to copy. |
['material_0.png', 'material.mtl']
|
prompt_template
|
str
|
Prompt template for GPT queries. |
None
|
attrs_name
|
list[str]
|
List of attribute names to include. |
None
|
render_dir
|
str
|
Directory for rendered images. |
'urdf_renders'
|
render_view_num
|
int
|
Number of views to render. |
4
|
decompose_convex
|
bool
|
Whether to decompose mesh for collision. |
False
|
rotate_xyzw
|
list[float]
|
Quaternion for mesh rotation. |
(0.7071, 0, 0, 0.7071)
|
Example
from embodied_gen.validators.urdf_convertor import URDFGenerator
from embodied_gen.utils.gpt_clients import GPT_CLIENT
urdf_gen = URDFGenerator(GPT_CLIENT, render_view_num=4)
urdf_path = urdf_gen(mesh_path="mesh.obj", output_root="output_dir")
print("Generated URDF:", urdf_path)
Source code in embodied_gen/validators/urdf_convertor.py
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 | |
__call__
__call__(mesh_path: str, output_root: str, text_prompt: str = None, category: str = 'unknown', **kwargs)
Generates a URDF file for a mesh asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_path
|
str
|
Path to mesh file. |
required |
output_root
|
str
|
Directory for outputs. |
required |
text_prompt
|
str
|
Prompt for GPT. |
None
|
category
|
str
|
Asset category. |
'unknown'
|
**kwargs
|
Additional attributes. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
Path to generated URDF file. |
Source code in embodied_gen/validators/urdf_convertor.py
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
add_quality_tag
staticmethod
add_quality_tag(urdf_path: str, results: list, output_path: str = None) -> None
Adds a quality tag to a URDF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to the URDF file. |
required |
results
|
list
|
List of [checker_name, result] pairs. |
required |
output_path
|
str
|
Output file path. |
None
|
Source code in embodied_gen/validators/urdf_convertor.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
generate_urdf
generate_urdf(input_mesh: str, output_dir: str, attr_dict: dict, output_name: str = None) -> str
Generate a URDF file for a given mesh with specified attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_mesh
|
str
|
Path to the input mesh file. |
required |
output_dir
|
str
|
Directory to store the generated URDF and mesh. |
required |
attr_dict
|
dict
|
Dictionary of asset attributes. |
required |
output_name
|
str
|
Name for the URDF and robot. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Path to the generated URDF file. |
Source code in embodied_gen/validators/urdf_convertor.py
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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
get_attr_from_urdf
staticmethod
get_attr_from_urdf(urdf_path: str, attr_root: str = './/link/extra_info', attr_name: str = 'scale') -> float
Extracts an attribute value from a URDF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urdf_path
|
str
|
Path to the URDF file. |
required |
attr_root
|
str
|
XML path to attribute root. |
'.//link/extra_info'
|
attr_name
|
str
|
Attribute name. |
'scale'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Attribute value, or None if not found. |
Source code in embodied_gen/validators/urdf_convertor.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
get_estimated_attributes
get_estimated_attributes(asset_attrs: dict)
Calculates estimated attributes from asset properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_attrs
|
dict
|
Asset attributes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Estimated attributes (height, mass, mu, category). |
Source code in embodied_gen/validators/urdf_convertor.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
parse_response
parse_response(response: str) -> dict[str, any]
Parses GPT response to extract asset attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
str
|
GPT response string. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, any]
|
dict[str, any]: Parsed attributes. |
Source code in embodied_gen/validators/urdf_convertor.py
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 | |