Spaces:
Runtime error
Runtime error
Revert "debug"
Browse filesThis reverts commit 4a619ecd2546955bf118982e8977ab2cd418288a.
app.py
CHANGED
@@ -33,8 +33,8 @@ if torch.cuda.get_device_properties(0).major >= 8:
|
|
33 |
|
34 |
FLORENCE_MODEL, FLORENCE_PROCESSOR = load_florence_model(device=DEVICE)
|
35 |
SAM_IMAGE_MODEL = load_sam_image_model(device=DEVICE)
|
36 |
-
|
37 |
-
|
38 |
|
39 |
|
40 |
def resize_image_dimensions(
|
@@ -63,7 +63,7 @@ def is_image_empty(image: Image.Image) -> bool:
|
|
63 |
return all(pixel == 0 for pixel in pixels)
|
64 |
|
65 |
|
66 |
-
@spaces.GPU()
|
67 |
@torch.inference_mode()
|
68 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
69 |
def process(
|
@@ -128,23 +128,23 @@ def process(
|
|
128 |
mask = mask.resize((width, height), Image.LANCZOS)
|
129 |
mask = mask.filter(ImageFilter.GaussianBlur(radius=10))
|
130 |
|
131 |
-
return image, mask
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
|
149 |
|
150 |
with gr.Blocks() as demo:
|
|
|
33 |
|
34 |
FLORENCE_MODEL, FLORENCE_PROCESSOR = load_florence_model(device=DEVICE)
|
35 |
SAM_IMAGE_MODEL = load_sam_image_model(device=DEVICE)
|
36 |
+
FLUX_INPAINTING_PIPELINE = FluxInpaintPipeline.from_pretrained(
|
37 |
+
"black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
|
38 |
|
39 |
|
40 |
def resize_image_dimensions(
|
|
|
63 |
return all(pixel == 0 for pixel in pixels)
|
64 |
|
65 |
|
66 |
+
@spaces.GPU(duration=150)
|
67 |
@torch.inference_mode()
|
68 |
@torch.autocast(device_type="cuda", dtype=torch.bfloat16)
|
69 |
def process(
|
|
|
128 |
mask = mask.resize((width, height), Image.LANCZOS)
|
129 |
mask = mask.filter(ImageFilter.GaussianBlur(radius=10))
|
130 |
|
131 |
+
# return image, mask
|
132 |
+
|
133 |
+
if randomize_seed_checkbox:
|
134 |
+
seed_slicer = random.randint(0, MAX_SEED)
|
135 |
+
generator = torch.Generator().manual_seed(seed_slicer)
|
136 |
+
result = FLUX_INPAINTING_PIPELINE(
|
137 |
+
prompt=inpainting_prompt_text,
|
138 |
+
image=image,
|
139 |
+
mask_image=mask,
|
140 |
+
width=width,
|
141 |
+
height=height,
|
142 |
+
strength=strength_slider,
|
143 |
+
generator=generator,
|
144 |
+
num_inference_steps=num_inference_steps_slider
|
145 |
+
).images[0]
|
146 |
+
print('INFERENCE DONE')
|
147 |
+
return result, mask
|
148 |
|
149 |
|
150 |
with gr.Blocks() as demo:
|