Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from paddleocr import PaddleOCR | |
| import traceback | |
| def ocr_image(image): | |
| if image is None: | |
| return "Aucune image fournie" | |
| try: | |
| ocr = PaddleOCR(lang='fr') | |
| result = ocr.ocr(image) # Retrait de cls=False | |
| if not result or not result[0]: | |
| return "Aucun texte détecté" | |
| lines = [line[1][0] for line in result[0]] | |
| return "\n".join(lines) | |
| except Exception as e: | |
| return f"Erreur : {str(e)}\n\n{traceback.format_exc()}" | |
| iface = gr.Interface( | |
| fn=ocr_image, | |
| inputs=gr.Image(type="filepath", label="Téléchargez votre document"), | |
| outputs=gr.Textbox(label="Texte extrait", lines=15), | |
| title="Test PaddleOCR", | |
| description="Extraction de texte de documents administratifs sénégalais." | |
| ) | |
| iface.launch() |