Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,35 +12,33 @@ from huggingface_hub import snapshot_download, hf_hub_download
|
|
| 12 |
import os
|
| 13 |
import shutil
|
| 14 |
|
| 15 |
-
from
|
| 16 |
-
import
|
| 17 |
-
|
| 18 |
-
import json
|
| 19 |
from pydantic import BaseModel
|
| 20 |
from fastapi.responses import JSONResponse
|
| 21 |
|
|
|
|
| 22 |
app = FastAPI()
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
filename="args.json"
|
| 34 |
-
)
|
| 35 |
|
| 36 |
-
|
| 37 |
-
args_data = json.load(f)
|
| 38 |
-
|
| 39 |
-
# Load model
|
| 40 |
-
with open("https://huggingface.co/spaces/SinaLab/wojood-api/tree/main/Nested/utils/tag_vocab.pkl", "rb") as f:
|
| 41 |
-
label_vocab = pickle.load(f)
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
BASE_DIR = os.path.expanduser("~/.sinatools")
|
| 46 |
|
|
|
|
| 12 |
import os
|
| 13 |
import shutil
|
| 14 |
|
| 15 |
+
from fastapi import FastAPI
|
| 16 |
+
from huggingface_hub import hf_hub_download
|
| 17 |
+
import os
|
|
|
|
| 18 |
from pydantic import BaseModel
|
| 19 |
from fastapi.responses import JSONResponse
|
| 20 |
|
| 21 |
+
print("Version ---- 2")
|
| 22 |
app = FastAPI()
|
| 23 |
|
| 24 |
+
def download_file_from_hf(repo_id, filename):
|
| 25 |
+
target_dir = os.path.expanduser("~/.sinatools")
|
| 26 |
+
os.makedirs(target_dir, exist_ok=True)
|
| 27 |
|
| 28 |
+
file_path = hf_hub_download(
|
| 29 |
+
repo_id=repo_id,
|
| 30 |
+
filename=filename,
|
| 31 |
+
local_dir=target_dir,
|
| 32 |
+
local_dir_use_symlinks=False
|
| 33 |
+
)
|
| 34 |
|
| 35 |
+
return file_path
|
| 36 |
|
| 37 |
+
download_file_from_hf("SinaLab/Nested-v1","args.json")
|
| 38 |
+
download_file_from_hf("SinaLab/Nested-v1","tag_vocab.pkl")
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
snapshot_download(repo_id="SinaLab/Nested", allow_patterns="checkpoints/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
|
|
|
| 42 |
|
| 43 |
BASE_DIR = os.path.expanduser("~/.sinatools")
|
| 44 |
|