May222's picture
Update app.py
74f998a
raw
history blame
981 Bytes
import gradio as gr
# from transformers import pipeline
from PIL import Image
import pytesseract
import cv2
import os
# pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
# def predict(input_img):
# predictions = pipeline(input_img)
# return input_img, {p["label"]: p["score"] for p in predictions}
def recognize(input_img):
text = pytesseract.image_to_string(Image.open("./data/" + filename))
return input_img, text
gradio_app = gr.Interface(
recognize,
inputs=gr.inputs.Textbox(lines=2, placeholder="Name Here..."),
inputs=gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)],
inputs=[gr.Image(label="Upload an Image", type="pil")],
outputs=[gr.Textbox(label="Text in the Image")],
title="Extrate Text From Image",
)
if __name__ == "__main__":
gradio_app.launch()