File size: 1,838 Bytes
1f5f680
f2c9245
ced9582
 
7310428
1f5f680
dab7f2f
5b71a2f
be713a5
e1cb6e8
 
f2c9245
 
 
 
5739d02
 
 
 
faa2cc3
410276e
 
f2c9245
410276e
faa2cc3
 
 
410276e
 
 
 
 
 
 
f2c9245
faa2cc3
 
f2c9245
7310428
 
 
 
 
 
ced9582
 
 
 
 
7310428
410276e
ced9582
7310428
ced9582
410276e
7310428
410276e
 
7310428
 
1f5f680
f1a3cbd
faa2cc3
410276e
faa2cc3
f1a3cbd
410276e
 
 
 
 
b1b5fc5
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import gradio as gr
from PIL import Image
import time
import os
import pathlib

#Greet es una función de ejemplo para usar.
def greet(input1, input2):
    print("Imprimiendo en Consola")
    print("Ésto es el input1 al día de hoy: ", input1)
    print("Ésto es el input2 al día de hoy: ", input2)

    #Aquí voy a poner como lo maneja roop en hf.
    #https://huggingface.co/spaces/ezioruan/roop/blob/main/app.py

    #Ésta es la forma correcta de guardar imagenes. 
    #Para los videos es directo. 
    #Y al parecer PIL ya lo tiene instalado.

    source_path = "input.jpg"
    target_path = "target.mp4"
    result_path = "result.mp4"

    #Para Imagenes
    source_image = Image.fromarray(input1)
    print("Esto es source_image: ", source_image)
    source_image.save(source_path)
    # target_image = Image.fromarray(input2)
    # print("Esto es target_image: ", target_image)
    # target_image.save(target_path)

    #Para Video
    #source_path = input1
    target_path = input2

    print("source_path: ", source_path)
    print("target_path: ", target_path)

    source = source_path
    target = target_path
    output = result_path

    #command =  "adios.py"
    command = f"python run.py -s {source}  -t {target} -o {output} --frame-processor face_swapper"
    print(command)
    time.sleep(1)
    proc = os.popen(command)
    output = proc.read()

    print("Estoy imprimiendo el OUTPUT:")
    time.sleep(3)
    print(output)
    print("Eso fue el output...")

    #Para imagen
    path = pathlib.Path("result.jpg")
    #Para video
    path = pathlib.Path("result.mp4")
    
    return path

#Así para imagenes
# demo = gr.Interface(
# fn=greet, inputs=[gr.Image(), gr.Image()], outputs="image"
# )

#Así para video
demo = gr.Interface(
fn=greet, inputs=[gr.Image(), gr.Video()], outputs="video"
)

demo.launch()