Spaces:
Build error
Build error
Moibe
commited on
Commit
路
8e363d1
1
Parent(s):
52e1485
Zip Perfect!
Browse files- .gitignore +1 -0
- app.py +36 -20
.gitignore
CHANGED
|
@@ -5,6 +5,7 @@ target.png
|
|
| 5 |
result.jpg
|
| 6 |
result.png
|
| 7 |
result.mp4
|
|
|
|
| 8 |
|
| 9 |
inswapper_128.onnx
|
| 10 |
|
|
|
|
| 5 |
result.jpg
|
| 6 |
result.png
|
| 7 |
result.mp4
|
| 8 |
+
*.zip
|
| 9 |
|
| 10 |
inswapper_128.onnx
|
| 11 |
|
app.py
CHANGED
|
@@ -3,16 +3,23 @@ from PIL import Image
|
|
| 3 |
import time
|
| 4 |
import os
|
| 5 |
import pathlib
|
|
|
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
|
| 9 |
-
with open(filename, "w") as f:
|
| 10 |
-
f.write(text)
|
| 11 |
-
|
| 12 |
-
path_archivo = pathlib.Path(filename)
|
| 13 |
-
|
| 14 |
-
return path_archivo
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def greet(input1, input2):
|
| 18 |
|
|
@@ -62,15 +69,6 @@ def greet(input1, input2):
|
|
| 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 |
-
print("Esto es la lista de imagenes: ", images)
|
| 74 |
|
| 75 |
files = os.listdir(path_general)
|
| 76 |
print("Estos son los files que hay:")
|
|
@@ -125,27 +123,45 @@ def greet(input1, input2):
|
|
| 125 |
print(output)
|
| 126 |
print("Termin贸 la impresi贸n del output...")
|
| 127 |
|
|
|
|
|
|
|
|
|
|
| 128 |
print("Ahora estamos imprimiendo las rutas para ver si apareci贸 una nueva:")
|
| 129 |
files = os.listdir(path_general)
|
| 130 |
print("Estos son los files que hay:")
|
| 131 |
print(files)
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
for filename in os.listdir(path_foto):
|
| 134 |
if filename.endswith(".png"):
|
| 135 |
path = os.path.join(path_foto, filename)
|
| 136 |
image = Image.open(path)
|
| 137 |
images.append(image)
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
if modo == "video":
|
| 140 |
#Para video
|
| 141 |
path = pathlib.Path("result.mp4")
|
|
|
|
| 142 |
print("脡ste es el path para video:", path)
|
| 143 |
-
|
|
|
|
| 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,7 +170,7 @@ def greet(input1, input2):
|
|
| 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()
|
|
|
|
| 3 |
import time
|
| 4 |
import os
|
| 5 |
import pathlib
|
| 6 |
+
import zipfile36 as zipfile
|
| 7 |
|
| 8 |
+
def save_images_as_zip(path_foto, filename):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
print("Entr茅 a la funci贸n que hace los zips...")
|
| 11 |
+
time.sleep(1)
|
| 12 |
+
|
| 13 |
+
with zipfile.ZipFile(filename, "w") as zip_file:
|
| 14 |
+
for foto in os.listdir(path_foto):
|
| 15 |
+
print("La foto en os.listdir es: ", foto)
|
| 16 |
+
path_foto_zippable = str(path_foto) + "\\" + foto
|
| 17 |
+
print("La ruta textual final de esa foto en particular es: ", path_foto_zippable)
|
| 18 |
+
time.sleep(1)
|
| 19 |
+
# ruta = pathlib.Path(path_foto_zippable)
|
| 20 |
+
# zip_file.write(ruta)
|
| 21 |
+
ruta = os.path.basename(path_foto_zippable)
|
| 22 |
+
zip_file.write(path_foto_zippable, ruta)
|
| 23 |
|
| 24 |
def greet(input1, input2):
|
| 25 |
|
|
|
|
| 69 |
print("Path general: ", path_particular)
|
| 70 |
|
| 71 |
path = pathlib.Path("result.mp4")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
files = os.listdir(path_general)
|
| 74 |
print("Estos son los files que hay:")
|
|
|
|
| 123 |
print(output)
|
| 124 |
print("Termin贸 la impresi贸n del output...")
|
| 125 |
|
| 126 |
+
print("脡ste es el momento en el que se creo result, revisar...")
|
| 127 |
+
time.sleep(10)
|
| 128 |
+
|
| 129 |
print("Ahora estamos imprimiendo las rutas para ver si apareci贸 una nueva:")
|
| 130 |
files = os.listdir(path_general)
|
| 131 |
print("Estos son los files que hay:")
|
| 132 |
print(files)
|
| 133 |
|
| 134 |
+
#Creaci贸n de la galer铆a:
|
| 135 |
+
images = []
|
| 136 |
+
|
| 137 |
+
#nom_video = "whitebeauty"
|
| 138 |
+
path_foto = pathlib.Path(path_particular + "/temp/" + nom_video + "/")
|
| 139 |
+
print("脡ste es el path foto: ", path_foto)
|
| 140 |
+
|
| 141 |
for filename in os.listdir(path_foto):
|
| 142 |
if filename.endswith(".png"):
|
| 143 |
path = os.path.join(path_foto, filename)
|
| 144 |
image = Image.open(path)
|
| 145 |
images.append(image)
|
| 146 |
|
| 147 |
+
print("Esto es la lista de imagenes: ", images)
|
| 148 |
+
|
| 149 |
+
nombre_zip = nom_video + ".zip"
|
| 150 |
+
print("El nombre del zip ser谩: ", nombre_zip)
|
| 151 |
+
save_images_as_zip(path_foto, nombre_zip)
|
| 152 |
+
|
| 153 |
if modo == "video":
|
| 154 |
#Para video
|
| 155 |
path = pathlib.Path("result.mp4")
|
| 156 |
+
path_zip = pathlib.Path(nombre_zip)
|
| 157 |
print("脡ste es el path para video:", path)
|
| 158 |
+
print("Y 茅ste es el path para el zip: ", path_zip)
|
| 159 |
+
return path, images, nombre_zip
|
| 160 |
else:
|
| 161 |
#Para imagen
|
| 162 |
path = pathlib.Path("result.png")
|
| 163 |
print("脡ste es el path para imagen:", path)
|
| 164 |
+
return path, images, images
|
| 165 |
|
| 166 |
#As铆 para imagenes
|
| 167 |
# demo = gr.Interface(
|
|
|
|
| 170 |
|
| 171 |
#As铆 para video
|
| 172 |
demo = gr.Interface(
|
| 173 |
+
fn=greet, inputs=[gr.Image(), gr.Video()], outputs=[gr.Video(), gr.Gallery(), gr.File()]
|
| 174 |
)
|
| 175 |
|
| 176 |
demo.launch()
|