Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
text= pipeline("image-to-text")
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
from PIL import Image
|
| 6 |
+
import pytesseract
|
| 7 |
+
|
| 8 |
+
def image_to_text(image):
|
| 9 |
+
# Convertir l'image en texte en utilisant pytesseract
|
| 10 |
+
text = pytesseract.image_to_string(Image.open(image.name))
|
| 11 |
+
return text
|
| 12 |
+
|
| 13 |
+
# Interface Gradio
|
| 14 |
+
inputs = gr.Image(label="Sélectionnez une image")
|
| 15 |
+
outputs = gr.Textbox(label="Texte extrait")
|
| 16 |
+
|
| 17 |
+
interface = gr.Interface(
|
| 18 |
+
fn=image_to_text,
|
| 19 |
+
inputs=inputs,
|
| 20 |
+
outputs=outputs,
|
| 21 |
+
title="Image vers Texte",
|
| 22 |
+
description="Téléchargez une image et cliquez sur 'Soumettre' pour extraire le texte.",
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
interface.launch()
|