diff --git a/README.md b/README.md index 387f86d8d57382f4d34dd6627dd3d841964a95ae..75071aeb73e86f63ad6b7c5e53fd5157efe5aa79 100644 --- a/README.md +++ b/README.md @@ -313,8 +313,8 @@ An example is available in the `huggingface/` folder. You need to create a JSON | ---------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------- | | `model_name` | Name of the model |`doc-ufcn-generic-historical-line`| | `classes_colors` | List with the colors of the classes | `["green"]`| -| `title` | Title of the app | **Required**| -| `description` | Description of the app | **Required**| +| `title` | Title of the app (supports Markdown) | **Required**| +| `description` | Description of the app (supports Markdown) | **Required**| | `examples` | Paths towards the image examples. | **Required**| A ready-to-use configuration file is available in `huggingface/config.json`. You may update it to your needs. diff --git a/hugging_face/app.py b/hugging_face/app.py index cf001e5fee4cf98f2067104bbdf481c47cdc47ac..0f32319dcdec174e98f4d5ce52d8369f320c55c8 100644 --- a/hugging_face/app.py +++ b/hugging_face/app.py @@ -101,15 +101,13 @@ def query_image(image): # Add an index to dictionary keys to differentiate predictions of the same class predict.append( { - "polygon": np.asarray(polygon["polygon"]) - .astype(int) - .tolist(), # The list of coordinates of the points of the polygon - "confidence": polygon[ - "confidence" - ], # Confidence that the model predicts the polygon in the right place - "channel": classes[ - channel - ], # The channel on which the polygon is predicted + # The list of coordinates of the points of the polygon. + # Cast to list of np.int32 to make it JSON-serializable + "polygon": np.asarray(polygon["polygon"], dtype=np.int32).tolist(), + # Confidence that the model predicts the polygon in the right place + "confidence": polygon["confidence"], + # The channel on which the polygon is predicted + "channel": classes[channel], } ) @@ -120,7 +118,7 @@ def query_image(image): with gr.Blocks() as process_image: # Create app title - gr.Markdown(f"<h1 align='center'>{config['title']}</h1>") + gr.Markdown(f"# {config['title']}") # Create app description gr.Markdown(config["description"]) @@ -167,10 +165,10 @@ with gr.Blocks() as process_image: # Generates a json with the model predictions json_output = gr.JSON() - # Create the button to clear the inputs and outputs + # Clear button: set default values to inputs and output objects clear_button.click( - lambda x, y, z: (None, None, None), - inputs=[image, image_output, json_output], + lambda: (None, None, None), + inputs=[], outputs=[image, image_output, json_output], ) diff --git a/hugging_face/resource/hf_doc_ufcn_line_hist.png b/hugging_face/resource/hf_doc_ufcn_line_hist.png index 58daa8a7b9712dc028cecdcaaa8bc784d6ae15e9..16f7789662a95f264804052605caf27add2eea34 100644 Binary files a/hugging_face/resource/hf_doc_ufcn_line_hist.png and b/hugging_face/resource/hf_doc_ufcn_line_hist.png differ