Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -79,12 +79,22 @@ def generate_ocr(method, img):
|
|
79 |
|
80 |
return text_output, label
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
# Gradio Interface
|
83 |
image_input = gr.Image()
|
84 |
method_input = gr.Radio(["PaddleOCR", "EasyOCR", "KerasOCR"], value="PaddleOCR")
|
85 |
output_text = gr.Textbox(label="Extracted Text")
|
86 |
output_label = gr.Textbox(label="Spam Classification")
|
87 |
|
|
|
|
|
88 |
demo = gr.Interface(
|
89 |
generate_ocr,
|
90 |
inputs=[method_input, image_input],
|
@@ -94,6 +104,13 @@ demo = gr.Interface(
|
|
94 |
theme="compact",
|
95 |
)
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
# Launch App
|
98 |
if __name__ == "__main__":
|
99 |
demo.launch()
|
|
|
79 |
|
80 |
return text_output, label
|
81 |
|
82 |
+
# Clear Button Functionality
|
83 |
+
def clear_and_save(output_text, output_label):
|
84 |
+
# Save the results to the repository before clearing
|
85 |
+
save_results_to_repo(output_text, output_label)
|
86 |
+
|
87 |
+
# Return empty values to clear the Gradio interface
|
88 |
+
return "", ""
|
89 |
+
|
90 |
# Gradio Interface
|
91 |
image_input = gr.Image()
|
92 |
method_input = gr.Radio(["PaddleOCR", "EasyOCR", "KerasOCR"], value="PaddleOCR")
|
93 |
output_text = gr.Textbox(label="Extracted Text")
|
94 |
output_label = gr.Textbox(label="Spam Classification")
|
95 |
|
96 |
+
clear_button = gr.Button("Clear") # Add the Clear button
|
97 |
+
|
98 |
demo = gr.Interface(
|
99 |
generate_ocr,
|
100 |
inputs=[method_input, image_input],
|
|
|
104 |
theme="compact",
|
105 |
)
|
106 |
|
107 |
+
# Set up the Clear button functionality
|
108 |
+
clear_button.click(
|
109 |
+
clear_and_save,
|
110 |
+
inputs=[output_text, output_label],
|
111 |
+
outputs=[output_text, output_label]
|
112 |
+
)
|
113 |
+
|
114 |
# Launch App
|
115 |
if __name__ == "__main__":
|
116 |
demo.launch()
|