SuperSecureHuman commited on
Commit
3bea50d
·
verified ·
1 Parent(s): be86b24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -63,7 +63,7 @@ def load_custom_model(model_key):
63
  # Pass model_name to config for correct model instantiation
64
  config = {"model": {"name": model_info["model_name"]}}
65
  model = XrayReg.load_from_checkpoint(model_info["ckpt"], map_location="cpu")
66
- model = model.model
67
  model.eval()
68
  for param in model.parameters():
69
  param.requires_grad = True
@@ -100,7 +100,7 @@ def predict_and_cam_custom(inp, model):
100
  # GradCAM for regression: use last conv layer, target output
101
  from pytorch_grad_cam import GradCAM
102
  from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
103
- model = model.cuda()
104
  target_layers = [
105
  layer
106
  for name, layer in model.named_modules()
@@ -156,7 +156,7 @@ def download_models():
156
  local_dir=local_dir,
157
  )
158
 
159
-
160
  def main():
161
  # Download models if not already present
162
  try:
 
63
  # Pass model_name to config for correct model instantiation
64
  config = {"model": {"name": model_info["model_name"]}}
65
  model = XrayReg.load_from_checkpoint(model_info["ckpt"], map_location="cpu")
66
+ model = model.model.cuda() if torch.cuda.is_available() else model.model
67
  model.eval()
68
  for param in model.parameters():
69
  param.requires_grad = True
 
100
  # GradCAM for regression: use last conv layer, target output
101
  from pytorch_grad_cam import GradCAM
102
  from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
103
+ # model = model.cuda()
104
  target_layers = [
105
  layer
106
  for name, layer in model.named_modules()
 
156
  local_dir=local_dir,
157
  )
158
 
159
+ @spaces.GPU
160
  def main():
161
  # Download models if not already present
162
  try: