samfhy commited on
Commit
b6ab652
·
verified ·
1 Parent(s): 8732376

drop downloading default model weights

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -91,12 +91,12 @@ tta_transform = v2.Compose([
91
  v2.Normalize(mean=[0.6007, 0.5679, 0.5206], std=[0.2411, 0.2392, 0.2479])
92
  ])
93
 
94
- efficientnet = models.efficientnet_v2_l(weights='EfficientNet_V2_L_Weights.DEFAULT')
95
  efficientnet.classifier = new_layers
96
  efficientnet.load_state_dict(checkpoint['model_state_dict'])
97
  efficientnet.to(device).eval()
98
 
99
- def predict(img, use_optimized_threshold):
100
  if img is None:
101
  return {}
102
  img = img.convert('RGB')
@@ -113,7 +113,7 @@ def predict(img, use_optimized_threshold):
113
 
114
  prediction_dict = {}
115
  for i, label in enumerate(labels):
116
- thresh = optimal_thresholds.get(label, 0.5) if use_optimized_threshold else 0.5
117
  if predicted_probs[i] >= thresh:
118
  prediction_dict[label] = predicted_probs[i]
119
 
 
91
  v2.Normalize(mean=[0.6007, 0.5679, 0.5206], std=[0.2411, 0.2392, 0.2479])
92
  ])
93
 
94
+ efficientnet = models.efficientnet_v2_l(weights=None)
95
  efficientnet.classifier = new_layers
96
  efficientnet.load_state_dict(checkpoint['model_state_dict'])
97
  efficientnet.to(device).eval()
98
 
99
+ def predict(img):
100
  if img is None:
101
  return {}
102
  img = img.convert('RGB')
 
113
 
114
  prediction_dict = {}
115
  for i, label in enumerate(labels):
116
+ thresh = optimal_thresholds.get(label, 0.5) if USE_OPTIMIZED_THRESHOLD else 0.5
117
  if predicted_probs[i] >= thresh:
118
  prediction_dict[label] = predicted_probs[i]
119