Spaces:
Sleeping
Sleeping
NBoukachab
commited on
Commit
•
4bfbf72
1
Parent(s):
a825fd3
Modif clear function and comments
Browse files
app.py
CHANGED
@@ -83,8 +83,8 @@ def query_image(image):
|
|
83 |
predict.append(
|
84 |
{
|
85 |
# The list of coordinates of the points of the polygon.
|
86 |
-
#
|
87 |
-
"polygon": np.asarray(polygon["polygon"]).tolist(),
|
88 |
# Confidence that the model predicts the polygon in the right place
|
89 |
"confidence": polygon["confidence"],
|
90 |
# The channel on which the polygon is predicted
|
@@ -146,10 +146,10 @@ with gr.Blocks() as process_image:
|
|
146 |
# Generates a json with the model predictions
|
147 |
json_output = gr.JSON()
|
148 |
|
149 |
-
#
|
150 |
clear_button.click(
|
151 |
-
lambda
|
152 |
-
inputs=[
|
153 |
outputs=[image, image_output, json_output],
|
154 |
)
|
155 |
|
|
|
83 |
predict.append(
|
84 |
{
|
85 |
# The list of coordinates of the points of the polygon.
|
86 |
+
# Cast to list of np.int32 to make it JSON-serializable
|
87 |
+
"polygon": np.asarray(polygon["polygon"], dtype=np.int32).tolist(),
|
88 |
# Confidence that the model predicts the polygon in the right place
|
89 |
"confidence": polygon["confidence"],
|
90 |
# The channel on which the polygon is predicted
|
|
|
146 |
# Generates a json with the model predictions
|
147 |
json_output = gr.JSON()
|
148 |
|
149 |
+
# Clear button: set default values to inputs and output objects
|
150 |
clear_button.click(
|
151 |
+
lambda: (None, None, None),
|
152 |
+
inputs=[],
|
153 |
outputs=[image, image_output, json_output],
|
154 |
)
|
155 |
|