Spaces:
Sleeping
Sleeping
import gradio as gr | |
from recognization.recognization import TextRecognition | |
from detection.recognize_id.detect_and_recognize_id import Recognize_ID | |
from detection.detection import detection | |
import os | |
# Define a dummy prediction function | |
def predict_image(image): | |
# Recognize ID | |
rec_id = Recognize_ID() | |
id = rec_id.give_me_id_number(image) | |
# Detection | |
det = detection() | |
detection_list = det.full_pipeline(image) | |
result = '' | |
# Loop on all detected images and recognize them | |
recognizer = TextRecognition() | |
for line in detection_list[2:6]: | |
for word in line: | |
recognized_word = recognizer.recognize_image(word) | |
result = result + recognized_word + ' ' | |
result += '\n' | |
# Add Id number | |
result = result + id | |
return result | |
# List of paths to your sample images | |
current_dir = os.path.dirname(os.path.abspath(__file__)) | |
sample_images = [ | |
os.path.join(current_dir , "samples/id_1.png" ) | |
] | |
# Create the Gradio interface | |
interface = gr.Interface( | |
fn=predict_image, # Function to run | |
inputs="image", # Input type | |
outputs="text", # Output type | |
title="Information extraction from Egyptian IDs", | |
description="Upload an image", | |
examples=sample_images | |
) | |
# Launch the app | |
interface.launch() | |