Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -191,7 +191,7 @@ def reordenar_sentenca(sentenca):
|
|
| 191 |
sentenca_normalizada = ""
|
| 192 |
for i in range(len(frase)):
|
| 193 |
sentenca_normalizada += frase[i] + " "
|
| 194 |
-
return sentenca_normalizada.strip()
|
| 195 |
|
| 196 |
# Carregar os modelos
|
| 197 |
processor = AutoProcessor.from_pretrained("histlearn/microsoft-git-portuguese-neuro-simbolic")
|
|
@@ -228,21 +228,21 @@ def text_to_speech_gtts(text, lang='pt'):
|
|
| 228 |
def process_image(image):
|
| 229 |
_, pixel_values = prepare_image(image)
|
| 230 |
caption_pt = generate_caption(pixel_values)
|
| 231 |
-
caption_pt = reordenar_sentenca(caption_pt)
|
| 232 |
audio_file = text_to_speech_gtts(caption_pt)
|
| 233 |
-
|
|
|
|
| 234 |
|
| 235 |
# Caminhos para as imagens de exemplo
|
| 236 |
example_image_paths = [
|
| 237 |
-
|
| 238 |
-
|
| 239 |
]
|
| 240 |
|
| 241 |
# Interface Gradio
|
| 242 |
iface = gr.Interface(
|
| 243 |
fn=process_image,
|
| 244 |
inputs=gr.Image(type="filepath"),
|
| 245 |
-
outputs=[gr.Textbox(), gr.Audio(type="filepath")],
|
| 246 |
examples=example_image_paths,
|
| 247 |
title="Image to Voice",
|
| 248 |
description="Gera uma descrição em português e a converte em voz a partir de uma imagem."
|
|
|
|
| 191 |
sentenca_normalizada = ""
|
| 192 |
for i in range(len(frase)):
|
| 193 |
sentenca_normalizada += frase[i] + " "
|
| 194 |
+
return sentenca_normalizada.strip(), tags
|
| 195 |
|
| 196 |
# Carregar os modelos
|
| 197 |
processor = AutoProcessor.from_pretrained("histlearn/microsoft-git-portuguese-neuro-simbolic")
|
|
|
|
| 228 |
def process_image(image):
|
| 229 |
_, pixel_values = prepare_image(image)
|
| 230 |
caption_pt = generate_caption(pixel_values)
|
| 231 |
+
caption_pt, tags = reordenar_sentenca(caption_pt)
|
| 232 |
audio_file = text_to_speech_gtts(caption_pt)
|
| 233 |
+
tags_text = " | ".join(tags)
|
| 234 |
+
return caption_pt, tags_text, audio_file
|
| 235 |
|
| 236 |
# Caminhos para as imagens de exemplo
|
| 237 |
example_image_paths = [
|
| 238 |
+
"./example2.jpeg"
|
|
|
|
| 239 |
]
|
| 240 |
|
| 241 |
# Interface Gradio
|
| 242 |
iface = gr.Interface(
|
| 243 |
fn=process_image,
|
| 244 |
inputs=gr.Image(type="filepath"),
|
| 245 |
+
outputs=[gr.Textbox(label="Caption"), gr.Textbox(label="Morphological Analysis"), gr.Audio(type="filepath")],
|
| 246 |
examples=example_image_paths,
|
| 247 |
title="Image to Voice",
|
| 248 |
description="Gera uma descrição em português e a converte em voz a partir de uma imagem."
|