Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,10 +15,15 @@ logging.basicConfig(
|
|
15 |
logger = logging.getLogger(__name__)
|
16 |
|
17 |
# Set Hugging Face cache directory to a writable path
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
# Create cache
|
21 |
-
os.makedirs('/tmp
|
|
|
|
|
22 |
|
23 |
# Global variable for the model
|
24 |
pipe = None
|
@@ -30,7 +35,8 @@ def load_model():
|
|
30 |
logger.info("Loading Zero123Plus model...")
|
31 |
pipe = DiffusionPipeline.from_pretrained(
|
32 |
"sudo-ai/zero123plus-v1.2",
|
33 |
-
torch_dtype=torch.float32
|
|
|
34 |
)
|
35 |
pipe.to("cpu")
|
36 |
logger.info("Model loaded successfully")
|
|
|
15 |
logger = logging.getLogger(__name__)
|
16 |
|
17 |
# Set Hugging Face cache directory to a writable path
|
18 |
+
# Make sure to set this BEFORE importing or initializing any models
|
19 |
+
os.environ['TRANSFORMERS_CACHE'] = '/tmp/transformers_cache'
|
20 |
+
os.environ['HF_HOME'] = '/tmp/hf_home'
|
21 |
+
os.environ['XDG_CACHE_HOME'] = '/tmp/cache'
|
22 |
|
23 |
+
# Create cache directories if they don't exist
|
24 |
+
os.makedirs('/tmp/transformers_cache', exist_ok=True)
|
25 |
+
os.makedirs('/tmp/hf_home', exist_ok=True)
|
26 |
+
os.makedirs('/tmp/cache', exist_ok=True)
|
27 |
|
28 |
# Global variable for the model
|
29 |
pipe = None
|
|
|
35 |
logger.info("Loading Zero123Plus model...")
|
36 |
pipe = DiffusionPipeline.from_pretrained(
|
37 |
"sudo-ai/zero123plus-v1.2",
|
38 |
+
torch_dtype=torch.float32,
|
39 |
+
cache_dir="/tmp/diffusers_cache"
|
40 |
)
|
41 |
pipe.to("cpu")
|
42 |
logger.info("Model loaded successfully")
|