Spaces:
Runtime error
Runtime error
Update app.py (#6)
Browse files- Update app.py (93fff84a1c1009e353e918ccdcd7c5bc78744732)
Co-authored-by: Kattamuri Tejo Vardhan <tejovk311@users.noreply.huggingface.co>
app.py
CHANGED
@@ -7,12 +7,10 @@ import cv2
|
|
7 |
import tempfile
|
8 |
import shutil
|
9 |
import logging
|
10 |
-
os.environ["HF_HOME"] = "/cache"
|
11 |
-
os.environ["TRANSFORMERS_CACHE"]= "/cache"
|
12 |
-
os.environ["HF_DATASETS_CACHE"] = "/cache"
|
13 |
from transformers import VideoMAEForVideoClassification, VideoMAEImageProcessor
|
14 |
from PIL import Image
|
15 |
from torchvision.transforms import Compose, Resize, ToTensor
|
|
|
16 |
|
17 |
app = Flask(__name__)
|
18 |
# Configure logging
|
@@ -31,7 +29,7 @@ def load_model():
|
|
31 |
if model is None:
|
32 |
model_name = "OPear/videomae-large-finetuned-UCF-Crime"
|
33 |
logger.info(f"Loading model {model_name} on {device}...")
|
34 |
-
model = VideoMAEForVideoClassification.from_pretrained(
|
35 |
processor = VideoMAEImageProcessor.from_pretrained(model_name)
|
36 |
transform = Compose([
|
37 |
Resize((224, 224)),
|
|
|
7 |
import tempfile
|
8 |
import shutil
|
9 |
import logging
|
|
|
|
|
|
|
10 |
from transformers import VideoMAEForVideoClassification, VideoMAEImageProcessor
|
11 |
from PIL import Image
|
12 |
from torchvision.transforms import Compose, Resize, ToTensor
|
13 |
+
os.makedirs("./.cache", exist_ok=True)
|
14 |
|
15 |
app = Flask(__name__)
|
16 |
# Configure logging
|
|
|
29 |
if model is None:
|
30 |
model_name = "OPear/videomae-large-finetuned-UCF-Crime"
|
31 |
logger.info(f"Loading model {model_name} on {device}...")
|
32 |
+
model = VideoMAEForVideoClassification.from_pretrained("OPear/videomae-large-finetuned-UCF-Crime",cache_dir="./.cache").to(device)
|
33 |
processor = VideoMAEImageProcessor.from_pretrained(model_name)
|
34 |
transform = Compose([
|
35 |
Resize((224, 224)),
|