Spaces:
Build error
Build error
Commit
·
c5da540
1
Parent(s):
85bcfe1
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
python -m pip install --upgrade pip
|
2 |
from diffusers import AutoencoderKL, UNet2DConditionModel, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
|
3 |
import gradio as gr
|
4 |
import torch
|
@@ -240,33 +239,6 @@ def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance
|
|
240 |
|
241 |
# update_state(f"Done. Seed: {seed}")
|
242 |
|
243 |
-
# Inpainting function
|
244 |
-
def inpaint(image, mask):
|
245 |
-
# Convert PIL Image to OpenCV format
|
246 |
-
image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
|
247 |
-
mask = cv2.cvtColor(np.array(mask), cv2.COLOR_RGB2BGR)
|
248 |
-
|
249 |
-
# Perform inpainting
|
250 |
-
inpainted = cv2.inpaint(image, mask, 3, cv2.INPAINT_TELEA)
|
251 |
-
|
252 |
-
# Convert back to PIL Image
|
253 |
-
inpainted = Image.fromarray(cv2.cvtColor(inpainted, cv2.COLOR_BGR2RGB))
|
254 |
-
|
255 |
-
return inpainted
|
256 |
-
|
257 |
-
# Gradio interface
|
258 |
-
image = gr.inputs.Image()
|
259 |
-
mask = gr.inputs.Image()
|
260 |
-
|
261 |
-
iface = gr.Interface(
|
262 |
-
fn=inpaint,
|
263 |
-
inputs=[image, mask],
|
264 |
-
outputs="image"
|
265 |
-
)
|
266 |
-
|
267 |
-
iface.launch()
|
268 |
-
return replace_nsfw_images(result)
|
269 |
-
|
270 |
def replace_nsfw_images(results):
|
271 |
|
272 |
if is_colab:
|
|
|
|
|
1 |
from diffusers import AutoencoderKL, UNet2DConditionModel, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
|
2 |
import gradio as gr
|
3 |
import torch
|
|
|
239 |
|
240 |
# update_state(f"Done. Seed: {seed}")
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
def replace_nsfw_images(results):
|
243 |
|
244 |
if is_colab:
|