Spaces:
mashroo
/
Runtime error

YoussefAnso commited on
Commit
bfac008
·
1 Parent(s): dcb102c

Ensure model components are on CPU after loading in app.py to prevent device-related issues during processing.

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -146,6 +146,13 @@ model = CRM(specs)
146
  model.load_state_dict(torch.load(crm_path, map_location="cpu"), strict=False)
147
  model = model.to(args.device)
148
 
 
 
 
 
 
 
 
149
  stage1_config = OmegaConf.load(args.stage1_config).config
150
  stage2_config = OmegaConf.load(args.stage2_config).config
151
  stage2_sampler_config = stage2_config.sampler
 
146
  model.load_state_dict(torch.load(crm_path, map_location="cpu"), strict=False)
147
  model = model.to(args.device)
148
 
149
+ # After loading or instantiating the model, ensure everything is on CPU
150
+ model = model.cpu()
151
+ if hasattr(model, 'rgbMlp'):
152
+ model.rgbMlp = model.rgbMlp.cpu()
153
+ if hasattr(model, 'decoder'):
154
+ model.decoder = model.decoder.cpu()
155
+
156
  stage1_config = OmegaConf.load(args.stage1_config).config
157
  stage2_config = OmegaConf.load(args.stage2_config).config
158
  stage2_sampler_config = stage2_config.sampler