Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,6 @@ import torch
|
|
| 6 |
# el resultado del primero modelo(texto generado) en la entrada del 2潞 modelo
|
| 7 |
# texto to audio
|
| 8 |
|
| 9 |
-
def transform(example_batch):
|
| 10 |
-
# Take a list of PIL images and turn them to pixel values
|
| 11 |
-
inputs = feature_extractor([x.convert("RGB") for x in example_batch['image']], return_tensors='pt')
|
| 12 |
-
|
| 13 |
-
# Don't forget to include the labels!
|
| 14 |
-
inputs['labels'] = example_batch['labels']
|
| 15 |
-
return inputs
|
| 16 |
|
| 17 |
# Cargar el modelo que convierte imagen a texto
|
| 18 |
image_to_text_model = pipeline("image-classification")
|
|
@@ -23,7 +16,7 @@ text_to_audio_model = pipeline("text-to-speech")
|
|
| 23 |
# Funci贸n para la interfaz de Gradio
|
| 24 |
def image_to_audio(input_image):
|
| 25 |
# Convertir la imagen a texto
|
| 26 |
-
text_output =
|
| 27 |
|
| 28 |
# Generar audio a partir del texto
|
| 29 |
audio_output = text_to_audio_model(text_output)[0]['audio']
|
|
@@ -34,7 +27,7 @@ def image_to_audio(input_image):
|
|
| 34 |
# Interfaz Gradio
|
| 35 |
iface = gr.Interface(
|
| 36 |
fn=image_to_audio,
|
| 37 |
-
inputs=gr.Image(),
|
| 38 |
outputs="audio",
|
| 39 |
live=True,
|
| 40 |
interpretation="default",
|
|
|
|
| 6 |
# el resultado del primero modelo(texto generado) en la entrada del 2潞 modelo
|
| 7 |
# texto to audio
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Cargar el modelo que convierte imagen a texto
|
| 11 |
image_to_text_model = pipeline("image-classification")
|
|
|
|
| 16 |
# Funci贸n para la interfaz de Gradio
|
| 17 |
def image_to_audio(input_image):
|
| 18 |
# Convertir la imagen a texto
|
| 19 |
+
text_output = image_to_text_model(input_image)[0]['label']
|
| 20 |
|
| 21 |
# Generar audio a partir del texto
|
| 22 |
audio_output = text_to_audio_model(text_output)[0]['audio']
|
|
|
|
| 27 |
# Interfaz Gradio
|
| 28 |
iface = gr.Interface(
|
| 29 |
fn=image_to_audio,
|
| 30 |
+
inputs= gr.Image(type="pil"),
|
| 31 |
outputs="audio",
|
| 32 |
live=True,
|
| 33 |
interpretation="default",
|