Update app.py
Browse files
app.py
CHANGED
|
@@ -56,8 +56,8 @@ def extract_image(pos_prompts, neg_prompts, img, threshold):
|
|
| 56 |
|
| 57 |
return output_image, final_mask
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
|
| 61 |
fn=extract_image,
|
| 62 |
inputs=[
|
| 63 |
gr.Textbox(
|
|
@@ -77,5 +77,17 @@ iface = gr.Interface(
|
|
| 77 |
],
|
| 78 |
)
|
| 79 |
|
| 80 |
-
# Launch Gradio
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
return output_image, final_mask
|
| 58 |
|
| 59 |
+
# Gradio UI
|
| 60 |
+
iface_ui = gr.Interface(
|
| 61 |
fn=extract_image,
|
| 62 |
inputs=[
|
| 63 |
gr.Textbox(
|
|
|
|
| 77 |
],
|
| 78 |
)
|
| 79 |
|
| 80 |
+
# Launch Gradio UI
|
| 81 |
+
iface_ui.launch()
|
| 82 |
+
|
| 83 |
+
# Non-UI Version
|
| 84 |
+
def run_non_ui(image_path, pos_prompts, neg_prompts, threshold):
|
| 85 |
+
img = Image.open(image_path)
|
| 86 |
+
output_image, output_mask = extract_image(pos_prompts, neg_prompts, img, threshold)
|
| 87 |
+
|
| 88 |
+
# Save or use the output_image and output_mask as needed
|
| 89 |
+
output_image.show() # For demonstration purposes, opens the image with the default image viewer
|
| 90 |
+
output_mask.show() # For demonstration purposes, opens the mask with the default image viewer
|
| 91 |
+
|
| 92 |
+
# Example of using non-UI version
|
| 93 |
+
# run_non_ui("path/to/your/image.jpg", "positive prompt", "negative prompt", 0.5)
|