andrew3d commited on
Commit
3c768e2
Β·
verified Β·
1 Parent(s): 76ef786

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -1
app.py CHANGED
@@ -346,4 +346,39 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
346
  # Entry
347
  # ---------------------------------------------------------------------------
348
  if __name__ == "__main__":
349
- # Cache model w
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
  # Entry
347
  # ---------------------------------------------------------------------------
348
  if __name__ == "__main__":
349
+ # Cache model weights locally
350
+ cache_weights(WEIGHTS_DIR)
351
+
352
+ # Load pipeline on CPU
353
+ hi3dgen_pipeline = Hi3DGenPipeline.from_pretrained("weights/trellis-normal-v0-1")
354
+ try:
355
+ hi3dgen_pipeline.to("cpu")
356
+ except Exception:
357
+ pass # some pipelines may not implement .to
358
+
359
+ # Initialize normal predictor (CPU)
360
+ try:
361
+ normal_predictor = torch.hub.load(
362
+ os.path.join(torch.hub.get_dir(), 'hugoycj_StableNormal_main'),
363
+ "StableNormal_turbo",
364
+ yoso_version='yoso-normal-v1-8-1',
365
+ source='local',
366
+ local_cache_dir='./weights',
367
+ pretrained=True
368
+ )
369
+ except Exception:
370
+ normal_predictor = torch.hub.load(
371
+ "hugoycj/StableNormal",
372
+ "StableNormal_turbo",
373
+ trust_repo=True,
374
+ yoso_version='yoso-normal-v1-8-1',
375
+ local_cache_dir='./weights'
376
+ )
377
+
378
+ try:
379
+ normal_predictor.to("cpu")
380
+ except Exception:
381
+ pass
382
+
383
+ # Launch the Gradio app
384
+ demo.launch(share=False, server_name="0.0.0.0")