Spaces:
Paused
Paused
mcp + cleanup
Browse files- .gitignore +2 -0
- app.py +56 -521
- example_images/000050281.jpg +0 -3
- example_images/000077066.jpg +0 -3
- example_images/000119733.jpg +0 -3
- example_images/000365954.jpg +0 -3
- example_images/000440817.jpg +0 -3
- example_images/00066-10350085.png +0 -3
- example_images/01.jpg +0 -3
- example_images/01194-20240127001056_1024x1536.png +0 -3
- example_images/02.jpg +0 -3
- example_images/04.jpg +0 -3
- example_images/1.png +0 -3
- example_images/1280X1280.png +0 -3
- example_images/1_20241127203215.png +0 -3
- example_images/1e5953ff5e029bfc81bb0a1d4792d26d.jpg +0 -3
- example_images/289089159-a6d7abc142419e63cab0a566eb38e0fb6acb217b340f054c6172139b316f6596.png +0 -3
- example_images/386724677-589d19050d4ea0603aee6831459aede29a24f4d8668c62c049f413db31508a54.png +0 -3
- example_images/468404374-d52ec1a44aa7e0dc9c2807ce09d303a111c78f34da3da2401b83ce10815ff872.png +0 -3
- example_images/46e79704-c88e-4e68-97b4-b4c40cd29826.png +0 -3
- example_images/6652baf6-4096-40ef-a475-425e4c072daf.png +0 -3
- example_images/8FtFUxRzXqaguVRGzkHvN.png +0 -3
- example_images/996e2cf6-daa5-48c4-9ad7-0719af640c17_1748848108409.png +0 -3
- example_images/ComfyUI_00254_.png +0 -3
- example_images/ComfyUI_temp_mllvz_00071_.png +0 -3
- example_images/RAL_0315.JPG +0 -3
- example_images/apple.png +0 -3
- example_images/byward-outfitters-B97YFrsITyo-unsplash.jpg +0 -3
- example_images/d8f8f44c64106e7715c61b5dfa9d9ca0974314c5d4a4a50418acf7ff373432bb.png +0 -3
- example_images/flux5.png +0 -3
- example_images/vicky-hladynets-C8Ta0gwPbQg-unsplash.jpg +0 -3
- omnigen2/__pycache__/__init__.cpython-310.pyc +0 -0
- omnigen2/__pycache__/__init__.cpython-38.pyc +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
**/__pycache__
|
| 2 |
+
**/.DS_Store
|
app.py
CHANGED
|
@@ -46,25 +46,59 @@ def load_pipeline(accelerator, weight_dtype, args):
|
|
| 46 |
|
| 47 |
@spaces.GPU(duration=180)
|
| 48 |
def run(
|
| 49 |
-
|
| 50 |
-
width_input,
|
| 51 |
-
height_input,
|
| 52 |
-
scheduler,
|
| 53 |
-
num_inference_steps,
|
| 54 |
-
image_input_1,
|
| 55 |
-
image_input_2,
|
| 56 |
-
image_input_3,
|
| 57 |
-
negative_prompt,
|
| 58 |
-
guidance_scale_input,
|
| 59 |
-
img_guidance_scale_input,
|
| 60 |
-
cfg_range_start,
|
| 61 |
-
cfg_range_end,
|
| 62 |
-
num_images_per_prompt,
|
| 63 |
-
max_input_image_side_length,
|
| 64 |
-
max_pixels,
|
| 65 |
-
seed_input,
|
| 66 |
progress=gr.Progress(),
|
| 67 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
input_images = [image_input_1, image_input_2, image_input_3]
|
| 69 |
input_images = [img for img in input_images if img is not None]
|
| 70 |
|
|
@@ -91,7 +125,7 @@ def run(
|
|
| 91 |
)
|
| 92 |
|
| 93 |
results = pipeline(
|
| 94 |
-
prompt=
|
| 95 |
input_images=input_images,
|
| 96 |
width=width_input,
|
| 97 |
height=height_input,
|
|
@@ -135,480 +169,6 @@ def run(
|
|
| 135 |
return output_image
|
| 136 |
|
| 137 |
|
| 138 |
-
def get_example():
|
| 139 |
-
case = [
|
| 140 |
-
[
|
| 141 |
-
"The sun rises slightly, the dew on the rose petals in the garden is clear, a crystal ladybug is crawling to the dew, the background is the early morning garden, macro lens.",
|
| 142 |
-
1024,
|
| 143 |
-
1024,
|
| 144 |
-
'euler',
|
| 145 |
-
50,
|
| 146 |
-
None,
|
| 147 |
-
None,
|
| 148 |
-
None,
|
| 149 |
-
NEGATIVE_PROMPT,
|
| 150 |
-
3.5,
|
| 151 |
-
1.0,
|
| 152 |
-
0.0,
|
| 153 |
-
1.0,
|
| 154 |
-
1,
|
| 155 |
-
2048,
|
| 156 |
-
1024 * 1024,
|
| 157 |
-
0,
|
| 158 |
-
],
|
| 159 |
-
[
|
| 160 |
-
"A snow maiden with pale translucent skin, frosty white lashes, and a soft expression of longing",
|
| 161 |
-
1024,
|
| 162 |
-
1024,
|
| 163 |
-
'euler',
|
| 164 |
-
50,
|
| 165 |
-
None,
|
| 166 |
-
None,
|
| 167 |
-
None,
|
| 168 |
-
NEGATIVE_PROMPT,
|
| 169 |
-
3.5,
|
| 170 |
-
1.0,
|
| 171 |
-
0.0,
|
| 172 |
-
1.0,
|
| 173 |
-
1,
|
| 174 |
-
2048,
|
| 175 |
-
1024 * 1024,
|
| 176 |
-
0,
|
| 177 |
-
],
|
| 178 |
-
[
|
| 179 |
-
"Add a fisherman hat to the woman's head",
|
| 180 |
-
1024,
|
| 181 |
-
1024,
|
| 182 |
-
'euler',
|
| 183 |
-
50,
|
| 184 |
-
os.path.join(ROOT_DIR, "example_images/flux5.png"),
|
| 185 |
-
None,
|
| 186 |
-
None,
|
| 187 |
-
NEGATIVE_PROMPT,
|
| 188 |
-
5.0,
|
| 189 |
-
2.0,
|
| 190 |
-
0.0,
|
| 191 |
-
1.0,
|
| 192 |
-
1,
|
| 193 |
-
2048,
|
| 194 |
-
1024 * 1024,
|
| 195 |
-
0,
|
| 196 |
-
],
|
| 197 |
-
[
|
| 198 |
-
" replace the sword with a hammer.",
|
| 199 |
-
1024,
|
| 200 |
-
1024,
|
| 201 |
-
'euler',
|
| 202 |
-
50,
|
| 203 |
-
os.path.join(
|
| 204 |
-
ROOT_DIR,
|
| 205 |
-
"example_images/d8f8f44c64106e7715c61b5dfa9d9ca0974314c5d4a4a50418acf7ff373432bb.png",
|
| 206 |
-
),
|
| 207 |
-
None,
|
| 208 |
-
None,
|
| 209 |
-
NEGATIVE_PROMPT,
|
| 210 |
-
5.0,
|
| 211 |
-
2.0,
|
| 212 |
-
0.0,
|
| 213 |
-
1.0,
|
| 214 |
-
1,
|
| 215 |
-
2048,
|
| 216 |
-
1024 * 1024,
|
| 217 |
-
0,
|
| 218 |
-
],
|
| 219 |
-
[
|
| 220 |
-
"Extract the character from the picture and fill the rest of the background with white.",
|
| 221 |
-
# "Transform the sculpture into jade",
|
| 222 |
-
1024,
|
| 223 |
-
1024,
|
| 224 |
-
'euler',
|
| 225 |
-
50,
|
| 226 |
-
os.path.join(
|
| 227 |
-
ROOT_DIR, "example_images/46e79704-c88e-4e68-97b4-b4c40cd29826.png"
|
| 228 |
-
),
|
| 229 |
-
None,
|
| 230 |
-
None,
|
| 231 |
-
NEGATIVE_PROMPT,
|
| 232 |
-
5.0,
|
| 233 |
-
2.0,
|
| 234 |
-
0.0,
|
| 235 |
-
1.0,
|
| 236 |
-
1,
|
| 237 |
-
2048,
|
| 238 |
-
1024 * 1024,
|
| 239 |
-
0,
|
| 240 |
-
],
|
| 241 |
-
[
|
| 242 |
-
"Make he smile",
|
| 243 |
-
1024,
|
| 244 |
-
1024,
|
| 245 |
-
'euler',
|
| 246 |
-
50,
|
| 247 |
-
os.path.join(
|
| 248 |
-
ROOT_DIR, "example_images/vicky-hladynets-C8Ta0gwPbQg-unsplash.jpg"
|
| 249 |
-
),
|
| 250 |
-
None,
|
| 251 |
-
None,
|
| 252 |
-
NEGATIVE_PROMPT,
|
| 253 |
-
5.0,
|
| 254 |
-
2.0,
|
| 255 |
-
0.0,
|
| 256 |
-
1.0,
|
| 257 |
-
1,
|
| 258 |
-
2048,
|
| 259 |
-
1024 * 1024,
|
| 260 |
-
0,
|
| 261 |
-
],
|
| 262 |
-
[
|
| 263 |
-
"Change the background to classroom",
|
| 264 |
-
1024,
|
| 265 |
-
1024,
|
| 266 |
-
'euler',
|
| 267 |
-
50,
|
| 268 |
-
os.path.join(ROOT_DIR, "example_images/ComfyUI_temp_mllvz_00071_.png"),
|
| 269 |
-
None,
|
| 270 |
-
None,
|
| 271 |
-
NEGATIVE_PROMPT,
|
| 272 |
-
5.0,
|
| 273 |
-
2.0,
|
| 274 |
-
0.0,
|
| 275 |
-
1.0,
|
| 276 |
-
1,
|
| 277 |
-
2048,
|
| 278 |
-
1024 * 1024,
|
| 279 |
-
0,
|
| 280 |
-
],
|
| 281 |
-
[
|
| 282 |
-
"Raise his hand",
|
| 283 |
-
1024,
|
| 284 |
-
1024,
|
| 285 |
-
'euler',
|
| 286 |
-
50,
|
| 287 |
-
os.path.join(
|
| 288 |
-
ROOT_DIR,
|
| 289 |
-
"example_images/289089159-a6d7abc142419e63cab0a566eb38e0fb6acb217b340f054c6172139b316f6596.png",
|
| 290 |
-
),
|
| 291 |
-
None,
|
| 292 |
-
None,
|
| 293 |
-
NEGATIVE_PROMPT,
|
| 294 |
-
5.0,
|
| 295 |
-
2.0,
|
| 296 |
-
0.0,
|
| 297 |
-
1.0,
|
| 298 |
-
1,
|
| 299 |
-
2048,
|
| 300 |
-
1024 * 1024,
|
| 301 |
-
0,
|
| 302 |
-
],
|
| 303 |
-
[
|
| 304 |
-
"Generate a photo of an anime-style figurine placed on a desk. The figurine model should be based on the character photo provided in the attachment, accurately replicating the full-body pose, facial expression, and clothing style of the character in the photo, ensuring the entire figurine is fully presented. The overall design should be exquisite and detailed, soft gradient colors and a delicate texture, leaning towards a Japanese anime style, rich in details, with a realistic quality and beautiful visual appeal.",
|
| 305 |
-
1024,
|
| 306 |
-
1024,
|
| 307 |
-
'euler',
|
| 308 |
-
50,
|
| 309 |
-
os.path.join(ROOT_DIR, "example_images/RAL_0315.JPG"),
|
| 310 |
-
None,
|
| 311 |
-
None,
|
| 312 |
-
NEGATIVE_PROMPT,
|
| 313 |
-
5.0,
|
| 314 |
-
2.0,
|
| 315 |
-
0.0,
|
| 316 |
-
1.0,
|
| 317 |
-
1,
|
| 318 |
-
2048,
|
| 319 |
-
1024 * 1024,
|
| 320 |
-
0,
|
| 321 |
-
],
|
| 322 |
-
[
|
| 323 |
-
"Change the dress to blue.",
|
| 324 |
-
1024,
|
| 325 |
-
1024,
|
| 326 |
-
'euler',
|
| 327 |
-
50,
|
| 328 |
-
os.path.join(ROOT_DIR, "example_images/1.png"),
|
| 329 |
-
None,
|
| 330 |
-
None,
|
| 331 |
-
NEGATIVE_PROMPT,
|
| 332 |
-
5.0,
|
| 333 |
-
2.0,
|
| 334 |
-
0.0,
|
| 335 |
-
1.0,
|
| 336 |
-
1,
|
| 337 |
-
2048,
|
| 338 |
-
1024 * 1024,
|
| 339 |
-
0,
|
| 340 |
-
],
|
| 341 |
-
[
|
| 342 |
-
"Remove the cat",
|
| 343 |
-
1024,
|
| 344 |
-
1024,
|
| 345 |
-
'euler',
|
| 346 |
-
50,
|
| 347 |
-
os.path.join(
|
| 348 |
-
ROOT_DIR,
|
| 349 |
-
"example_images/386724677-589d19050d4ea0603aee6831459aede29a24f4d8668c62c049f413db31508a54.png",
|
| 350 |
-
),
|
| 351 |
-
None,
|
| 352 |
-
None,
|
| 353 |
-
NEGATIVE_PROMPT,
|
| 354 |
-
5.0,
|
| 355 |
-
2.0,
|
| 356 |
-
0.0,
|
| 357 |
-
1.0,
|
| 358 |
-
1,
|
| 359 |
-
2048,
|
| 360 |
-
1024 * 1024,
|
| 361 |
-
0,
|
| 362 |
-
],
|
| 363 |
-
[
|
| 364 |
-
"In a cozy café, the anime figure is sitting in front of a laptop, smiling confidently.",
|
| 365 |
-
1024,
|
| 366 |
-
1024,
|
| 367 |
-
'euler',
|
| 368 |
-
50,
|
| 369 |
-
os.path.join(ROOT_DIR, "example_images/ComfyUI_00254_.png"),
|
| 370 |
-
None,
|
| 371 |
-
None,
|
| 372 |
-
NEGATIVE_PROMPT,
|
| 373 |
-
5.0,
|
| 374 |
-
2.0,
|
| 375 |
-
0.0,
|
| 376 |
-
1.0,
|
| 377 |
-
1,
|
| 378 |
-
2048,
|
| 379 |
-
1024 * 1024,
|
| 380 |
-
0,
|
| 381 |
-
],
|
| 382 |
-
[
|
| 383 |
-
"Create a wedding figure based on the girl in the first image and the man in the second image. Set the background as a wedding hall, with the man dressed in a suit and the girl in a white wedding dress. Ensure that the original faces remain unchanged and are accurately preserved. The man should adopt a realistic style, whereas the girl should maintain their classic anime style.",
|
| 384 |
-
1024,
|
| 385 |
-
1024,
|
| 386 |
-
'euler',
|
| 387 |
-
50,
|
| 388 |
-
os.path.join(ROOT_DIR, "example_images/1_20241127203215.png"),
|
| 389 |
-
os.path.join(ROOT_DIR, "example_images/000050281.jpg"),
|
| 390 |
-
None,
|
| 391 |
-
NEGATIVE_PROMPT,
|
| 392 |
-
5.0,
|
| 393 |
-
3.0,
|
| 394 |
-
0.0,
|
| 395 |
-
1.0,
|
| 396 |
-
1,
|
| 397 |
-
2048,
|
| 398 |
-
1024 * 1024,
|
| 399 |
-
0,
|
| 400 |
-
],
|
| 401 |
-
[
|
| 402 |
-
"Let the girl and the boy get married in the church. ",
|
| 403 |
-
1024,
|
| 404 |
-
1024,
|
| 405 |
-
'euler',
|
| 406 |
-
50,
|
| 407 |
-
os.path.join(ROOT_DIR, "example_images/8FtFUxRzXqaguVRGzkHvN.png"),
|
| 408 |
-
os.path.join(ROOT_DIR, "example_images/01194-20240127001056_1024x1536.png"),
|
| 409 |
-
None,
|
| 410 |
-
NEGATIVE_PROMPT,
|
| 411 |
-
5.0,
|
| 412 |
-
3.0,
|
| 413 |
-
0.0,
|
| 414 |
-
1.0,
|
| 415 |
-
1,
|
| 416 |
-
2048,
|
| 417 |
-
1024 * 1024,
|
| 418 |
-
0,
|
| 419 |
-
],
|
| 420 |
-
[
|
| 421 |
-
"Let the man from image1 and the woman from image2 kiss and hug",
|
| 422 |
-
1024,
|
| 423 |
-
1024,
|
| 424 |
-
'euler',
|
| 425 |
-
50,
|
| 426 |
-
os.path.join(ROOT_DIR, "example_images/1280X1280.png"),
|
| 427 |
-
os.path.join(ROOT_DIR, "example_images/000077066.jpg"),
|
| 428 |
-
None,
|
| 429 |
-
NEGATIVE_PROMPT,
|
| 430 |
-
5.0,
|
| 431 |
-
2.0,
|
| 432 |
-
0.0,
|
| 433 |
-
1.0,
|
| 434 |
-
1,
|
| 435 |
-
2048,
|
| 436 |
-
1024 * 1024,
|
| 437 |
-
0,
|
| 438 |
-
],
|
| 439 |
-
[
|
| 440 |
-
"Please let the person in image 2 hold the toy from the first image in a parking lot.",
|
| 441 |
-
1024,
|
| 442 |
-
1024,
|
| 443 |
-
'euler',
|
| 444 |
-
50,
|
| 445 |
-
os.path.join(ROOT_DIR, "example_images/04.jpg"),
|
| 446 |
-
os.path.join(ROOT_DIR, "example_images/000365954.jpg"),
|
| 447 |
-
None,
|
| 448 |
-
NEGATIVE_PROMPT,
|
| 449 |
-
5.0,
|
| 450 |
-
2.0,
|
| 451 |
-
0.0,
|
| 452 |
-
1.0,
|
| 453 |
-
1,
|
| 454 |
-
2048,
|
| 455 |
-
1024 * 1024,
|
| 456 |
-
0,
|
| 457 |
-
],
|
| 458 |
-
[
|
| 459 |
-
"Make the girl pray in the second image.",
|
| 460 |
-
1024,
|
| 461 |
-
682,
|
| 462 |
-
'euler',
|
| 463 |
-
50,
|
| 464 |
-
os.path.join(ROOT_DIR, "example_images/000440817.jpg"),
|
| 465 |
-
os.path.join(ROOT_DIR, "example_images/000119733.jpg"),
|
| 466 |
-
None,
|
| 467 |
-
NEGATIVE_PROMPT,
|
| 468 |
-
5.0,
|
| 469 |
-
2.0,
|
| 470 |
-
0.0,
|
| 471 |
-
1.0,
|
| 472 |
-
1,
|
| 473 |
-
2048,
|
| 474 |
-
1024 * 1024,
|
| 475 |
-
0,
|
| 476 |
-
],
|
| 477 |
-
[
|
| 478 |
-
"Add the bird from image 1 to the desk in image 2",
|
| 479 |
-
1024,
|
| 480 |
-
682,
|
| 481 |
-
'euler',
|
| 482 |
-
50,
|
| 483 |
-
os.path.join(
|
| 484 |
-
ROOT_DIR,
|
| 485 |
-
"example_images/996e2cf6-daa5-48c4-9ad7-0719af640c17_1748848108409.png",
|
| 486 |
-
),
|
| 487 |
-
os.path.join(ROOT_DIR, "example_images/00066-10350085.png"),
|
| 488 |
-
None,
|
| 489 |
-
NEGATIVE_PROMPT,
|
| 490 |
-
5.0,
|
| 491 |
-
2.0,
|
| 492 |
-
0.0,
|
| 493 |
-
1.0,
|
| 494 |
-
1,
|
| 495 |
-
2048,
|
| 496 |
-
1024 * 1024,
|
| 497 |
-
0,
|
| 498 |
-
],
|
| 499 |
-
[
|
| 500 |
-
"Replace the apple in the first image with the cat from the second image",
|
| 501 |
-
1024,
|
| 502 |
-
780,
|
| 503 |
-
'euler',
|
| 504 |
-
50,
|
| 505 |
-
os.path.join(ROOT_DIR, "example_images/apple.png"),
|
| 506 |
-
os.path.join(
|
| 507 |
-
ROOT_DIR,
|
| 508 |
-
"example_images/468404374-d52ec1a44aa7e0dc9c2807ce09d303a111c78f34da3da2401b83ce10815ff872.png",
|
| 509 |
-
),
|
| 510 |
-
None,
|
| 511 |
-
NEGATIVE_PROMPT,
|
| 512 |
-
5.0,
|
| 513 |
-
2.0,
|
| 514 |
-
0.0,
|
| 515 |
-
1.0,
|
| 516 |
-
1,
|
| 517 |
-
2048,
|
| 518 |
-
1024 * 1024,
|
| 519 |
-
0,
|
| 520 |
-
],
|
| 521 |
-
[
|
| 522 |
-
"Replace the woman in the second image with the woman from the first image",
|
| 523 |
-
1024,
|
| 524 |
-
747,
|
| 525 |
-
'euler',
|
| 526 |
-
50,
|
| 527 |
-
os.path.join(
|
| 528 |
-
ROOT_DIR, "example_images/byward-outfitters-B97YFrsITyo-unsplash.jpg"
|
| 529 |
-
),
|
| 530 |
-
os.path.join(
|
| 531 |
-
ROOT_DIR, "example_images/6652baf6-4096-40ef-a475-425e4c072daf.png"
|
| 532 |
-
),
|
| 533 |
-
None,
|
| 534 |
-
NEGATIVE_PROMPT,
|
| 535 |
-
5.0,
|
| 536 |
-
2.0,
|
| 537 |
-
0.0,
|
| 538 |
-
1.0,
|
| 539 |
-
1,
|
| 540 |
-
2048,
|
| 541 |
-
1024 * 1024,
|
| 542 |
-
0,
|
| 543 |
-
],
|
| 544 |
-
[
|
| 545 |
-
"The cat is sitting on the table. The bird is perching on the edge of the table.",
|
| 546 |
-
800,
|
| 547 |
-
512,
|
| 548 |
-
"euler",
|
| 549 |
-
50,
|
| 550 |
-
os.path.join(
|
| 551 |
-
ROOT_DIR,
|
| 552 |
-
"example_images/996e2cf6-daa5-48c4-9ad7-0719af640c17_1748848108409.png",
|
| 553 |
-
),
|
| 554 |
-
os.path.join(
|
| 555 |
-
ROOT_DIR,
|
| 556 |
-
"example_images/468404374-d52ec1a44aa7e0dc9c2807ce09d303a111c78f34da3da2401b83ce10815ff872.png",
|
| 557 |
-
),
|
| 558 |
-
os.path.join(ROOT_DIR, "example_images/00066-10350085.png"),
|
| 559 |
-
NEGATIVE_PROMPT,
|
| 560 |
-
5.0,
|
| 561 |
-
2.0,
|
| 562 |
-
0.0,
|
| 563 |
-
1.0,
|
| 564 |
-
1,
|
| 565 |
-
2048,
|
| 566 |
-
1024 * 1024,
|
| 567 |
-
0,
|
| 568 |
-
],
|
| 569 |
-
]
|
| 570 |
-
return case
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
def run_for_examples(
|
| 574 |
-
instruction,
|
| 575 |
-
width_input,
|
| 576 |
-
height_input,
|
| 577 |
-
scheduler,
|
| 578 |
-
num_inference_steps,
|
| 579 |
-
image_input_1,
|
| 580 |
-
image_input_2,
|
| 581 |
-
image_input_3,
|
| 582 |
-
negative_prompt,
|
| 583 |
-
text_guidance_scale_input,
|
| 584 |
-
image_guidance_scale_input,
|
| 585 |
-
cfg_range_start,
|
| 586 |
-
cfg_range_end,
|
| 587 |
-
num_images_per_prompt,
|
| 588 |
-
max_input_image_side_length,
|
| 589 |
-
max_pixels,
|
| 590 |
-
seed_input,
|
| 591 |
-
):
|
| 592 |
-
return run(
|
| 593 |
-
instruction,
|
| 594 |
-
width_input,
|
| 595 |
-
height_input,
|
| 596 |
-
scheduler,
|
| 597 |
-
num_inference_steps,
|
| 598 |
-
image_input_1,
|
| 599 |
-
image_input_2,
|
| 600 |
-
image_input_3,
|
| 601 |
-
negative_prompt,
|
| 602 |
-
text_guidance_scale_input,
|
| 603 |
-
image_guidance_scale_input,
|
| 604 |
-
cfg_range_start,
|
| 605 |
-
cfg_range_end,
|
| 606 |
-
num_images_per_prompt,
|
| 607 |
-
max_input_image_side_length,
|
| 608 |
-
max_pixels,
|
| 609 |
-
seed_input,
|
| 610 |
-
)
|
| 611 |
-
|
| 612 |
description = """
|
| 613 |
### 💡 Quick Tips for Best Results (see our [github](https://github.com/VectorSpaceLab/OmniGen2?tab=readme-ov-file#-usage-tips) for more details)
|
| 614 |
- Image Quality: Use high-resolution images (at least 512x512 recommended).
|
|
@@ -640,8 +200,8 @@ def main(args):
|
|
| 640 |
with gr.Row():
|
| 641 |
with gr.Column():
|
| 642 |
# text prompt
|
| 643 |
-
|
| 644 |
-
label='Enter your prompt. Use "first/second image"
|
| 645 |
placeholder="Type your prompt here...",
|
| 646 |
)
|
| 647 |
|
|
@@ -777,32 +337,7 @@ def main(args):
|
|
| 777 |
generate_button.click(
|
| 778 |
run,
|
| 779 |
inputs=[
|
| 780 |
-
|
| 781 |
-
width_input,
|
| 782 |
-
height_input,
|
| 783 |
-
scheduler_input,
|
| 784 |
-
num_inference_steps,
|
| 785 |
-
image_input_1,
|
| 786 |
-
image_input_2,
|
| 787 |
-
image_input_3,
|
| 788 |
-
negative_prompt,
|
| 789 |
-
text_guidance_scale_input,
|
| 790 |
-
image_guidance_scale_input,
|
| 791 |
-
cfg_range_start,
|
| 792 |
-
cfg_range_end,
|
| 793 |
-
num_images_per_prompt,
|
| 794 |
-
max_input_image_side_length,
|
| 795 |
-
max_pixels,
|
| 796 |
-
seed_input,
|
| 797 |
-
],
|
| 798 |
-
outputs=output_image,
|
| 799 |
-
)
|
| 800 |
-
|
| 801 |
-
gr.Examples(
|
| 802 |
-
examples=get_example(),
|
| 803 |
-
fn=run_for_examples,
|
| 804 |
-
inputs=[
|
| 805 |
-
instruction,
|
| 806 |
width_input,
|
| 807 |
height_input,
|
| 808 |
scheduler_input,
|
|
@@ -825,7 +360,7 @@ def main(args):
|
|
| 825 |
|
| 826 |
gr.Markdown(article)
|
| 827 |
# launch
|
| 828 |
-
demo.launch(share=args.share, server_port=args.port, allowed_paths=[ROOT_DIR])
|
| 829 |
|
| 830 |
def parse_args():
|
| 831 |
parser = argparse.ArgumentParser(description="Run the OmniGen2")
|
|
|
|
| 46 |
|
| 47 |
@spaces.GPU(duration=180)
|
| 48 |
def run(
|
| 49 |
+
prompt,
|
| 50 |
+
width_input=1024,
|
| 51 |
+
height_input=1024,
|
| 52 |
+
scheduler='euler',
|
| 53 |
+
num_inference_steps=50,
|
| 54 |
+
image_input_1=None,
|
| 55 |
+
image_input_2=None,
|
| 56 |
+
image_input_3=None,
|
| 57 |
+
negative_prompt=NEGATIVE_PROMPT,
|
| 58 |
+
guidance_scale_input=5.0,
|
| 59 |
+
img_guidance_scale_input=2.0,
|
| 60 |
+
cfg_range_start=0.0,
|
| 61 |
+
cfg_range_end=1.0,
|
| 62 |
+
num_images_per_prompt=1,
|
| 63 |
+
max_input_image_side_length=2048,
|
| 64 |
+
max_pixels=1024 * 1024,
|
| 65 |
+
seed_input=-1,
|
| 66 |
progress=gr.Progress(),
|
| 67 |
):
|
| 68 |
+
"""
|
| 69 |
+
Generate and/or edit images based on text prompts and optional input images using the OmniGen2 pipeline.
|
| 70 |
+
|
| 71 |
+
Quick Tips for Best Results:
|
| 72 |
+
- Generate high-resolution images (at least 512x512 recommended).
|
| 73 |
+
- Be Specific: Instead of "Add bird to desk", try "Add the bird from image 1 to the desk in image 2".
|
| 74 |
+
- Use English: English prompts currently yield better results.
|
| 75 |
+
- Adjust image_guidance_scale for better consistency with the reference image:
|
| 76 |
+
- Image Editing: 1.3 - 2.0
|
| 77 |
+
- In-context Generation: 2.0 - 3.0
|
| 78 |
+
|
| 79 |
+
Args:
|
| 80 |
+
prompt: Text prompt describing the desired image generation or editing task.
|
| 81 |
+
width_input: Width of the output image in pixels (default: 1024).
|
| 82 |
+
height_input: Height of the output image in pixels (default: 1024).
|
| 83 |
+
scheduler: Scheduler type to use ('euler' or 'dpmsolver') (default: 'euler').
|
| 84 |
+
num_inference_steps: Number of denoising steps (default: 50).
|
| 85 |
+
image_input_1: Optional first input image for editing/reference (default: None).
|
| 86 |
+
image_input_2: Optional second input image for editing/reference (default: None).
|
| 87 |
+
image_input_3: Optional third input image for editing/reference (default: None).
|
| 88 |
+
negative_prompt: Text describing what to avoid in the generation (default: NEGATIVE_PROMPT).
|
| 89 |
+
guidance_scale_input: Text guidance scale for controlling prompt adherence (default: 5.0).
|
| 90 |
+
img_guidance_scale_input: Image guidance scale for controlling input image adherence (default: 2.0).
|
| 91 |
+
cfg_range_start: Start of the classifier-free guidance range (0.0-1.0) (default: 0.0).
|
| 92 |
+
cfg_range_end: End of the classifier-free guidance range (0.0-1.0) (default: 1.0).
|
| 93 |
+
num_images_per_prompt: Number of images to generate per prompt (default: 1).
|
| 94 |
+
max_input_image_side_length: Maximum side length for input images (default: 2048).
|
| 95 |
+
max_pixels: Maximum total pixels for input images (default: 1048576).
|
| 96 |
+
seed_input: Random seed for reproducible generation (-1 for random) (default: -1).
|
| 97 |
+
progress: Gradio progress tracker. (Can be None when not ran on Gradio)
|
| 98 |
+
|
| 99 |
+
Returns:
|
| 100 |
+
PIL.Image: Generated image or collage of multiple generated images.
|
| 101 |
+
"""
|
| 102 |
input_images = [image_input_1, image_input_2, image_input_3]
|
| 103 |
input_images = [img for img in input_images if img is not None]
|
| 104 |
|
|
|
|
| 125 |
)
|
| 126 |
|
| 127 |
results = pipeline(
|
| 128 |
+
prompt=prompt,
|
| 129 |
input_images=input_images,
|
| 130 |
width=width_input,
|
| 131 |
height=height_input,
|
|
|
|
| 169 |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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
description = """
|
| 173 |
### 💡 Quick Tips for Best Results (see our [github](https://github.com/VectorSpaceLab/OmniGen2?tab=readme-ov-file#-usage-tips) for more details)
|
| 174 |
- Image Quality: Use high-resolution images (at least 512x512 recommended).
|
|
|
|
| 200 |
with gr.Row():
|
| 201 |
with gr.Column():
|
| 202 |
# text prompt
|
| 203 |
+
prompt = gr.Textbox(
|
| 204 |
+
label='Enter your prompt. Use "first/second image" as reference.',
|
| 205 |
placeholder="Type your prompt here...",
|
| 206 |
)
|
| 207 |
|
|
|
|
| 337 |
generate_button.click(
|
| 338 |
run,
|
| 339 |
inputs=[
|
| 340 |
+
prompt,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
width_input,
|
| 342 |
height_input,
|
| 343 |
scheduler_input,
|
|
|
|
| 360 |
|
| 361 |
gr.Markdown(article)
|
| 362 |
# launch
|
| 363 |
+
demo.launch(share=args.share, server_port=args.port, allowed_paths=[ROOT_DIR], mcp_server=True)
|
| 364 |
|
| 365 |
def parse_args():
|
| 366 |
parser = argparse.ArgumentParser(description="Run the OmniGen2")
|
example_images/000050281.jpg
DELETED
Git LFS Details
|
example_images/000077066.jpg
DELETED
Git LFS Details
|
example_images/000119733.jpg
DELETED
Git LFS Details
|
example_images/000365954.jpg
DELETED
Git LFS Details
|
example_images/000440817.jpg
DELETED
Git LFS Details
|
example_images/00066-10350085.png
DELETED
Git LFS Details
|
example_images/01.jpg
DELETED
Git LFS Details
|
example_images/01194-20240127001056_1024x1536.png
DELETED
Git LFS Details
|
example_images/02.jpg
DELETED
Git LFS Details
|
example_images/04.jpg
DELETED
Git LFS Details
|
example_images/1.png
DELETED
Git LFS Details
|
example_images/1280X1280.png
DELETED
Git LFS Details
|
example_images/1_20241127203215.png
DELETED
Git LFS Details
|
example_images/1e5953ff5e029bfc81bb0a1d4792d26d.jpg
DELETED
Git LFS Details
|
example_images/289089159-a6d7abc142419e63cab0a566eb38e0fb6acb217b340f054c6172139b316f6596.png
DELETED
Git LFS Details
|
example_images/386724677-589d19050d4ea0603aee6831459aede29a24f4d8668c62c049f413db31508a54.png
DELETED
Git LFS Details
|
example_images/468404374-d52ec1a44aa7e0dc9c2807ce09d303a111c78f34da3da2401b83ce10815ff872.png
DELETED
Git LFS Details
|
example_images/46e79704-c88e-4e68-97b4-b4c40cd29826.png
DELETED
Git LFS Details
|
example_images/6652baf6-4096-40ef-a475-425e4c072daf.png
DELETED
Git LFS Details
|
example_images/8FtFUxRzXqaguVRGzkHvN.png
DELETED
Git LFS Details
|
example_images/996e2cf6-daa5-48c4-9ad7-0719af640c17_1748848108409.png
DELETED
Git LFS Details
|
example_images/ComfyUI_00254_.png
DELETED
Git LFS Details
|
example_images/ComfyUI_temp_mllvz_00071_.png
DELETED
Git LFS Details
|
example_images/RAL_0315.JPG
DELETED
Git LFS Details
|
example_images/apple.png
DELETED
Git LFS Details
|
example_images/byward-outfitters-B97YFrsITyo-unsplash.jpg
DELETED
Git LFS Details
|
example_images/d8f8f44c64106e7715c61b5dfa9d9ca0974314c5d4a4a50418acf7ff373432bb.png
DELETED
Git LFS Details
|
example_images/flux5.png
DELETED
Git LFS Details
|
example_images/vicky-hladynets-C8Ta0gwPbQg-unsplash.jpg
DELETED
Git LFS Details
|
omnigen2/__pycache__/__init__.cpython-310.pyc
DELETED
|
Binary file (160 Bytes)
|
|
|
omnigen2/__pycache__/__init__.cpython-38.pyc
DELETED
|
Binary file (139 Bytes)
|
|
|