Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -27,8 +27,11 @@ pipe = JoyImageEditPlusPipeline.from_pretrained(
|
|
| 27 |
pipe.enable_model_cpu_offload()
|
| 28 |
|
| 29 |
|
| 30 |
-
def _estimate_duration(images, prompt, num_inference_steps, guidance_scale, seed, negative_prompt,
|
| 31 |
-
"""Estimate the GPU duration needed based on step count and image count.
|
|
|
|
|
|
|
|
|
|
| 32 |
n_imgs = len(images) if images else 0
|
| 33 |
# ~1s per step for 16B transformer + 8B text encoder + VAE, plus overhead
|
| 34 |
return min(300, 60 + int(num_inference_steps * 3.5) + n_imgs * 10)
|
|
@@ -67,8 +70,11 @@ def generate(
|
|
| 67 |
if isinstance(images, list):
|
| 68 |
pil_images = []
|
| 69 |
for img in images:
|
| 70 |
-
if isinstance(img, dict)
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
elif isinstance(img, str):
|
| 73 |
pil_images.append(Image.open(img).convert("RGB"))
|
| 74 |
elif isinstance(img, Image.Image):
|
|
|
|
| 27 |
pipe.enable_model_cpu_offload()
|
| 28 |
|
| 29 |
|
| 30 |
+
def _estimate_duration(images, prompt, num_inference_steps, guidance_scale, seed, negative_prompt, randomize_seed, *args, **kwargs):
|
| 31 |
+
"""Estimate the GPU duration needed based on step count and image count.
|
| 32 |
+
|
| 33 |
+
Accepts *args/**kwargs because Gradio passes progress= positionally.
|
| 34 |
+
"""
|
| 35 |
n_imgs = len(images) if images else 0
|
| 36 |
# ~1s per step for 16B transformer + 8B text encoder + VAE, plus overhead
|
| 37 |
return min(300, 60 + int(num_inference_steps * 3.5) + n_imgs * 10)
|
|
|
|
| 70 |
if isinstance(images, list):
|
| 71 |
pil_images = []
|
| 72 |
for img in images:
|
| 73 |
+
if isinstance(img, dict):
|
| 74 |
+
# Gallery passes {'image': filepath, 'caption': ...} or {'path': ...}
|
| 75 |
+
path = img.get("image") or img.get("path")
|
| 76 |
+
if path:
|
| 77 |
+
pil_images.append(Image.open(path).convert("RGB"))
|
| 78 |
elif isinstance(img, str):
|
| 79 |
pil_images.append(Image.open(img).convert("RGB"))
|
| 80 |
elif isinstance(img, Image.Image):
|