Spaces:
Runtime error
Runtime error
cap image size, ensure result dimension is divisible by 8
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
from typing import Tuple
|
| 2 |
|
| 3 |
-
import torch
|
| 4 |
-
import spaces
|
| 5 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 6 |
from diffusers import FluxInpaintPipeline
|
| 7 |
|
| 8 |
MARKDOWN = """
|
|
@@ -49,22 +50,24 @@ def process(input_image_editor, input_text, progress=gr.Progress(track_tqdm=True
|
|
| 49 |
return None
|
| 50 |
|
| 51 |
image = input_image_editor['background']
|
| 52 |
-
|
| 53 |
|
| 54 |
if not image:
|
| 55 |
gr.Info("Please upload an image.")
|
| 56 |
return None
|
| 57 |
|
| 58 |
-
if not
|
| 59 |
gr.Info("Please draw a mask on the image.")
|
| 60 |
return None
|
| 61 |
|
| 62 |
width, height = resize_image_dimensions(original_resolution_wh=image.size)
|
|
|
|
|
|
|
| 63 |
|
| 64 |
return pipe(
|
| 65 |
prompt=input_text,
|
| 66 |
-
image=
|
| 67 |
-
mask_image=
|
| 68 |
width=width,
|
| 69 |
height=height,
|
| 70 |
strength=0.7,
|
|
|
|
| 1 |
from typing import Tuple
|
| 2 |
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
+
import spaces
|
| 5 |
+
import torch
|
| 6 |
+
from PIL import Image
|
| 7 |
from diffusers import FluxInpaintPipeline
|
| 8 |
|
| 9 |
MARKDOWN = """
|
|
|
|
| 50 |
return None
|
| 51 |
|
| 52 |
image = input_image_editor['background']
|
| 53 |
+
mask = input_image_editor['layers'][0]
|
| 54 |
|
| 55 |
if not image:
|
| 56 |
gr.Info("Please upload an image.")
|
| 57 |
return None
|
| 58 |
|
| 59 |
+
if not mask:
|
| 60 |
gr.Info("Please draw a mask on the image.")
|
| 61 |
return None
|
| 62 |
|
| 63 |
width, height = resize_image_dimensions(original_resolution_wh=image.size)
|
| 64 |
+
resized_image = image.resize((width, height), Image.LANCZOS)
|
| 65 |
+
resized_mask = mask.resize((width, height), Image.NEAREST)
|
| 66 |
|
| 67 |
return pipe(
|
| 68 |
prompt=input_text,
|
| 69 |
+
image=resized_image,
|
| 70 |
+
mask_image=resized_mask,
|
| 71 |
width=width,
|
| 72 |
height=height,
|
| 73 |
strength=0.7,
|