ktllc commited on
Commit
cf83b7c
·
1 Parent(s): fbf28e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -51,7 +51,10 @@ def find_similarity(base64_image, text_input):
51
 
52
  # Define a function for image segmentation
53
  def segment_image(input_image, text_input):
54
- image = cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)
 
 
 
55
  mask_generator = SamAutomaticMaskGenerator(sam)
56
  masks = mask_generator.generate(image)
57
 
@@ -81,7 +84,7 @@ def segment_image(input_image, text_input):
81
  return segmented_regions
82
 
83
  # Create Gradio components
84
- input_image = gr.inputs.Image()
85
  text_input = gr.Textbox(label="Text Input") # Use Textbox with a label
86
  output_images = gr.outputs.JSON()
87
 
 
51
 
52
  # Define a function for image segmentation
53
  def segment_image(input_image, text_input):
54
+ image_bytes = base64.b64decode(input_image)
55
+ image = Image.open(BytesIO(image_bytes))
56
+
57
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
58
  mask_generator = SamAutomaticMaskGenerator(sam)
59
  masks = mask_generator.generate(image)
60
 
 
84
  return segmented_regions
85
 
86
  # Create Gradio components
87
+ input_image = gr.Textbox(label="Base64 Image", lines=8)
88
  text_input = gr.Textbox(label="Text Input") # Use Textbox with a label
89
  output_images = gr.outputs.JSON()
90