Spaces:
Sleeping
Sleeping
XiaoyiYangRIT
commited on
Commit
·
a6cd9f8
1
Parent(s):
62b60d1
Update some files
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import torch
|
|
3 |
import math
|
4 |
import os
|
5 |
from transformers import AutoTokenizer, AutoModel, AutoProcessor
|
|
|
6 |
from decord import VideoReader, cpu
|
7 |
from PIL import Image
|
8 |
from torchvision.transforms import Compose, Resize, ToTensor, Normalize
|
@@ -23,9 +24,10 @@ MODEL_NAME = "OpenGVLab/InternVL3-14B"
|
|
23 |
|
24 |
# 如果第一次运行:下载模型并缓存到 /data
|
25 |
if not os.path.exists(PERSISTENT_DIR):
|
26 |
-
print("
|
27 |
-
from transformers import snapshot_download
|
28 |
snapshot_download(repo_id=MODEL_NAME, local_dir=PERSISTENT_DIR, trust_remote_code=True)
|
|
|
|
|
29 |
|
30 |
# 模型加载(从本地)
|
31 |
tokenizer = AutoTokenizer.from_pretrained(PERSISTENT_DIR, trust_remote_code=True)
|
|
|
3 |
import math
|
4 |
import os
|
5 |
from transformers import AutoTokenizer, AutoModel, AutoProcessor
|
6 |
+
from huggingface_hub import snapshot_download
|
7 |
from decord import VideoReader, cpu
|
8 |
from PIL import Image
|
9 |
from torchvision.transforms import Compose, Resize, ToTensor, Normalize
|
|
|
24 |
|
25 |
# 如果第一次运行:下载模型并缓存到 /data
|
26 |
if not os.path.exists(PERSISTENT_DIR):
|
27 |
+
print("⏬ First run: downloading model to persistent storage...")
|
|
|
28 |
snapshot_download(repo_id=MODEL_NAME, local_dir=PERSISTENT_DIR, trust_remote_code=True)
|
29 |
+
else:
|
30 |
+
print("✅ Loaded model from persistent cache.")
|
31 |
|
32 |
# 模型加载(从本地)
|
33 |
tokenizer = AutoTokenizer.from_pretrained(PERSISTENT_DIR, trust_remote_code=True)
|