File size: 641 Bytes
9a1ef90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from transformers import pipeline
text= pipeline("image-to-text")

import gradio as gr
from PIL import Image
import pytesseract

def image_to_text(image):
    # Convertir l'image en texte en utilisant pytesseract
    text = pytesseract.image_to_string(Image.open(image.name))
    return text

# Interface Gradio
inputs = gr.Image(label="Sélectionnez une image")
outputs = gr.Textbox(label="Texte extrait")

interface = gr.Interface(
    fn=image_to_text,
    inputs=inputs,
    outputs=outputs,
    title="Image vers Texte",
    description="Téléchargez une image et cliquez sur 'Soumettre' pour extraire le texte.",
)

interface.launch()