Spaces:
Runtime error
Runtime error
Moibe
commited on
Commit
•
4296c87
1
Parent(s):
372a6ba
Gallery excellent
Browse files
app.py
CHANGED
@@ -32,14 +32,6 @@ def greet(input1, input2):
|
|
32 |
|
33 |
path_video = input2
|
34 |
|
35 |
-
#Mientras tanto voy a crear un archivo de texto genérico.
|
36 |
-
filename = "hola.txt"
|
37 |
-
text = "Hola Mundo"
|
38 |
-
|
39 |
-
path_archivo = create_text_file(filename, text)
|
40 |
-
|
41 |
-
print("El path de mi archivo de texto es: ", path_archivo)
|
42 |
-
|
43 |
if plataforma == "local":
|
44 |
#Para local.
|
45 |
path_parts = path_video.split("\\")
|
@@ -47,9 +39,18 @@ def greet(input1, input2):
|
|
47 |
#Para HuggingFace
|
48 |
print("La plataforma en la que basaremos la división es HuggingFace.")
|
49 |
path_parts = path_video.split("/")
|
|
|
|
|
50 |
|
51 |
|
52 |
print("Imprimiendo path_parts: ", path_parts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
path_particular = "/".join(path_parts[0:len(path_parts) - 1])
|
54 |
path_general = "/".join(path_parts[0:len(path_parts) - 2])
|
55 |
|
@@ -61,8 +62,21 @@ def greet(input1, input2):
|
|
61 |
print("Path general: ", path_particular)
|
62 |
|
63 |
path = pathlib.Path("result.mp4")
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
print("Éste es el path foto: ", path_foto)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
files = os.listdir(path_general)
|
68 |
print("Estos son los files que hay:")
|
@@ -124,12 +138,14 @@ def greet(input1, input2):
|
|
124 |
|
125 |
if modo == "video":
|
126 |
#Para video
|
127 |
-
|
|
|
|
|
128 |
else:
|
129 |
#Para imagen
|
130 |
path = pathlib.Path("result.png")
|
131 |
print("Éste es el path para imagen:", path)
|
132 |
-
return path,
|
133 |
|
134 |
#Así para imagenes
|
135 |
# demo = gr.Interface(
|
@@ -138,7 +154,7 @@ def greet(input1, input2):
|
|
138 |
|
139 |
#Así para video
|
140 |
demo = gr.Interface(
|
141 |
-
fn=greet, inputs=[gr.Image(), gr.Video()], outputs=[gr.Video(), gr.
|
142 |
)
|
143 |
|
144 |
demo.launch()
|
|
|
32 |
|
33 |
path_video = input2
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
if plataforma == "local":
|
36 |
#Para local.
|
37 |
path_parts = path_video.split("\\")
|
|
|
39 |
#Para HuggingFace
|
40 |
print("La plataforma en la que basaremos la división es HuggingFace.")
|
41 |
path_parts = path_video.split("/")
|
42 |
+
print("Esto es parth_paths, de aquí lo puedes obtener?: ", path_parts)
|
43 |
+
time.sleep(10)
|
44 |
|
45 |
|
46 |
print("Imprimiendo path_parts: ", path_parts)
|
47 |
+
|
48 |
+
#Aquí obtendremos nom_video
|
49 |
+
filename = path_parts[-1]
|
50 |
+
nom_video = filename[:-4]
|
51 |
+
print("Esto es filename alias nom_video: ", nom_video)
|
52 |
+
time.sleep(5)
|
53 |
+
|
54 |
path_particular = "/".join(path_parts[0:len(path_parts) - 1])
|
55 |
path_general = "/".join(path_parts[0:len(path_parts) - 2])
|
56 |
|
|
|
62 |
print("Path general: ", path_particular)
|
63 |
|
64 |
path = pathlib.Path("result.mp4")
|
65 |
+
|
66 |
+
#Creación de la galería:
|
67 |
+
images = []
|
68 |
+
|
69 |
+
#nom_video = "whitebeauty"
|
70 |
+
path_foto = pathlib.Path(path_particular + "/temp/" + nom_video + "/")
|
71 |
print("Éste es el path foto: ", path_foto)
|
72 |
+
|
73 |
+
for filename in os.listdir(path_foto):
|
74 |
+
if filename.endswith(".png"):
|
75 |
+
path = os.path.join(path_foto, filename)
|
76 |
+
image = Image.open(path)
|
77 |
+
images.append(image)
|
78 |
+
|
79 |
+
print("Esto es la lista de imagenes: ", images)
|
80 |
|
81 |
files = os.listdir(path_general)
|
82 |
print("Estos son los files que hay:")
|
|
|
138 |
|
139 |
if modo == "video":
|
140 |
#Para video
|
141 |
+
path = pathlib.Path("result.mp4")
|
142 |
+
print("Éste es el path para video:", path)
|
143 |
+
return path, images
|
144 |
else:
|
145 |
#Para imagen
|
146 |
path = pathlib.Path("result.png")
|
147 |
print("Éste es el path para imagen:", path)
|
148 |
+
return path, images
|
149 |
|
150 |
#Así para imagenes
|
151 |
# demo = gr.Interface(
|
|
|
154 |
|
155 |
#Así para video
|
156 |
demo = gr.Interface(
|
157 |
+
fn=greet, inputs=[gr.Image(), gr.Video()], outputs=[gr.Video(), gr.Gallery()]
|
158 |
)
|
159 |
|
160 |
demo.launch()
|