NBoukachab commited on
Commit
4bfbf72
1 Parent(s): a825fd3

Modif clear function and comments

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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
- # Use np.asarray to change list to ndarray to turn int64 to int32 with np.ndarray.tolist
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
- # Create the button to clear the inputs and outputs
150
  clear_button.click(
151
- lambda x, y, z: (None, None, None),
152
- inputs=[image, image_output, json_output],
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