Models API
embodied_gen.models.texture_model
build_texture_gen_pipe
build_texture_gen_pipe(base_ckpt_dir: str, controlnet_ckpt: str = None, ip_adapt_scale: float = 0, device: str = 'cuda') -> DiffusionPipeline
Build and initialize the Kolors + ControlNet (optional IP-Adapter) texture generation pipeline.
Loads Kolors tokenizer, text encoder (ChatGLM), VAE, UNet, scheduler and (optionally)
a ControlNet checkpoint plus IP-Adapter vision encoder. If controlnet_ckpt is
not provided, the default multi-view texture ControlNet weights are downloaded
automatically from the hub. When ip_adapt_scale > 0 an IP-Adapter vision
encoder and its weights are also loaded and activated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_ckpt_dir
|
str
|
Root directory where Kolors (and optionally Kolors-IP-Adapter-Plus) weights
are or will be stored. Required subfolders: |
required |
controlnet_ckpt
|
str
|
Directory containing a ControlNet checkpoint (safetensors). If |
None
|
ip_adapt_scale
|
float
|
Strength (>=0) of IP-Adapter conditioning. Set >0 to enable IP-Adapter; typical values: 0.4-0.8. Default: 0 (disabled). |
0
|
device
|
str
|
Target device to move the pipeline to (e.g. |
'cuda'
|
Returns:
| Name | Type | Description |
|---|---|---|
DiffusionPipeline |
DiffusionPipeline
|
A configured |
DiffusionPipeline
|
|
|
DiffusionPipeline
|
generation (with optional IP-Adapter support). |
Example
Initialize pipeline with IP-Adapter enabled.
from embodied_gen.models.texture_model import build_texture_gen_pipe
ip_adapt_scale = 0.7
PIPELINE = build_texture_gen_pipe(
base_ckpt_dir="./weights",
ip_adapt_scale=ip_adapt_scale,
device="cuda",
)
PIPELINE.set_ip_adapter_scale([ip_adapt_scale])
from embodied_gen.models.texture_model import build_texture_gen_pipe
PIPELINE = build_texture_gen_pipe(
base_ckpt_dir="./weights",
ip_adapt_scale=0,
device="cuda",
)
Source code in embodied_gen/models/texture_model.py
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 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 | |
embodied_gen.models.gs_model
GaussianOperator
dataclass
GaussianOperator(_opacities: Tensor, _means: Tensor, _scales: Tensor, _quats: Tensor, _rgbs: Optional[Tensor] = None, _features_dc: Optional[Tensor] = None, _features_rest: Optional[Tensor] = None, sh_degree: Optional[int] = 0, device: str = 'cuda')
Bases: GaussianBase
Gaussian Splatting operator.
Supports transformation, scaling, color computation, and rasterization-based rendering.
Inherits
GaussianBase: Base class with Gaussian params (means, scales, etc.)
Functionality includes: - Applying instance poses to transform Gaussian means and quaternions. - Scaling Gaussians to a real-world size. - Computing colors using spherical harmonics. - Rendering images via differentiable rasterization. - Exporting transformed and rescaled models to .ply format.
get_gaussians
get_gaussians(c2w: Tensor = None, instance_pose: Tensor = None, apply_activate: bool = False) -> GaussianBase
Get Gaussian data under the given instance_pose.
Source code in embodied_gen/models/gs_model.py
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 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
embodied_gen.models.layout
LayoutDesigner
LayoutDesigner(gpt_client: GPTclient, system_prompt: str, verbose: bool = False)
Bases: object
A class for querying GPT-based scene layout reasoning and formatting responses.
Attributes:
| Name | Type | Description |
|---|---|---|
prompt |
str
|
The system prompt for GPT. |
verbose |
bool
|
Whether to log responses. |
gpt_client |
GPTclient
|
The GPT client instance. |
Methods:
| Name | Description |
|---|---|
query |
Query GPT with a prompt and parameters. |
format_response |
Parse and clean JSON response. |
format_response_repair |
Repair and parse JSON response. |
save_output |
Save output to file. |
__call__ |
Query and process output. |
Source code in embodied_gen/models/layout.py
394 395 396 397 398 399 400 401 402 | |
__call__
__call__(prompt: str, save_path: str = None, params: dict = None) -> dict | str
Query GPT and process the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User prompt. |
required |
save_path
|
str
|
Path to save output. |
None
|
params
|
dict
|
GPT parameters. |
None
|
Returns:
| Type | Description |
|---|---|
dict | str
|
dict | str: Output data. |
Source code in embodied_gen/models/layout.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
format_response
format_response(response: str) -> dict
Format and parse GPT response as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
str
|
Raw GPT response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Parsed JSON output. |
Raises:
| Type | Description |
|---|---|
JSONDecodeError
|
If parsing fails. |
Source code in embodied_gen/models/layout.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
format_response_repair
format_response_repair(response: str) -> dict
Repair and parse possibly broken JSON response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
str
|
Raw GPT response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Parsed JSON output. |
Source code in embodied_gen/models/layout.py
448 449 450 451 452 453 454 455 456 457 | |
query
query(prompt: str, params: dict = None) -> str
Query GPT with the system prompt and user prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User prompt. |
required |
params
|
dict
|
GPT parameters. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
GPT response. |
Source code in embodied_gen/models/layout.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
save_output
save_output(output: dict, save_path: str) -> None
Save output dictionary to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict
|
Output data. |
required |
save_path
|
str
|
Path to save the file. |
required |
Source code in embodied_gen/models/layout.py
459 460 461 462 463 464 465 466 467 468 | |
build_scene_layout
build_scene_layout(task_desc: str, output_path: str = None, gpt_params: dict = None) -> LayoutInfo
Build a 3D scene layout from a natural language task description.
This function uses GPT-based reasoning to generate a structured scene layout, including object hierarchy, spatial relations, and style descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_desc
|
str
|
Natural language description of the robotic task. |
required |
output_path
|
str
|
Path to save the visualized scene tree. |
None
|
gpt_params
|
dict
|
Parameters for GPT queries. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
LayoutInfo |
LayoutInfo
|
Structured layout information for the scene. |
Example
from embodied_gen.models.layout import build_scene_layout
layout_info = build_scene_layout(
task_desc="Put the apples on the table on the plate",
output_path="outputs/scene_tree.jpg",
)
print(layout_info)
Source code in embodied_gen/models/layout.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
embodied_gen.models.text_model
build_text2img_ip_pipeline
build_text2img_ip_pipeline(ckpt_dir: str, ref_scale: float, device: str = 'cuda') -> StableDiffusionXLPipelineIP
Builds a Stable Diffusion XL pipeline with IP-Adapter for text-to-image generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ckpt_dir
|
str
|
Directory containing model checkpoints. |
required |
ref_scale
|
float
|
Reference scale for IP-Adapter. |
required |
device
|
str
|
Device for inference. |
'cuda'
|
Returns:
| Name | Type | Description |
|---|---|---|
StableDiffusionXLPipelineIP |
StableDiffusionXLPipeline
|
Configured pipeline. |
Example
from embodied_gen.models.text_model import build_text2img_ip_pipeline
pipe = build_text2img_ip_pipeline("weights/Kolors", ref_scale=0.3)
Source code in embodied_gen/models/text_model.py
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 | |
build_text2img_pipeline
build_text2img_pipeline(ckpt_dir: str, device: str = 'cuda') -> StableDiffusionXLPipeline
Builds a Stable Diffusion XL pipeline for text-to-image generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ckpt_dir
|
str
|
Directory containing model checkpoints. |
required |
device
|
str
|
Device for inference. |
'cuda'
|
Returns:
| Name | Type | Description |
|---|---|---|
StableDiffusionXLPipeline |
StableDiffusionXLPipeline
|
Configured pipeline. |
Example
from embodied_gen.models.text_model import build_text2img_pipeline
pipe = build_text2img_pipeline("weights/Kolors")
Source code in embodied_gen/models/text_model.py
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 | |
download_kolors_weights
download_kolors_weights(local_dir: str = 'weights/Kolors') -> None
Downloads Kolors model weights from HuggingFace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_dir
|
str
|
Local directory to store weights. |
'weights/Kolors'
|
Source code in embodied_gen/models/text_model.py
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 | |
text2img_gen
text2img_gen(prompt: str, n_sample: int, guidance_scale: float, pipeline: StableDiffusionXLPipeline | StableDiffusionXLPipeline, ip_image: Image | str = None, image_wh: tuple[int, int] = [1024, 1024], infer_step: int = 50, ip_image_size: int = 512, seed: int = None) -> list[Image.Image]
Generates images from text prompts using a Stable Diffusion XL pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt for image generation. |
required |
n_sample
|
int
|
Number of images to generate. |
required |
guidance_scale
|
float
|
Guidance scale for diffusion. |
required |
pipeline
|
StableDiffusionXLPipeline | StableDiffusionXLPipeline
|
Pipeline instance. |
required |
ip_image
|
Image | str
|
Reference image for IP-Adapter. |
None
|
image_wh
|
tuple[int, int]
|
Output image size (width, height). |
[1024, 1024]
|
infer_step
|
int
|
Number of inference steps. |
50
|
ip_image_size
|
int
|
Size for IP-Adapter image. |
512
|
seed
|
int
|
Random seed. |
None
|
Returns:
| Type | Description |
|---|---|
list[Image]
|
list[Image.Image]: List of generated images. |
Example
from embodied_gen.models.text_model import text2img_gen
images = text2img_gen(prompt="banana", n_sample=3, guidance_scale=7.5)
images[0].save("banana.png")
Source code in embodied_gen/models/text_model.py
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 | |
embodied_gen.models.sr_model
ImageRealESRGAN
ImageRealESRGAN(outscale: int, model_path: str = None)
A wrapper for Real-ESRGAN-based image super-resolution.
This class uses the RealESRGAN model to perform image upscaling, typically by a factor of 4.
Attributes:
| Name | Type | Description |
|---|---|---|
outscale |
int
|
The output image scale factor (e.g., 2, 4). |
model_path |
str
|
Path to the pre-trained model weights. |
Example
from embodied_gen.models.sr_model import ImageRealESRGAN
from PIL import Image
sr_model = ImageRealESRGAN(outscale=4)
img = Image.open("input.png")
upscaled = sr_model(img)
upscaled.save("output.png")
Initializes the RealESRGAN upscaler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outscale
|
int
|
Output scale factor. |
required |
model_path
|
str
|
Path to model weights. |
None
|
Source code in embodied_gen/models/sr_model.py
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 | |
__call__
__call__(image: Union[Image, ndarray]) -> Image.Image
Performs super-resolution on the input image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[Image, ndarray]
|
Input image. |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Upscaled image. |
Source code in embodied_gen/models/sr_model.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
ImageStableSR
ImageStableSR(model_path: str = 'stabilityai/stable-diffusion-x4-upscaler', device='cuda')
Super-resolution image upscaler using Stable Diffusion x4 upscaling model.
This class wraps the StabilityAI Stable Diffusion x4 upscaler for high-quality image super-resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Path or HuggingFace repo for the model. |
'stabilityai/stable-diffusion-x4-upscaler'
|
device
|
str
|
Device for inference. |
'cuda'
|
Example
from embodied_gen.models.sr_model import ImageStableSR
from PIL import Image
sr_model = ImageStableSR()
img = Image.open("input.png")
upscaled = sr_model(img)
upscaled.save("output.png")
Initializes the Stable Diffusion x4 upscaler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Model path or repo. |
'stabilityai/stable-diffusion-x4-upscaler'
|
device
|
str
|
Device for inference. |
'cuda'
|
Source code in embodied_gen/models/sr_model.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
__call__
__call__(image: Union[Image, ndarray], prompt: str = '', infer_step: int = 20) -> Image.Image
Performs super-resolution on the input image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[Image, ndarray]
|
Input image. |
required |
prompt
|
str
|
Text prompt for upscaling. |
''
|
infer_step
|
int
|
Number of inference steps. |
20
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Upscaled image. |
Source code in embodied_gen/models/sr_model.py
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 | |
embodied_gen.models.segment_model
BMGG14Remover
BMGG14Remover()
Bases: object
Removes background using the RMBG-1.4 segmentation model.
Example
from embodied_gen.models.segment_model import BMGG14Remover
remover = BMGG14Remover()
result = remover("input.jpg", "output.png")
Initializes the BMGG14Remover.
Source code in embodied_gen/models/segment_model.py
369 370 371 372 373 374 375 | |
__call__
__call__(image: Union[str, Image, ndarray], save_path: str = None)
Removes background from an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[str, Image, ndarray]
|
Input image. |
required |
save_path
|
str
|
Path to save the output image. |
None
|
Returns:
| Type | Description |
|---|---|
|
Image.Image: Image with background removed. |
Source code in embodied_gen/models/segment_model.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
RembgRemover
RembgRemover()
Bases: object
Removes background from images using the rembg library.
Example
from embodied_gen.models.segment_model import RembgRemover
remover = RembgRemover()
result = remover("input.jpg", "output.png")
Initializes the RembgRemover.
Source code in embodied_gen/models/segment_model.py
327 328 329 | |
__call__
__call__(image: Union[str, Image, ndarray], save_path: str = None) -> Image.Image
Removes background from an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[str, Image, ndarray]
|
Input image. |
required |
save_path
|
str
|
Path to save the output image. |
None
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Image with background removed (RGBA). |
Source code in embodied_gen/models/segment_model.py
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 | |
SAMPredictor
SAMPredictor(checkpoint: str = None, model_type: str = 'vit_h', binary_thresh: float = 0.1, device: str = 'cuda')
Bases: object
Loads SAM models and predicts segmentation masks from user points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint
|
str
|
Path to model checkpoint. |
None
|
model_type
|
str
|
SAM model type. |
'vit_h'
|
binary_thresh
|
float
|
Threshold for binary mask. |
0.1
|
device
|
str
|
Device for inference. |
'cuda'
|
Source code in embodied_gen/models/segment_model.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
__call__
__call__(image: Union[str, Image, ndarray], selected_points: list[list[int]]) -> Image.Image
Segments image using selected points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[str, Image, ndarray]
|
Input image. |
required |
selected_points
|
list[list[int]]
|
List of points and labels. |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Segmented RGBA image. |
Source code in embodied_gen/models/segment_model.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
generate_masks
generate_masks(image: ndarray, selected_points: list[list[int]]) -> np.ndarray
Generates segmentation masks from selected points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
Input image array. |
required |
selected_points
|
list[list[int]]
|
List of points and labels. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
list[tuple[np.ndarray, str]]: List of masks and names. |
Source code in embodied_gen/models/segment_model.py
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 | |
get_segmented_image
get_segmented_image(image: ndarray, masks: list[tuple[ndarray, str]]) -> Image.Image
Combines masks and returns segmented image with alpha channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
Input image array. |
required |
masks
|
list[tuple[ndarray, str]]
|
List of masks. |
required |
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Segmented RGBA image. |
Source code in embodied_gen/models/segment_model.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 | |
preprocess_image
preprocess_image(image: Image) -> np.ndarray
Preprocesses input image for SAM prediction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Preprocessed image array. |
Source code in embodied_gen/models/segment_model.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
SAMRemover
SAMRemover(checkpoint: str = None, model_type: str = 'vit_h', area_ratio: float = 15)
Bases: object
Loads SAM models and performs background removal on images.
Attributes:
| Name | Type | Description |
|---|---|---|
checkpoint |
str
|
Path to the model checkpoint. |
model_type |
str
|
Type of the SAM model to load. |
area_ratio |
float
|
Area ratio for filtering small connected components. |
Example
from embodied_gen.models.segment_model import SAMRemover
remover = SAMRemover(model_type="vit_h")
result = remover("input.jpg", "output.png")
Source code in embodied_gen/models/segment_model.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
__call__
__call__(image: Union[str, Image, ndarray], save_path: str = None) -> Image.Image
Removes the background from an image using the SAM model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[str, Image, ndarray]
|
Input image. |
required |
save_path
|
str
|
Path to save the output image. |
None
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Image with background removed (RGBA). |
Source code in embodied_gen/models/segment_model.py
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 | |
get_segmented_image_by_agent
get_segmented_image_by_agent(image: Image, sam_remover: SAMRemover, rbg_remover: RembgRemover, seg_checker: ImageSegChecker = None, save_path: str = None, mode: Literal['loose', 'strict'] = 'loose') -> Image.Image
Segments an image using SAM and rembg, with quality checking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image. |
required |
sam_remover
|
SAMRemover
|
SAM-based remover. |
required |
rbg_remover
|
RembgRemover
|
rembg-based remover. |
required |
seg_checker
|
ImageSegChecker
|
Quality checker. |
None
|
save_path
|
str
|
Path to save the output image. |
None
|
mode
|
Literal['loose', 'strict']
|
Segmentation mode. |
'loose'
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Segmented RGBA image. |
Source code in embodied_gen/models/segment_model.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 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 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
invert_rgba_pil
invert_rgba_pil(image: Image, mask: Image, save_path: str = None) -> Image.Image
Inverts the alpha channel of an RGBA image using a mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input RGB image. |
required |
mask
|
Image
|
Mask image for alpha inversion. |
required |
save_path
|
str
|
Path to save the output image. |
None
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: RGBA image with inverted alpha. |
Source code in embodied_gen/models/segment_model.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
embodied_gen.models.image_comm_model
BasePipelineLoader
BasePipelineLoader(device='cuda')
Bases: ABC
Abstract base class for loading Hugging Face image generation pipelines.
Attributes:
| Name | Type | Description |
|---|---|---|
device |
str
|
Device to load the pipeline on. |
Methods:
| Name | Description |
|---|---|
load |
Loads and returns the pipeline. |
Source code in embodied_gen/models/image_comm_model.py
50 51 | |
load
abstractmethod
load()
Load and return the pipeline instance.
Source code in embodied_gen/models/image_comm_model.py
53 54 55 56 | |
BasePipelineRunner
BasePipelineRunner(pipe)
Bases: ABC
Abstract base class for running image generation pipelines.
Attributes:
| Name | Type | Description |
|---|---|---|
pipe |
The loaded pipeline. |
Methods:
| Name | Description |
|---|---|
run |
Runs the pipeline with a prompt. |
Source code in embodied_gen/models/image_comm_model.py
69 70 | |
run
abstractmethod
run(prompt: str, **kwargs) -> Image.Image
Run the pipeline with the given prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt for image generation. |
required |
**kwargs
|
Additional pipeline arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Generated image(s). |
Source code in embodied_gen/models/image_comm_model.py
72 73 74 75 76 77 78 79 80 81 82 83 | |
ChromaLoader
ChromaLoader(device='cuda')
Bases: BasePipelineLoader
Loader for Chroma pipeline.
Source code in embodied_gen/models/image_comm_model.py
50 51 | |
load
load()
Load the Chroma pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
ChromaPipeline |
Loaded pipeline. |
Source code in embodied_gen/models/image_comm_model.py
296 297 298 299 300 301 302 303 304 | |
ChromaRunner
ChromaRunner(pipe)
Bases: BasePipelineRunner
Runner for Chroma pipeline.
Source code in embodied_gen/models/image_comm_model.py
69 70 | |
run
run(prompt: str, negative_prompt=None, **kwargs) -> Image.Image
Generate images using Chroma pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt. |
required |
negative_prompt
|
str
|
Negative prompt. |
None
|
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Generated image(s). |
Source code in embodied_gen/models/image_comm_model.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
CosmosLoader
CosmosLoader(model_id='nvidia/Cosmos-Predict2-2B-Text2Image', local_dir='weights/cosmos2', device='cuda')
Bases: BasePipelineLoader
Loader for Cosmos2 text-to-image pipeline.
Source code in embodied_gen/models/image_comm_model.py
127 128 129 130 131 132 133 134 135 | |
load
load()
Load the Cosmos2 text-to-image pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
Cosmos2TextToImagePipeline |
Loaded pipeline. |
Source code in embodied_gen/models/image_comm_model.py
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 | |
CosmosRunner
CosmosRunner(pipe)
Bases: BasePipelineRunner
Runner for Cosmos2 text-to-image pipeline.
Source code in embodied_gen/models/image_comm_model.py
69 70 | |
run
run(prompt: str, negative_prompt=None, **kwargs) -> Image.Image
Generate images using Cosmos2 pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt. |
required |
negative_prompt
|
str
|
Negative prompt. |
None
|
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Generated image(s). |
Source code in embodied_gen/models/image_comm_model.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
FluxLoader
FluxLoader(device='cuda')
Bases: BasePipelineLoader
Loader for Flux pipeline.
Source code in embodied_gen/models/image_comm_model.py
50 51 | |
load
load()
Load the Flux pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
FluxPipeline |
Loaded pipeline. |
Source code in embodied_gen/models/image_comm_model.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
FluxRunner
FluxRunner(pipe)
Bases: BasePipelineRunner
Runner for Flux pipeline.
Source code in embodied_gen/models/image_comm_model.py
69 70 | |
run
run(prompt: str, **kwargs) -> Image.Image
Generate images using Flux pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt. |
required |
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Generated image(s). |
Source code in embodied_gen/models/image_comm_model.py
279 280 281 282 283 284 285 286 287 288 289 | |
KolorsLoader
KolorsLoader(device='cuda')
Bases: BasePipelineLoader
Loader for Kolors pipeline.
Source code in embodied_gen/models/image_comm_model.py
50 51 | |
load
load()
Load the Kolors pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
KolorsPipeline |
Loaded pipeline. |
Source code in embodied_gen/models/image_comm_model.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
KolorsRunner
KolorsRunner(pipe)
Bases: BasePipelineRunner
Runner for Kolors pipeline.
Source code in embodied_gen/models/image_comm_model.py
69 70 | |
run
run(prompt: str, **kwargs) -> Image.Image
Generate images using Kolors pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt. |
required |
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Generated image(s). |
Source code in embodied_gen/models/image_comm_model.py
243 244 245 246 247 248 249 250 251 252 253 | |
SD35Loader
SD35Loader(device='cuda')
Bases: BasePipelineLoader
Loader for Stable Diffusion 3.5 medium pipeline.
Source code in embodied_gen/models/image_comm_model.py
50 51 | |
load
load()
Load the Stable Diffusion 3.5 medium pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
StableDiffusion3Pipeline |
Loaded pipeline. |
Source code in embodied_gen/models/image_comm_model.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
SD35Runner
SD35Runner(pipe)
Bases: BasePipelineRunner
Runner for Stable Diffusion 3.5 medium pipeline.
Source code in embodied_gen/models/image_comm_model.py
69 70 | |
run
run(prompt: str, **kwargs) -> Image.Image
Generate images using Stable Diffusion 3.5 medium.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Text prompt. |
required |
**kwargs
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Image
|
Image.Image: Generated image(s). |
Source code in embodied_gen/models/image_comm_model.py
110 111 112 113 114 115 116 117 118 119 120 | |
build_hf_image_pipeline
build_hf_image_pipeline(name: str, device='cuda') -> BasePipelineRunner
Build a Hugging Face image generation pipeline runner by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the pipeline (e.g., "sd35", "cosmos"). |
required |
device
|
str
|
Device to load the pipeline on. |
'cuda'
|
Returns:
| Name | Type | Description |
|---|---|---|
BasePipelineRunner |
BasePipelineRunner
|
Pipeline runner instance. |
Example
from embodied_gen.models.image_comm_model import build_hf_image_pipeline
runner = build_hf_image_pipeline("sd35")
images = runner.run(prompt="A robot holding a sign that says 'Hello'")
Source code in embodied_gen/models/image_comm_model.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
embodied_gen.models.delight_model
DelightingModel
DelightingModel(model_path: str = None, num_infer_step: int = 50, mask_erosion_size: int = 3, image_guide_scale: float = 1.5, text_guide_scale: float = 1.0, device: str = 'cuda', seed: int = 0)
Bases: object
A model to remove the lighting in image space.
This model is encapsulated based on the Hunyuan3D-Delight model
from https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-delight-v2-0 # noqa
Attributes:
| Name | Type | Description |
|---|---|---|
image_guide_scale |
float
|
Weight of image guidance in diffusion process. |
text_guide_scale |
float
|
Weight of text (prompt) guidance in diffusion process. |
num_infer_step |
int
|
Number of inference steps for diffusion model. |
mask_erosion_size |
int
|
Size of erosion kernel for alpha mask cleanup. |
device |
str
|
Device used for inference, e.g., 'cuda' or 'cpu'. |
seed |
int
|
Random seed for diffusion model reproducibility. |
model_path |
str
|
Filesystem path to pretrained model weights. |
pipeline |
Lazy-loaded diffusion pipeline instance. |
Source code in embodied_gen/models/delight_model.py
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 | |