Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -103,11 +103,13 @@ def segment_image(input_image, text_input):
|
|
103 |
api_result = client.predict(image_base64, text_input, api_name="/predict")
|
104 |
|
105 |
# Append the API result and similarity to the list
|
106 |
-
results_with_similarity.append({"api_result": api_result, "similarity": similarity})
|
107 |
|
|
|
|
|
108 |
# Print the top 6 results
|
109 |
-
for result in results_with_similarity:
|
110 |
-
|
111 |
|
112 |
# Return the segmented images in descending order of similarity
|
113 |
return results_with_similarity
|
@@ -115,7 +117,7 @@ def segment_image(input_image, text_input):
|
|
115 |
# Create Gradio components
|
116 |
input_image = gr.Textbox(label="Base64 Image", lines=8)
|
117 |
text_input = gr.Textbox(label="Text Input") # Use Textbox with a label
|
118 |
-
|
119 |
|
120 |
# Create a Gradio interface
|
121 |
-
gr.Interface(fn=segment_image, inputs=[input_image, text_input], outputs=
|
|
|
103 |
api_result = client.predict(image_base64, text_input, api_name="/predict")
|
104 |
|
105 |
# Append the API result and similarity to the list
|
106 |
+
results_with_similarity.append({"api_result": api_result, "image": image_base64, "similarity": similarity})
|
107 |
|
108 |
+
results_with_similarity = results_with_similarity[:1]
|
109 |
+
|
110 |
# Print the top 6 results
|
111 |
+
# for result in results_with_similarity:
|
112 |
+
# print(result)
|
113 |
|
114 |
# Return the segmented images in descending order of similarity
|
115 |
return results_with_similarity
|
|
|
117 |
# Create Gradio components
|
118 |
input_image = gr.Textbox(label="Base64 Image", lines=8)
|
119 |
text_input = gr.Textbox(label="Text Input") # Use Textbox with a label
|
120 |
+
output_images = gr.outputs.JSON()
|
121 |
|
122 |
# Create a Gradio interface
|
123 |
+
gr.Interface(fn=segment_image, inputs=[input_image, text_input], outputs=output_images).launch()
|