Update app.py
Browse files
app.py
CHANGED
|
@@ -89,5 +89,21 @@ with gr.Blocks() as demo:
|
|
| 89 |
outputs=[output_image, output_mask],
|
| 90 |
)
|
| 91 |
|
| 92 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
demo.launch()
|
|
|
|
|
|
| 89 |
outputs=[output_image, output_mask],
|
| 90 |
)
|
| 91 |
|
| 92 |
+
# API endpoint definition
|
| 93 |
+
iface = gr.Interface(
|
| 94 |
+
extract_image,
|
| 95 |
+
[
|
| 96 |
+
gr.Textbox(label="Positive prompts"),
|
| 97 |
+
gr.Textbox(label="Negative prompts"),
|
| 98 |
+
gr.Image(type="pil"),
|
| 99 |
+
gr.Slider(minimum=0, maximum=1, value=0.4, label="Threshold"),
|
| 100 |
+
],
|
| 101 |
+
[gr.Image(label="Result"), gr.Image(label="Mask")],
|
| 102 |
+
"textbox,textbox,image,slider",
|
| 103 |
+
"image,image",
|
| 104 |
+
title="CLIPSeg API",
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
# Launch both UI and API
|
| 108 |
demo.launch()
|
| 109 |
+
iface.launch(share=True)
|