test / app.py
stphtan94117's picture
Upload app.py
423ba9d verified
raw
history blame contribute delete
751 Bytes
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()