Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 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 |
|