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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -58,16 +58,7 @@ def preprocess_image(inp):
58
  raise
59
 
60
 
61
- def load_custom_model(model_key):
62
- model_info = MODEL_OPTIONS[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.cuda() if torch.cuda.is_available() else model.model
67
- model.eval()
68
- for param in model.parameters():
69
- param.requires_grad = True
70
- return model
71
 
72
 
73
  def preprocess_image_custom(inp):
@@ -93,6 +84,18 @@ def predict_custom(model, input_tensor):
93
  return float(pred)
94
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  @spaces.GPU
97
  def predict_and_cam_custom(inp, model):
98
  input_tensor, rgb_img = preprocess_image_custom(inp)
 
58
  raise
59
 
60
 
61
+
 
 
 
 
 
 
 
 
 
62
 
63
 
64
  def preprocess_image_custom(inp):
 
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
97
+ return model
98
+
99
  @spaces.GPU
100
  def predict_and_cam_custom(inp, model):
101
  input_tensor, rgb_img = preprocess_image_custom(inp)