jbilcke-hf HF Staff commited on
Commit
15e5e2d
·
1 Parent(s): 9e97556
Files changed (1) hide show
  1. app.py +63 -10
app.py CHANGED
@@ -95,16 +95,69 @@ def create_args():
95
 
96
  logger.info("Initializing Hunyuan-GameCraft model...")
97
 
98
- model_path = os.path.join(WEIGHTS_PATH, "gamecraft_models/mp_rank_00_model_states_distill.pt")
99
- if not os.path.exists(model_path):
100
- logger.info("Downloading model weights from Hugging Face...")
101
- os.makedirs(os.path.join(WEIGHTS_PATH, "gamecraft_models"), exist_ok=True)
102
- hf_hub_download(
103
- repo_id="tencent/Hunyuan-GameCraft-1.0",
104
- filename="gamecraft_models/mp_rank_00_model_states_distill.pt",
105
- local_dir=WEIGHTS_PATH,
106
- local_dir_use_symlinks=False
107
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  args = create_args()
110
  hunyuan_video_sampler = HunyuanVideoSampler.from_pretrained(
 
95
 
96
  logger.info("Initializing Hunyuan-GameCraft model...")
97
 
98
+ # Define all required model files
99
+ required_files = [
100
+ "gamecraft_models/mp_rank_00_model_states_distill.pt",
101
+ "stdmodels/vae_3d/hyvae/config.json",
102
+ "stdmodels/vae_3d/hyvae/pytorch_model.pt",
103
+ ]
104
+
105
+ # Check and download missing files
106
+ for file_path in required_files:
107
+ full_path = os.path.join(WEIGHTS_PATH, file_path)
108
+ if not os.path.exists(full_path):
109
+ logger.info(f"Downloading {file_path} from Hugging Face...")
110
+ os.makedirs(os.path.dirname(full_path), exist_ok=True)
111
+ try:
112
+ hf_hub_download(
113
+ repo_id="tencent/Hunyuan-GameCraft-1.0",
114
+ filename=file_path,
115
+ local_dir=WEIGHTS_PATH,
116
+ local_dir_use_symlinks=False
117
+ )
118
+ logger.info(f"Successfully downloaded {file_path}")
119
+ except Exception as e:
120
+ logger.error(f"Failed to download {file_path}: {e}")
121
+ raise
122
+
123
+ # Also check for text encoder files (download if needed)
124
+ text_encoder_files = [
125
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/model-00001-of-00004.safetensors",
126
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/model-00002-of-00004.safetensors",
127
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/model-00003-of-00004.safetensors",
128
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/model-00004-of-00004.safetensors",
129
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/model.safetensors.index.json",
130
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/config.json",
131
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/tokenizer.json",
132
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/tokenizer_config.json",
133
+ "stdmodels/llava-llama-3-8b-v1_1-transformers/special_tokens_map.json",
134
+ "stdmodels/openai_clip-vit-large-patch14/config.json",
135
+ "stdmodels/openai_clip-vit-large-patch14/pytorch_model.bin",
136
+ "stdmodels/openai_clip-vit-large-patch14/tokenizer.json",
137
+ "stdmodels/openai_clip-vit-large-patch14/tokenizer_config.json",
138
+ "stdmodels/openai_clip-vit-large-patch14/special_tokens_map.json",
139
+ "stdmodels/openai_clip-vit-large-patch14/vocab.json",
140
+ "stdmodels/openai_clip-vit-large-patch14/merges.txt",
141
+ ]
142
+
143
+ for file_path in text_encoder_files:
144
+ full_path = os.path.join(WEIGHTS_PATH, file_path)
145
+ if not os.path.exists(full_path):
146
+ logger.info(f"Downloading {file_path} from Hugging Face...")
147
+ os.makedirs(os.path.dirname(full_path), exist_ok=True)
148
+ try:
149
+ hf_hub_download(
150
+ repo_id="tencent/Hunyuan-GameCraft-1.0",
151
+ filename=file_path,
152
+ local_dir=WEIGHTS_PATH,
153
+ local_dir_use_symlinks=False
154
+ )
155
+ logger.info(f"Successfully downloaded {file_path}")
156
+ except Exception as e:
157
+ logger.error(f"Failed to download {file_path}: {e}")
158
+ # Continue anyway as some files might be optional
159
+
160
+ logger.info("All required model files are ready")
161
 
162
  args = create_args()
163
  hunyuan_video_sampler = HunyuanVideoSampler.from_pretrained(