Spaces:
Running
Running
Commit
·
7b6fb4e
1
Parent(s):
90cc7c3
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
3 |
from gtts import gTTS
|
4 |
from pydub import AudioSegment
|
5 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
6 |
from PIL import Image
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
generator = pipeline('text-generation', model="checkpoints")
|
11 |
tokenizer = GPT2Tokenizer.from_pretrained('checkpoints')
|
@@ -50,25 +54,16 @@ def error_message_fn(error_message):
|
|
50 |
return gr.outputs.Textbox(text=error_message, placeholder="Error")
|
51 |
else:
|
52 |
return None
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
image_choices = []
|
57 |
-
for image_path in image_paths:
|
58 |
-
image = Image.open(image_path)
|
59 |
-
image.thumbnail((50, 50))
|
60 |
-
image_choices.append((image_path, image))
|
61 |
-
return image_choices
|
62 |
-
|
63 |
-
def select_image(image):
|
64 |
-
return image
|
65 |
|
66 |
iface = gr.Interface(
|
67 |
-
fn=
|
68 |
inputs=[
|
69 |
-
gr.inputs.Radio(label="Selecciona una imagen:", choices=get_image_choices(), default=get_image_choices()[0]),
|
70 |
gr.inputs.Textbox(lines=1, label="Nombre", placeholder="Ingresa tu nombre"),
|
71 |
-
gr.inputs.Textbox(lines=1, label="Fecha de Nacimiento", placeholder="DD/MM/AAAA")
|
|
|
72 |
],
|
73 |
outputs=[
|
74 |
gr.outputs.Video(label="Respuesta de Andrea (un minuto aproximadamente)").style(width=256),
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
import subprocess
|
4 |
from gtts import gTTS
|
5 |
from pydub import AudioSegment
|
6 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
7 |
from PIL import Image
|
8 |
+
|
9 |
+
def get_thumbnail(image_path, width):
|
10 |
+
image = Image.open(image_path)
|
11 |
+
image.thumbnail((width, width))
|
12 |
+
return image
|
13 |
|
14 |
generator = pipeline('text-generation', model="checkpoints")
|
15 |
tokenizer = GPT2Tokenizer.from_pretrained('checkpoints')
|
|
|
54 |
return gr.outputs.Textbox(text=error_message, placeholder="Error")
|
55 |
else:
|
56 |
return None
|
57 |
+
|
58 |
+
choices = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg"]
|
59 |
+
thumbnails = [get_thumbnail(image, 50) for image in choices]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
iface = gr.Interface(
|
62 |
+
fn=generate_output,
|
63 |
inputs=[
|
|
|
64 |
gr.inputs.Textbox(lines=1, label="Nombre", placeholder="Ingresa tu nombre"),
|
65 |
+
gr.inputs.Textbox(lines=1, label="Fecha de Nacimiento", placeholder="DD/MM/AAAA"),
|
66 |
+
gr.inputs.Image(label="Selecciona una imagen:", type="file")
|
67 |
],
|
68 |
outputs=[
|
69 |
gr.outputs.Video(label="Respuesta de Andrea (un minuto aproximadamente)").style(width=256),
|