Spaces:
Runtime error
Runtime error
| 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() | |