Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ from PIL import Image, ImageOps
|
|
15 |
import numpy as np
|
16 |
import imageio
|
17 |
os.mkdir("data")
|
18 |
-
|
19 |
os.mkdir("dataout")
|
20 |
|
21 |
# Load CLIPSeg model
|
@@ -42,10 +42,12 @@ def process_image(image, prompt):
|
|
42 |
# Perform inpainting with LAMA
|
43 |
# input_dict = {"image": image, "mask": mask_image}
|
44 |
# imageio.imwrite("./data/data_mask.png", input_dict["mask"])
|
45 |
-
|
|
|
46 |
# # inpainted_image = lama_model.inference(data=input_dict)["data"][0]
|
|
|
47 |
|
48 |
-
inpainted_image = Image.new('RGB', (image.shape[1], image.shape[0]), (0, 0, 0))
|
49 |
# inpainted_image = cv2.cvtColor(inpainted_image, cv2.COLOR_BGR2RGB)
|
50 |
# inpainted_image = Image.fromarray(inpainted_image)
|
51 |
|
@@ -53,7 +55,7 @@ def process_image(image, prompt):
|
|
53 |
|
54 |
interface = gr.Interface(fn=process_image,
|
55 |
inputs=[gr.Image(type="pil"), gr.Textbox(label="Please describe what you want to identify")],
|
56 |
-
outputs=[gr.Image(type="pil"), gr.Image(type="
|
57 |
title="Interactive demo: zero-shot image segmentation with CLIPSeg and inpainting with LAMA",
|
58 |
description="Demo for using CLIPSeg and LAMA to perform zero- and one-shot image segmentation and inpainting. To use it, simply upload an image and add a text to mask (identify in the image), or use one of the examples below and click 'submit'. Results will show up in a few seconds.")
|
59 |
|
|
|
15 |
import numpy as np
|
16 |
import imageio
|
17 |
os.mkdir("data")
|
18 |
+
os.rename("best.ckpt", "models/best.ckpt")
|
19 |
os.mkdir("dataout")
|
20 |
|
21 |
# Load CLIPSeg model
|
|
|
42 |
# Perform inpainting with LAMA
|
43 |
# input_dict = {"image": image, "mask": mask_image}
|
44 |
# imageio.imwrite("./data/data_mask.png", input_dict["mask"])
|
45 |
+
imageio.imwrite("./data/data_mask.png", mask_image)
|
46 |
+
os.system('python predict.py model.path=/home/user/app/ indir=/home/user/app/data/ outdir=/home/user/app/dataout/ device=cpu')
|
47 |
# # inpainted_image = lama_model.inference(data=input_dict)["data"][0]
|
48 |
+
inpainted_image = "./data/data_mask.png"
|
49 |
|
50 |
+
# inpainted_image = Image.new('RGB', (image.shape[1], image.shape[0]), (0, 0, 0))
|
51 |
# inpainted_image = cv2.cvtColor(inpainted_image, cv2.COLOR_BGR2RGB)
|
52 |
# inpainted_image = Image.fromarray(inpainted_image)
|
53 |
|
|
|
55 |
|
56 |
interface = gr.Interface(fn=process_image,
|
57 |
inputs=[gr.Image(type="pil"), gr.Textbox(label="Please describe what you want to identify")],
|
58 |
+
outputs=[gr.Image(type="pil"), gr.Image(type="file",label="output")],
|
59 |
title="Interactive demo: zero-shot image segmentation with CLIPSeg and inpainting with LAMA",
|
60 |
description="Demo for using CLIPSeg and LAMA to perform zero- and one-shot image segmentation and inpainting. To use it, simply upload an image and add a text to mask (identify in the image), or use one of the examples below and click 'submit'. Results will show up in a few seconds.")
|
61 |
|