Spaces:
Sleeping
Sleeping
alethanhson
commited on
Commit
·
0728e3f
1
Parent(s):
9a2c58a
fix model
Browse files
app.py
CHANGED
@@ -58,7 +58,39 @@ async def startup_event():
|
|
58 |
logger.warning("GPU not available. Using CPU, performance may be slow!")
|
59 |
|
60 |
try:
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
logger.info(f"Model loaded successfully on device: {device}")
|
63 |
except Exception as e:
|
64 |
logger.error(f"Could not load model: {str(e)}")
|
|
|
58 |
logger.warning("GPU not available. Using CPU, performance may be slow!")
|
59 |
|
60 |
try:
|
61 |
+
# Try to load the model with more information for debugging
|
62 |
+
logger.info("Attempting to load CSM 1B model...")
|
63 |
+
|
64 |
+
# Import extra tools that might be needed
|
65 |
+
from huggingface_hub import hf_hub_download
|
66 |
+
import json
|
67 |
+
import os
|
68 |
+
|
69 |
+
# Try to use an alternative loading method if the direct method fails
|
70 |
+
try:
|
71 |
+
# First attempt with default loading
|
72 |
+
generator = load_csm_1b(device=device)
|
73 |
+
except TypeError as e:
|
74 |
+
if "missing 1 required positional argument: 'config'" in str(e):
|
75 |
+
logger.info("Model requires config. Attempting to load with configuration...")
|
76 |
+
|
77 |
+
# Try to load the configuration first
|
78 |
+
try:
|
79 |
+
# The model_path can be model_id or path
|
80 |
+
model_id = "sesame/csm-1b"
|
81 |
+
# Try to download and load the config
|
82 |
+
config_file = hf_hub_download(repo_id=model_id, filename="config.json")
|
83 |
+
with open(config_file, 'r') as f:
|
84 |
+
config = json.load(f)
|
85 |
+
|
86 |
+
# Now try loading with config
|
87 |
+
generator = load_csm_1b(device=device, config=config)
|
88 |
+
except Exception as config_error:
|
89 |
+
logger.error(f"Failed to load configuration: {str(config_error)}")
|
90 |
+
raise
|
91 |
+
else:
|
92 |
+
raise
|
93 |
+
|
94 |
logger.info(f"Model loaded successfully on device: {device}")
|
95 |
except Exception as e:
|
96 |
logger.error(f"Could not load model: {str(e)}")
|