Spaces:
Runtime error
Runtime error
Jagrut Thakare
commited on
Commit
·
acec49f
1
Parent(s):
2c4722e
v2.6 - Working
Browse files
app.py
CHANGED
|
@@ -12,17 +12,9 @@ login(os.getenv("HF_TOKEN"))
|
|
| 12 |
@spaces.GPU()
|
| 13 |
def process_image(image, mask, progress=gr.Progress(track_tqdm=True)):
|
| 14 |
if np.unique(mask["background"]).size == 1:
|
| 15 |
-
print("\nDid not Receive Mask\n")
|
| 16 |
-
print("Mask Size : ", image["layers"][0].shape)
|
| 17 |
-
print("Unique values: ", np.unique(image["layers"][0]))
|
| 18 |
-
print("Type : ", type(image["layers"][0]))
|
| 19 |
mask = image["layers"][0]
|
| 20 |
output = process_inpaint(image["background"], mask)
|
| 21 |
else:
|
| 22 |
-
print("\nProcessing Received Mask\n")
|
| 23 |
-
print("Mask Size : ", mask["background"].shape)
|
| 24 |
-
print("Unique values: ", np.unique(mask["background"]))
|
| 25 |
-
print("Type : ", type(mask["background"]))
|
| 26 |
mask = mask["background"]
|
| 27 |
output = process_inpaint(image["background"], mask)
|
| 28 |
img_output = Image.fromarray(output).convert("RGB")
|
|
@@ -37,10 +29,11 @@ with gr.Blocks() as demo:
|
|
| 37 |
image = gr.ImageMask(type="numpy", layers=False, label="Upload Image")
|
| 38 |
with gr.Accordion(label="Advanced", open=False):
|
| 39 |
mask = gr.ImageMask(label="Mask", format="png", value=None, sources=["upload"])
|
|
|
|
| 40 |
button = gr.Button("Remove")
|
| 41 |
with gr.Column():
|
| 42 |
output = gr.Image(format="png", label="Output Image")
|
| 43 |
-
|
| 44 |
button.click(fn=process_image, inputs=[image, mask], outputs=[output, mask_out])
|
| 45 |
|
| 46 |
demo.launch(debug=True,show_error=True)
|
|
|
|
| 12 |
@spaces.GPU()
|
| 13 |
def process_image(image, mask, progress=gr.Progress(track_tqdm=True)):
|
| 14 |
if np.unique(mask["background"]).size == 1:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
mask = image["layers"][0]
|
| 16 |
output = process_inpaint(image["background"], mask)
|
| 17 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
mask = mask["background"]
|
| 19 |
output = process_inpaint(image["background"], mask)
|
| 20 |
img_output = Image.fromarray(output).convert("RGB")
|
|
|
|
| 29 |
image = gr.ImageMask(type="numpy", layers=False, label="Upload Image")
|
| 30 |
with gr.Accordion(label="Advanced", open=False):
|
| 31 |
mask = gr.ImageMask(label="Mask", format="png", value=None, sources=["upload"])
|
| 32 |
+
mask_out = gr.Image(format="png", label="Output Image")
|
| 33 |
button = gr.Button("Remove")
|
| 34 |
with gr.Column():
|
| 35 |
output = gr.Image(format="png", label="Output Image")
|
| 36 |
+
|
| 37 |
button.click(fn=process_image, inputs=[image, mask], outputs=[output, mask_out])
|
| 38 |
|
| 39 |
demo.launch(debug=True,show_error=True)
|