Spaces:
Runtime error
Runtime error
debug
Browse files
app.py
CHANGED
|
@@ -94,6 +94,7 @@ def process(
|
|
| 94 |
image = image.resize((width, height), Image.LANCZOS)
|
| 95 |
|
| 96 |
if segmentation_prompt_text:
|
|
|
|
| 97 |
_, result = run_florence_inference(
|
| 98 |
model=FLORENCE_MODEL,
|
| 99 |
processor=FLORENCE_PROCESSOR,
|
|
@@ -107,7 +108,10 @@ def process(
|
|
| 107 |
result=result,
|
| 108 |
resolution_wh=image.size
|
| 109 |
)
|
|
|
|
|
|
|
| 110 |
detections = run_sam_inference(SAM_IMAGE_MODEL, image, detections)
|
|
|
|
| 111 |
|
| 112 |
if len(detections) == 0:
|
| 113 |
gr.Info(f"{segmentation_prompt_text} prompt did not return any detections.")
|
|
@@ -118,21 +122,23 @@ def process(
|
|
| 118 |
mask = mask.resize((width, height), Image.LANCZOS)
|
| 119 |
mask = mask.filter(ImageFilter.GaussianBlur(radius=10))
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
| 136 |
|
| 137 |
|
| 138 |
with gr.Blocks() as demo:
|
|
|
|
| 94 |
image = image.resize((width, height), Image.LANCZOS)
|
| 95 |
|
| 96 |
if segmentation_prompt_text:
|
| 97 |
+
print('FLORENCE INFERENCE STARTED')
|
| 98 |
_, result = run_florence_inference(
|
| 99 |
model=FLORENCE_MODEL,
|
| 100 |
processor=FLORENCE_PROCESSOR,
|
|
|
|
| 108 |
result=result,
|
| 109 |
resolution_wh=image.size
|
| 110 |
)
|
| 111 |
+
print('FLORENCE INFERENCE DONE')
|
| 112 |
+
print('SAM INFERENCE STARTED')
|
| 113 |
detections = run_sam_inference(SAM_IMAGE_MODEL, image, detections)
|
| 114 |
+
print('SAM INFERENCE DONE')
|
| 115 |
|
| 116 |
if len(detections) == 0:
|
| 117 |
gr.Info(f"{segmentation_prompt_text} prompt did not return any detections.")
|
|
|
|
| 122 |
mask = mask.resize((width, height), Image.LANCZOS)
|
| 123 |
mask = mask.filter(ImageFilter.GaussianBlur(radius=10))
|
| 124 |
|
| 125 |
+
return image, mask
|
| 126 |
+
|
| 127 |
+
# if randomize_seed_checkbox:
|
| 128 |
+
# seed_slicer = random.randint(0, MAX_SEED)
|
| 129 |
+
# generator = torch.Generator().manual_seed(seed_slicer)
|
| 130 |
+
# result = FLUX_INPAINTING_PIPELINE(
|
| 131 |
+
# prompt=inpainting_prompt_text,
|
| 132 |
+
# image=image,
|
| 133 |
+
# mask_image=mask,
|
| 134 |
+
# width=width,
|
| 135 |
+
# height=height,
|
| 136 |
+
# strength=strength_slider,
|
| 137 |
+
# generator=generator,
|
| 138 |
+
# num_inference_steps=num_inference_steps_slider
|
| 139 |
+
# ).images[0]
|
| 140 |
+
# print('INFERENCE DONE')
|
| 141 |
+
# return result, mask
|
| 142 |
|
| 143 |
|
| 144 |
with gr.Blocks() as demo:
|