File size: 751 Bytes
423ba9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from OCR_test import process_image  

def detect_objects(image):
    try:
        # Call the `process_image` function with the image path
        result = process_image(image)
        return result
    except Exception as e:
        # Return any errors encountered during processing
        return f"Error: {e}"

# Define the Gradio interface
interface = gr.Interface(
    fn=detect_objects,
    inputs=gr.Image(type="filepath", label="Upload Image"),  # Set to "filepath" to pass file path directly
    outputs=gr.Textbox(label="Detection Results"),
    title="OCR Detection",
    description="Upload an image to get OCR results."
)

# Launch the Gradio app
if __name__ == "__main__":
    interface.launch()