Spaces:
Sleeping
Sleeping
Commit
路
36ee8a9
1
Parent(s):
e150f2a
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from gtts import gTTS
|
|
5 |
from pydub import AudioSegment
|
6 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
7 |
from PIL import Image
|
|
|
8 |
|
9 |
generator = pipeline('text-generation', model="checkpoints")
|
10 |
tokenizer = GPT2Tokenizer.from_pretrained('checkpoints')
|
@@ -31,7 +32,7 @@ def generate_output(image, name, date_of_birth):
|
|
31 |
except Exception as e:
|
32 |
return None, f"No se pudo generar el audio: {str(e)}"
|
33 |
|
34 |
-
command = f"python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face {image} --audio audio.wav --outfile video.mp4 --nosmooth"
|
35 |
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
36 |
if process.returncode != 0:
|
37 |
error_message = process.stderr.decode("utf-8")
|
@@ -50,16 +51,10 @@ def error_message_fn(error_message):
|
|
50 |
else:
|
51 |
return None
|
52 |
|
53 |
-
def get_image_options():
|
54 |
-
image_options = []
|
55 |
-
for i in range(1, 7):
|
56 |
-
image_options.append({"value": f"{i}.jpg", "label": f"Imagen {i}"})
|
57 |
-
return image_options
|
58 |
-
|
59 |
iface = gr.Interface(
|
60 |
fn=generate_output,
|
61 |
inputs=[
|
62 |
-
gr.inputs.
|
63 |
gr.inputs.Textbox(lines=1, label="Nombre", placeholder="Ingresa tu nombre"),
|
64 |
gr.inputs.Textbox(lines=1, label="Fecha de Nacimiento", placeholder="DD/MM/AAAA")
|
65 |
],
|
|
|
5 |
from pydub import AudioSegment
|
6 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, pipeline
|
7 |
from PIL import Image
|
8 |
+
import random
|
9 |
|
10 |
generator = pipeline('text-generation', model="checkpoints")
|
11 |
tokenizer = GPT2Tokenizer.from_pretrained('checkpoints')
|
|
|
32 |
except Exception as e:
|
33 |
return None, f"No se pudo generar el audio: {str(e)}"
|
34 |
|
35 |
+
command = f"python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face {image.name} --audio audio.wav --outfile video.mp4 --nosmooth"
|
36 |
process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
37 |
if process.returncode != 0:
|
38 |
error_message = process.stderr.decode("utf-8")
|
|
|
51 |
else:
|
52 |
return None
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
iface = gr.Interface(
|
55 |
fn=generate_output,
|
56 |
inputs=[
|
57 |
+
gr.inputs.Image(label="Imagen", type="file"),
|
58 |
gr.inputs.Textbox(lines=1, label="Nombre", placeholder="Ingresa tu nombre"),
|
59 |
gr.inputs.Textbox(lines=1, label="Fecha de Nacimiento", placeholder="DD/MM/AAAA")
|
60 |
],
|