Spaces:
Running
on
L40S
Running
on
L40S
Upload app_hg.py with huggingface_hub
Browse files
app_hg.py
CHANGED
@@ -30,6 +30,7 @@ import torch
|
|
30 |
import numpy as np
|
31 |
from PIL import Image
|
32 |
from einops import rearrange
|
|
|
33 |
|
34 |
from infer import seed_everything, save_gif
|
35 |
from infer import Text2Image, Removebg, Image2Views, Views2Mesh, GifRenderer
|
@@ -43,10 +44,40 @@ parser.add_argument("--use_lite", default=False, action="store_true")
|
|
43 |
parser.add_argument("--mv23d_cfg_path", default="./svrm/configs/svrm.yaml", type=str)
|
44 |
parser.add_argument("--mv23d_ckt_path", default="weights/svrm/svrm.safetensors", type=str)
|
45 |
parser.add_argument("--text2image_path", default="weights/hunyuanDiT", type=str)
|
46 |
-
parser.add_argument("--save_memory", default=
|
47 |
parser.add_argument("--device", default="cuda:0", type=str)
|
48 |
args = parser.parse_args()
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
################################################################
|
51 |
|
52 |
CONST_PORT = 8080
|
|
|
30 |
import numpy as np
|
31 |
from PIL import Image
|
32 |
from einops import rearrange
|
33 |
+
from huggingface_hub import snapshot_download
|
34 |
|
35 |
from infer import seed_everything, save_gif
|
36 |
from infer import Text2Image, Removebg, Image2Views, Views2Mesh, GifRenderer
|
|
|
44 |
parser.add_argument("--mv23d_cfg_path", default="./svrm/configs/svrm.yaml", type=str)
|
45 |
parser.add_argument("--mv23d_ckt_path", default="weights/svrm/svrm.safetensors", type=str)
|
46 |
parser.add_argument("--text2image_path", default="weights/hunyuanDiT", type=str)
|
47 |
+
parser.add_argument("--save_memory", default=True) # , action="store_true")
|
48 |
parser.add_argument("--device", default="cuda:0", type=str)
|
49 |
args = parser.parse_args()
|
50 |
|
51 |
+
def download_models():
|
52 |
+
# Create weights directory if it doesn't exist
|
53 |
+
os.makedirs("weights", exist_ok=True)
|
54 |
+
os.makedirs("weights/hunyuanDiT", exist_ok=True)
|
55 |
+
|
56 |
+
# Download Hunyuan3D-1 model
|
57 |
+
try:
|
58 |
+
snapshot_download(
|
59 |
+
repo_id="tencent/Hunyuan3D-1",
|
60 |
+
local_dir="./weights",
|
61 |
+
resume_download=True
|
62 |
+
)
|
63 |
+
print("Successfully downloaded Hunyuan3D-1 model")
|
64 |
+
except Exception as e:
|
65 |
+
print(f"Error downloading Hunyuan3D-1: {e}")
|
66 |
+
|
67 |
+
# Download HunyuanDiT model
|
68 |
+
try:
|
69 |
+
snapshot_download(
|
70 |
+
repo_id="Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled",
|
71 |
+
local_dir="./weights/hunyuanDiT",
|
72 |
+
resume_download=True
|
73 |
+
)
|
74 |
+
print("Successfully downloaded HunyuanDiT model")
|
75 |
+
except Exception as e:
|
76 |
+
print(f"Error downloading HunyuanDiT: {e}")
|
77 |
+
|
78 |
+
# Download models before starting the app
|
79 |
+
download_models()
|
80 |
+
|
81 |
################################################################
|
82 |
|
83 |
CONST_PORT = 8080
|