Spaces:
Runtime error
Runtime error
Revert "skip examples for now"
Browse filesThis reverts commit 93bcc9cf2191e844beb73ffb881fa633295d8165.
app.py
CHANGED
|
@@ -41,36 +41,36 @@ def remove_background(image: Image.Image, threshold: int = 50) -> Image.Image:
|
|
| 41 |
return image
|
| 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 |
pipe = FluxInpaintPipeline.from_pretrained(
|
| 76 |
"black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
|
|
@@ -240,27 +240,27 @@ with gr.Blocks() as demo:
|
|
| 240 |
with gr.Accordion("Debug", open=False):
|
| 241 |
output_mask_component = gr.Image(
|
| 242 |
type='pil', image_mode='RGB', label='Input mask', format="png")
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
|
| 265 |
submit_button_component.click(
|
| 266 |
fn=process,
|
|
|
|
| 41 |
return image
|
| 42 |
|
| 43 |
|
| 44 |
+
EXAMPLES = [
|
| 45 |
+
[
|
| 46 |
+
None,
|
| 47 |
+
{
|
| 48 |
+
"background": Image.open(requests.get("https://media.roboflow.com/spaces/doge-2-image.png", stream=True).raw),
|
| 49 |
+
"layers": [remove_background(Image.open(requests.get("https://media.roboflow.com/spaces/doge-2-mask-2.png", stream=True).raw))],
|
| 50 |
+
"composite": Image.open(requests.get("https://media.roboflow.com/spaces/doge-2-composite-2.png", stream=True).raw),
|
| 51 |
+
},
|
| 52 |
+
"little lion",
|
| 53 |
+
None,
|
| 54 |
+
42,
|
| 55 |
+
False,
|
| 56 |
+
0.85,
|
| 57 |
+
30
|
| 58 |
+
],
|
| 59 |
+
[
|
| 60 |
+
None,
|
| 61 |
+
{
|
| 62 |
+
"background": Image.open(requests.get("https://media.roboflow.com/spaces/doge-2-image.png", stream=True).raw),
|
| 63 |
+
"layers": [remove_background(Image.open(requests.get("https://media.roboflow.com/spaces/doge-2-mask-3.png", stream=True).raw))],
|
| 64 |
+
"composite": Image.open(requests.get("https://media.roboflow.com/spaces/doge-2-composite-3.png", stream=True).raw),
|
| 65 |
+
},
|
| 66 |
+
"tattoos",
|
| 67 |
+
None,
|
| 68 |
+
42,
|
| 69 |
+
False,
|
| 70 |
+
0.85,
|
| 71 |
+
30
|
| 72 |
+
]
|
| 73 |
+
]
|
| 74 |
|
| 75 |
pipe = FluxInpaintPipeline.from_pretrained(
|
| 76 |
"black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
|
|
|
|
| 240 |
with gr.Accordion("Debug", open=False):
|
| 241 |
output_mask_component = gr.Image(
|
| 242 |
type='pil', image_mode='RGB', label='Input mask', format="png")
|
| 243 |
+
with gr.Row():
|
| 244 |
+
gr.Examples(
|
| 245 |
+
fn=process,
|
| 246 |
+
examples=EXAMPLES,
|
| 247 |
+
inputs=[
|
| 248 |
+
input_image_editor_component,
|
| 249 |
+
inpainting_prompt_text_component,
|
| 250 |
+
masking_prompt_text_component,
|
| 251 |
+
masking_prompt_text_component,
|
| 252 |
+
seed_slicer_component,
|
| 253 |
+
randomize_seed_checkbox_component,
|
| 254 |
+
strength_slider_component,
|
| 255 |
+
num_inference_steps_slider_component
|
| 256 |
+
],
|
| 257 |
+
outputs=[
|
| 258 |
+
output_image_component,
|
| 259 |
+
output_mask_component
|
| 260 |
+
],
|
| 261 |
+
run_on_click=True,
|
| 262 |
+
cache_examples=True
|
| 263 |
+
)
|
| 264 |
|
| 265 |
submit_button_component.click(
|
| 266 |
fn=process,
|