drop downloading default model weights
Browse files
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=
|
| 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,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
|
| 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 |
|