Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
import torch.nn as nn
|
| 4 |
import torch.nn.functional as F
|
| 5 |
import math
|
| 6 |
import numpy as np
|
| 7 |
-
import os
|
| 8 |
from PIL import Image, ImageFilter
|
| 9 |
from torchvision import transforms, models
|
| 10 |
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
|
@@ -229,8 +238,11 @@ class TriStreamDetector(nn.Module):
|
|
| 229 |
|
| 230 |
def load_model():
|
| 231 |
print("Loading SigLIP backbone...")
|
|
|
|
| 232 |
siglip_base = AutoModelForImageClassification.from_pretrained(
|
| 233 |
-
|
|
|
|
|
|
|
| 234 |
)
|
| 235 |
|
| 236 |
print("Building TriStreamDetector...")
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
# ββ Force fully offline mode BEFORE any transformers import βββββββ
|
| 4 |
+
# The deployment environment has no internet access. These env vars
|
| 5 |
+
# prevent transformers / huggingface_hub from attempting any network
|
| 6 |
+
# calls (model card fetches, config resolution, token checks, etc.)
|
| 7 |
+
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
| 8 |
+
os.environ["HF_DATASETS_OFFLINE"] = "1"
|
| 9 |
+
os.environ["HF_HUB_OFFLINE"] = "1"
|
| 10 |
+
|
| 11 |
import gradio as gr
|
| 12 |
import torch
|
| 13 |
import torch.nn as nn
|
| 14 |
import torch.nn.functional as F
|
| 15 |
import math
|
| 16 |
import numpy as np
|
|
|
|
| 17 |
from PIL import Image, ImageFilter
|
| 18 |
from torchvision import transforms, models
|
| 19 |
from transformers import AutoModelForImageClassification, AutoImageProcessor
|
|
|
|
| 238 |
|
| 239 |
def load_model():
|
| 240 |
print("Loading SigLIP backbone...")
|
| 241 |
+
siglip_path = os.path.join(MODEL_PATH, "siglip_component")
|
| 242 |
siglip_base = AutoModelForImageClassification.from_pretrained(
|
| 243 |
+
siglip_path,
|
| 244 |
+
local_files_only=True,
|
| 245 |
+
ignore_mismatched_sizes=True,
|
| 246 |
)
|
| 247 |
|
| 248 |
print("Building TriStreamDetector...")
|