Spaces:
Sleeping
Sleeping
stphtan94117
commited on
Commit
•
423ba9d
1
Parent(s):
9dd6848
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from OCR_test import process_image
|
3 |
+
|
4 |
+
def detect_objects(image):
|
5 |
+
try:
|
6 |
+
# Call the `process_image` function with the image path
|
7 |
+
result = process_image(image)
|
8 |
+
return result
|
9 |
+
except Exception as e:
|
10 |
+
# Return any errors encountered during processing
|
11 |
+
return f"Error: {e}"
|
12 |
+
|
13 |
+
# Define the Gradio interface
|
14 |
+
interface = gr.Interface(
|
15 |
+
fn=detect_objects,
|
16 |
+
inputs=gr.Image(type="filepath", label="Upload Image"), # Set to "filepath" to pass file path directly
|
17 |
+
outputs=gr.Textbox(label="Detection Results"),
|
18 |
+
title="OCR Detection",
|
19 |
+
description="Upload an image to get OCR results."
|
20 |
+
)
|
21 |
+
|
22 |
+
# Launch the Gradio app
|
23 |
+
if __name__ == "__main__":
|
24 |
+
interface.launch()
|