Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,8 @@ import os
|
|
| 2 |
import torch
|
| 3 |
import spaces
|
| 4 |
import gradio as gr
|
| 5 |
-
from diffusers import FluxFillPipeline
|
|
|
|
| 6 |
import random
|
| 7 |
import numpy as np
|
| 8 |
from huggingface_hub import hf_hub_download
|
|
@@ -33,15 +34,18 @@ def inpaintGen(
|
|
| 33 |
randomize_seed: bool,
|
| 34 |
progress=gr.Progress(track_tqdm=True)):
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
-
if not
|
| 40 |
raise gr.Error("Please upload an image.")
|
| 41 |
|
| 42 |
-
if not
|
| 43 |
raise gr.Error("Please draw a mask on the image.")
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
width, height = source_img.size
|
| 46 |
|
| 47 |
if randomize_seed:
|
|
@@ -74,7 +78,7 @@ with gr.Blocks(theme="ocean", title="Flux.1 dev inpaint", css=CSS) as demo:
|
|
| 74 |
""")
|
| 75 |
with gr.Row():
|
| 76 |
with gr.Column():
|
| 77 |
-
imgMask = gr.ImageMask(type="
|
| 78 |
inpaint_prompt = gr.Textbox(label='Prompts ✏️', placeholder="A hat...")
|
| 79 |
with gr.Row():
|
| 80 |
Inpaint_sendBtn = gr.Button(value="Submit", variant='primary')
|
|
|
|
| 2 |
import torch
|
| 3 |
import spaces
|
| 4 |
import gradio as gr
|
| 5 |
+
from diffusers import FluxFillPipeline
|
| 6 |
+
from diffusers.utils import load_image
|
| 7 |
import random
|
| 8 |
import numpy as np
|
| 9 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 34 |
randomize_seed: bool,
|
| 35 |
progress=gr.Progress(track_tqdm=True)):
|
| 36 |
|
| 37 |
+
source_path = imgMask["background"]
|
| 38 |
+
mask_path = imgMask["layers"][0]
|
| 39 |
|
| 40 |
+
if not source_path:
|
| 41 |
raise gr.Error("Please upload an image.")
|
| 42 |
|
| 43 |
+
if not mask_path:
|
| 44 |
raise gr.Error("Please draw a mask on the image.")
|
| 45 |
+
|
| 46 |
+
source_img = load_image(source_path)
|
| 47 |
+
mask_img = load_image(mask_path)
|
| 48 |
+
|
| 49 |
width, height = source_img.size
|
| 50 |
|
| 51 |
if randomize_seed:
|
|
|
|
| 78 |
""")
|
| 79 |
with gr.Row():
|
| 80 |
with gr.Column():
|
| 81 |
+
imgMask = gr.ImageMask(type="filepath", label="Image", layers=False, height=800)
|
| 82 |
inpaint_prompt = gr.Textbox(label='Prompts ✏️', placeholder="A hat...")
|
| 83 |
with gr.Row():
|
| 84 |
Inpaint_sendBtn = gr.Button(value="Submit", variant='primary')
|