Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,37 +40,42 @@ def process_file_via_api(f):
|
|
40 |
chameleon = "butterfly.jpg"
|
41 |
url_example = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
sliders_processed = gr.Image(label="Processed Image")
|
48 |
-
slider_origin = gr.Image(label="Original Image")
|
49 |
-
|
50 |
tab1 = gr.Interface(
|
51 |
fn=process_image_via_api,
|
52 |
-
inputs=
|
53 |
-
outputs=[
|
54 |
examples=[chameleon],
|
55 |
api_name="/image_api"
|
56 |
)
|
57 |
|
|
|
|
|
|
|
|
|
58 |
tab2 = gr.Interface(
|
59 |
fn=process_url_via_api,
|
60 |
-
inputs=
|
61 |
-
outputs=[
|
62 |
examples=[url_example],
|
63 |
api_name="/url_api"
|
64 |
)
|
65 |
|
|
|
|
|
|
|
66 |
tab3 = gr.Interface(
|
67 |
fn=process_file_via_api,
|
68 |
-
inputs=
|
69 |
-
outputs=
|
70 |
examples=[chameleon],
|
71 |
api_name="/png_api"
|
72 |
)
|
73 |
|
|
|
74 |
demo = gr.TabbedInterface(
|
75 |
[tab1, tab2, tab3],
|
76 |
["Image Upload", "URL Input", "File Output"],
|
|
|
40 |
chameleon = "butterfly.jpg"
|
41 |
url_example = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
|
42 |
|
43 |
+
# Tab 1: Image Upload
|
44 |
+
sliders_processed_tab1 = gr.Image(label="Processed Image")
|
45 |
+
sliders_origin_tab1 = gr.Image(label="Original Image")
|
46 |
+
image_upload_tab1 = gr.Image(label="Upload an image")
|
|
|
|
|
|
|
47 |
tab1 = gr.Interface(
|
48 |
fn=process_image_via_api,
|
49 |
+
inputs=image_upload_tab1,
|
50 |
+
outputs=[sliders_processed_tab1, sliders_origin_tab1],
|
51 |
examples=[chameleon],
|
52 |
api_name="/image_api"
|
53 |
)
|
54 |
|
55 |
+
# Tab 2: URL Input
|
56 |
+
sliders_processed_tab2 = gr.Image(label="Processed Image")
|
57 |
+
sliders_origin_tab2 = gr.Image(label="Original Image")
|
58 |
+
url_input_tab2 = gr.Textbox(label="Paste an image URL")
|
59 |
tab2 = gr.Interface(
|
60 |
fn=process_url_via_api,
|
61 |
+
inputs=url_input_tab2,
|
62 |
+
outputs=[sliders_processed_tab2, sliders_origin_tab2],
|
63 |
examples=[url_example],
|
64 |
api_name="/url_api"
|
65 |
)
|
66 |
|
67 |
+
# Tab 3: File Output
|
68 |
+
output_file_tab3 = gr.File(label="Output PNG File")
|
69 |
+
image_file_upload_tab3 = gr.Image(label="Upload an image", type="filepath")
|
70 |
tab3 = gr.Interface(
|
71 |
fn=process_file_via_api,
|
72 |
+
inputs=image_file_upload_tab3,
|
73 |
+
outputs=output_file_tab3,
|
74 |
examples=[chameleon],
|
75 |
api_name="/png_api"
|
76 |
)
|
77 |
|
78 |
+
# Create the Tabbed Interface
|
79 |
demo = gr.TabbedInterface(
|
80 |
[tab1, tab2, tab3],
|
81 |
["Image Upload", "URL Input", "File Output"],
|