Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,8 +23,8 @@ def find_similarity(base64_image, text_input):
|
|
23 |
# Decode the base64 image to bytes
|
24 |
image_bytes = base64.b64decode(base64_image)
|
25 |
|
26 |
-
# Convert the bytes to a
|
27 |
-
image = Image.open(BytesIO(image_bytes))
|
28 |
|
29 |
# Preprocess the image
|
30 |
image = preprocess(image).unsqueeze(0).to(device)
|
@@ -55,7 +55,7 @@ def segment_image(input_image, text_input):
|
|
55 |
image = image.convert("RGB")
|
56 |
|
57 |
mask_generator = SamAutomaticMaskGenerator(sam)
|
58 |
-
masks = mask_generator.generate(image)
|
59 |
|
60 |
segmented_regions = [] # List to store segmented regions with similarity scores
|
61 |
|
|
|
23 |
# Decode the base64 image to bytes
|
24 |
image_bytes = base64.b64decode(base64_image)
|
25 |
|
26 |
+
# Convert the bytes to a numpy array
|
27 |
+
image = np.array(Image.open(BytesIO(image_bytes)))
|
28 |
|
29 |
# Preprocess the image
|
30 |
image = preprocess(image).unsqueeze(0).to(device)
|
|
|
55 |
image = image.convert("RGB")
|
56 |
|
57 |
mask_generator = SamAutomaticMaskGenerator(sam)
|
58 |
+
masks = mask_generator.generate(np.array(image))
|
59 |
|
60 |
segmented_regions = [] # List to store segmented regions with similarity scores
|
61 |
|