Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import pytesseract
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
# Load LLM pipeline (small model for demo)
|
7 |
+
llm = pipeline("text-generation", model="distilgpt2")
|
8 |
+
|
9 |
+
def process_image(image):
|
10 |
+
text = pytesseract.image_to_string(Image.fromarray(image))
|
11 |
+
llm_output = llm(text, max_length=100, do_sample=True)[0]["generated_text"]
|
12 |
+
return f"OCR Text:\n{text}\n\nLLM Response:\n{llm_output}"
|
13 |
+
|
14 |
+
gr.Interface(fn=process_image,
|
15 |
+
inputs=gr.Image(type="numpy"),
|
16 |
+
outputs="text",
|
17 |
+
title="OCR + LLM Text Generator").launch()
|