Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,19 +5,33 @@ import os
|
|
| 5 |
import subprocess
|
| 6 |
import shutil
|
| 7 |
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
iframe_html = """
|
| 11 |
<iframe src="http://localhost:8080" width="100%" height="500" style="border:none;"></iframe>
|
| 12 |
"""
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def organize_images_into_structure(source_folder, new_folder):
|
| 23 |
os.makedirs(new_folder, exist_ok=True)
|
|
@@ -31,34 +45,38 @@ def organize_images_into_structure(source_folder, new_folder):
|
|
| 31 |
shutil.copy(source_file, destination_file)
|
| 32 |
|
| 33 |
def update_submenu(clothing_type):
|
| 34 |
-
"""Функция для динамического обновления подменю в зависимости от типа одежды."""
|
| 35 |
if clothing_type == "Top":
|
| 36 |
return (
|
| 37 |
-
gr.Dropdown
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
)
|
| 44 |
elif clothing_type == "Down":
|
| 45 |
return (
|
| 46 |
-
gr.Dropdown
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
)
|
| 50 |
elif clothing_type == "Full body":
|
| 51 |
return (
|
| 52 |
-
gr.Dropdown
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
)
|
| 56 |
else:
|
| 57 |
return (
|
| 58 |
-
gr.Dropdown
|
| 59 |
-
gr.Dropdown
|
| 60 |
)
|
| 61 |
|
|
|
|
| 62 |
with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="sm")) as demo:
|
| 63 |
front_collar = gr.State()
|
| 64 |
back_collar = gr.State()
|
|
@@ -68,6 +86,7 @@ with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="
|
|
| 68 |
# Левая колонка: рендер и кнопки
|
| 69 |
with gr.Column(scale=3):
|
| 70 |
viewer = gr.HTML(iframe_html, label="3D Рендер")
|
|
|
|
| 71 |
with gr.Row():
|
| 72 |
save_render_btn = gr.Button("Сохранить рендер")
|
| 73 |
save_obj_btn = gr.Button("Сохранить OBJ")
|
|
@@ -128,8 +147,8 @@ with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="
|
|
| 128 |
|
| 129 |
def run_smpl():
|
| 130 |
subprocess.run([
|
| 131 |
-
"python3", "
|
| 132 |
-
"--model-path", "
|
| 133 |
])
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
|
|
|
| 5 |
import subprocess
|
| 6 |
import shutil
|
| 7 |
import threading
|
| 8 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 9 |
+
import logging
|
| 10 |
+
|
| 11 |
+
logging.basicConfig(level=logging.INFO)
|
| 12 |
|
| 13 |
|
| 14 |
iframe_html = """
|
| 15 |
<iframe src="http://localhost:8080" width="100%" height="500" style="border:none;"></iframe>
|
| 16 |
"""
|
| 17 |
|
| 18 |
+
async def run_simulation(data_path, config_path):
|
| 19 |
+
proc = await asyncio.create_subprocess_exec(
|
| 20 |
+
"python3", "GarmentCode/pattern_data_sim.py",
|
| 21 |
+
"--data", data_path,
|
| 22 |
+
"--config", config_path
|
| 23 |
+
)
|
| 24 |
+
await proc.wait() # дождаться завершения процесса
|
| 25 |
+
return
|
| 26 |
|
| 27 |
+
async def run_fitting(data_path, config_path):
|
| 28 |
+
proc = await asyncio.create_subprocess_exec(
|
| 29 |
+
"python3", "GarmentCode/pattern_fitter.py",
|
| 30 |
+
"--data", data_path,
|
| 31 |
+
"--config", config_path
|
| 32 |
+
)
|
| 33 |
+
await proc.wait() # дождаться завершения процесса
|
| 34 |
+
return
|
| 35 |
|
| 36 |
def organize_images_into_structure(source_folder, new_folder):
|
| 37 |
os.makedirs(new_folder, exist_ok=True)
|
|
|
|
| 45 |
shutil.copy(source_file, destination_file)
|
| 46 |
|
| 47 |
def update_submenu(clothing_type):
|
|
|
|
| 48 |
if clothing_type == "Top":
|
| 49 |
return (
|
| 50 |
+
gr.Dropdown(visible=True, label="Front Collar",
|
| 51 |
+
choices=["CircleNeckHalf", "CurvyNeckHalf", "VNeckHalf", "SquareNeckHalf",
|
| 52 |
+
"TrapezoidNeckHalf", "CircleArcNeckHalf", "Bezier2NeckHalf"],
|
| 53 |
+
interactive=True),
|
| 54 |
+
gr.Dropdown(visible=True, label="Back Collar",
|
| 55 |
+
choices=["CircleNeckHalf", "CurvyNeckHalf", "VNeckHalf", "SquareNeckHalf",
|
| 56 |
+
"TrapezoidNeckHalf", "CircleArcNeckHalf", "Bezier2NeckHalf"],
|
| 57 |
+
interactive=True)
|
| 58 |
)
|
| 59 |
elif clothing_type == "Down":
|
| 60 |
return (
|
| 61 |
+
gr.Dropdown(visible=True, label="Waist Style",
|
| 62 |
+
choices=["High Waist", "Low Waist", "Medium Waist"],
|
| 63 |
+
interactive=True),
|
| 64 |
+
gr.Dropdown(visible=False, interactive=True)
|
| 65 |
)
|
| 66 |
elif clothing_type == "Full body":
|
| 67 |
return (
|
| 68 |
+
gr.Dropdown(visible=True, label="Overall Style",
|
| 69 |
+
choices=["Slim Fit", "Loose Fit", "Regular Fit"],
|
| 70 |
+
interactive=True),
|
| 71 |
+
gr.Dropdown(visible=False, interactive=True)
|
| 72 |
)
|
| 73 |
else:
|
| 74 |
return (
|
| 75 |
+
gr.Dropdown(visible=False, interactive=True),
|
| 76 |
+
gr.Dropdown(visible=False, interactive=True)
|
| 77 |
)
|
| 78 |
|
| 79 |
+
|
| 80 |
with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="sm")) as demo:
|
| 81 |
front_collar = gr.State()
|
| 82 |
back_collar = gr.State()
|
|
|
|
| 86 |
# Левая колонка: рендер и кнопки
|
| 87 |
with gr.Column(scale=3):
|
| 88 |
viewer = gr.HTML(iframe_html, label="3D Рендер")
|
| 89 |
+
start_sim = gr.Button("Запустить симуляцию",variant="primary",scale=2)
|
| 90 |
with gr.Row():
|
| 91 |
save_render_btn = gr.Button("Сохранить рендер")
|
| 92 |
save_obj_btn = gr.Button("Сохранить OBJ")
|
|
|
|
| 147 |
|
| 148 |
def run_smpl():
|
| 149 |
subprocess.run([
|
| 150 |
+
"python3", "smpl_visualizer.py",
|
| 151 |
+
"--model-path", "/Users/user/Downloads/SMPL/SMPL_julia/SMPL_FEMALE.npz"
|
| 152 |
])
|
| 153 |
|
| 154 |
if __name__ == "__main__":
|