Spaces:
Runtime error
Runtime error
File size: 896 Bytes
1544649 ffb36e0 1544649 ffb36e0 |
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 27 28 29 30 31 32 33 34 35 36 |
import os
import gradio as gr
import requests
# Ortam değişkeninden token'ı oku
HF_TOKEN = os.environ.get("HF_TOKEN")
API_URL = "https://api-inference.huggingface.co/models/swttech/GeovinciOCRTR"
HEADERS = {
"Authorization": f"Bearer {HF_TOKEN}",
"Content-Type": "application/octet-stream"
}
def ocr_model(image):
if image is None:
return "Lütfen bir resim yükleyin."
image_bytes = image.read()
response = requests.post(API_URL, headers=HEADERS, data=image_bytes)
if response.status_code == 200:
return response.json()
else:
return f"Hata: {response.status_code}, {response.text}"
demo = gr.Interface(
fn=ocr_model,
inputs=gr.Image(type="file"),
outputs="text",
title="Geovinci OCR Modeli",
description="Bu model, yüklediğiniz resimdeki metni algılar."
)
if __name__ == "__main__":
demo.launch()
|