SuperSecureHuman commited on
Commit
50a9307
·
verified ·
1 Parent(s): 699e97e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -84,13 +84,12 @@ def predict_custom(model, input_tensor):
84
  return float(pred)
85
 
86
 
87
- @spaces.GPU
88
  def load_custom_model(model_key):
89
  model_info = MODEL_OPTIONS[model_key]
90
  # Pass model_name to config for correct model instantiation
91
  config = {"model": {"name": model_info["model_name"]}}
92
  model = XrayReg.load_from_checkpoint(model_info["ckpt"], map_location="cpu")
93
- model = model.model.cuda() if torch.cuda.is_available() else model.model
94
  model.eval()
95
  for param in model.parameters():
96
  param.requires_grad = True
@@ -99,6 +98,10 @@ def load_custom_model(model_key):
99
  @spaces.GPU
100
  def predict_and_cam_custom(inp, model):
101
  input_tensor, rgb_img = preprocess_image_custom(inp)
 
 
 
 
102
  value = predict_custom(model, input_tensor)
103
  # GradCAM for regression: use last conv layer, target output
104
  from pytorch_grad_cam import GradCAM
 
84
  return float(pred)
85
 
86
 
 
87
  def load_custom_model(model_key):
88
  model_info = MODEL_OPTIONS[model_key]
89
  # Pass model_name to config for correct model instantiation
90
  config = {"model": {"name": model_info["model_name"]}}
91
  model = XrayReg.load_from_checkpoint(model_info["ckpt"], map_location="cpu")
92
+ model = model.model
93
  model.eval()
94
  for param in model.parameters():
95
  param.requires_grad = True
 
98
  @spaces.GPU
99
  def predict_and_cam_custom(inp, model):
100
  input_tensor, rgb_img = preprocess_image_custom(inp)
101
+ model = model.cuda() if torch.cuda.is_available() else model.model
102
+ model.eval()
103
+ for param in model.parameters():
104
+ param.requires_grad = True
105
  value = predict_custom(model, input_tensor)
106
  # GradCAM for regression: use last conv layer, target output
107
  from pytorch_grad_cam import GradCAM