sigyllly commited on
Commit
b9f4e57
·
verified ·
1 Parent(s): 776f94c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
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
- # Define Gradio interface
60
- iface = gr.Interface(
61
  fn=extract_image,
62
  inputs=[
63
  gr.Textbox(
@@ -77,5 +77,17 @@ iface = gr.Interface(
77
  ],
78
  )
79
 
80
- # Launch Gradio API with an explicit endpoint
81
- iface.launch(share=True, debug=True, host="0.0.0.0", port=7860, open_browser=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
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)