Spaces:
Runtime error
Runtime error
File size: 717 Bytes
42366c4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import os
import gradio as gr
from transformers import pipeline
# قراءة التوكن من Secrets
hf_token = os.getenv("HF_TOKEN")
pipe = pipeline("image-to-text",
model="obay123/finetuned-ocr",
use_auth_token=hf_token)
def ocr_interface(image):
result = pipe(image)
return result[0]["generated_text"]
demo = gr.Interface(
fn=ocr_interface,
inputs=gr.Image(type="pil", label="📷 ارفع صورة نصية هنا"),
outputs="text",
title="OCR Finetuned Model",
description="واجهة تفاعلية: ارفع صورة نصية وسيتم استخراج النص منها"
)
if __name__ == "__main__":
demo.launch()
|