Haobo Yuan commited on
Commit
2fb6bea
·
1 Parent(s): 9cc3eb2

add device switcher

Browse files
Files changed (1) hide show
  1. main.py +1 -1
main.py CHANGED
@@ -36,7 +36,7 @@ examples = [
36
  ["app/assets/sa_235130.jpg"],
37
  ]
38
  model = MODELS.build(model_cfg.model)
39
- device = torch.device('cuda:0')
40
  model = model.to(device=device)
41
  model = model.eval()
42
  model.init_weights()
 
36
  ["app/assets/sa_235130.jpg"],
37
  ]
38
  model = MODELS.build(model_cfg.model)
39
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
40
  model = model.to(device=device)
41
  model = model.eval()
42
  model.init_weights()