Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
import torch.nn as nn
|
4 |
-
import torch.serialization #
|
5 |
from torchvision import models, transforms
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
from PIL import Image
|
@@ -25,8 +25,13 @@ CONFIDENCE_THRESHOLD = 0.8 # 80%
|
|
25 |
# Mahalanobis distance threshold for OOD detection
|
26 |
MAHALANOBIS_THRESHOLD = 100.0 # Calibrate this using a validation set
|
27 |
|
28 |
-
# Allowlist
|
29 |
-
torch.serialization.add_safe_globals([
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Download model from Hugging Face
|
32 |
def download_model():
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
import torch.nn as nn
|
4 |
+
import torch.serialization # For add_safe_globals
|
5 |
from torchvision import models, transforms
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
from PIL import Image
|
|
|
25 |
# Mahalanobis distance threshold for OOD detection
|
26 |
MAHALANOBIS_THRESHOLD = 100.0 # Calibrate this using a validation set
|
27 |
|
28 |
+
# Allowlist NumPy globals for torch.load
|
29 |
+
torch.serialization.add_safe_globals([
|
30 |
+
np.ndarray,
|
31 |
+
np._core.multiarray._reconstruct,
|
32 |
+
np.dtype,
|
33 |
+
_codecs.encode
|
34 |
+
])
|
35 |
|
36 |
# Download model from Hugging Face
|
37 |
def download_model():
|