Update app.py
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ NUM_CLASSES = 2
|
|
| 29 |
CLASS_NAMES = ["Elliptical", "Spiral"]
|
| 30 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 31 |
|
| 32 |
-
#
|
| 33 |
TEMPERATURE = 2.5 # softens overconfidence
|
| 34 |
CONF_THRESHOLD = 0.60 # below this → uncertain
|
| 35 |
ENTROPY_THRESHOLD = 0.85 # high entropy → uncertain
|
|
@@ -52,7 +52,7 @@ def load_model():
|
|
| 52 |
if os.path.exists(MODEL_PATH):
|
| 53 |
try:
|
| 54 |
state_dict = torch.load(MODEL_PATH, map_location=DEVICE)
|
| 55 |
-
model.load_state_dict((torch.load(MODEL_PATH, map_location=DEVICE))
|
| 56 |
print(f"Model loaded successfully from {MODEL_PATH}")
|
| 57 |
except Exception as e:
|
| 58 |
print(f"Error loading model: {e}")
|
|
|
|
| 29 |
CLASS_NAMES = ["Elliptical", "Spiral"]
|
| 30 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 31 |
|
| 32 |
+
# Calibration + OOD thresholds
|
| 33 |
TEMPERATURE = 2.5 # softens overconfidence
|
| 34 |
CONF_THRESHOLD = 0.60 # below this → uncertain
|
| 35 |
ENTROPY_THRESHOLD = 0.85 # high entropy → uncertain
|
|
|
|
| 52 |
if os.path.exists(MODEL_PATH):
|
| 53 |
try:
|
| 54 |
state_dict = torch.load(MODEL_PATH, map_location=DEVICE)
|
| 55 |
+
model.load_state_dict((torch.load(MODEL_PATH, map_location=DEVICE)))
|
| 56 |
print(f"Model loaded successfully from {MODEL_PATH}")
|
| 57 |
except Exception as e:
|
| 58 |
print(f"Error loading model: {e}")
|