Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -48,32 +48,32 @@ def save_image(image):
|
|
48 |
return None
|
49 |
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
url = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
)
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
demo.launch()
|
|
|
|
48 |
return None
|
49 |
|
50 |
|
51 |
+
with gr.Blocks() as demo:
|
52 |
+
image = gr.Image(label="Upload an image")
|
53 |
+
text = gr.Textbox(label="Paste an image URL")
|
54 |
+
download_button = gr.Button("Download Image")
|
55 |
+
output_file = gr.File()
|
56 |
+
slider1 = ImageSlider(label="birefnet", type="pil")
|
57 |
+
slider2 = ImageSlider(label="birefnet", type="pil")
|
58 |
+
|
59 |
+
chameleon = load_img("butterfly.jpg", output_type="pil")
|
60 |
+
url = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
|
61 |
+
|
62 |
+
with gr.Tab("Image Upload"):
|
63 |
+
tab1 = gr.Interface(
|
64 |
+
fn, inputs=image, outputs=[slider1, output_file], examples=[chameleon], api_name="image"
|
65 |
+
)
|
66 |
+
|
67 |
+
with gr.Tab("Image URL"):
|
68 |
+
tab2 = gr.Interface(
|
69 |
+
fn, inputs=text, outputs=[slider2, output_file], examples=[url], api_name="text"
|
70 |
+
)
|
71 |
+
|
72 |
+
def process_download(image):
|
73 |
+
return save_image(image[0])
|
74 |
+
|
75 |
+
download_button.click(process_download, inputs=slider1, outputs=output_file)
|
|
|
76 |
|
77 |
if __name__ == "__main__":
|
78 |
demo.launch()
|
79 |
+
|