Spaces:
Sleeping
Sleeping
Ahmad Hathim bin Ahmad Azman
commited on
Commit
Β·
3674571
1
Parent(s):
f36bbe6
Fixed model loading
Browse files- app.py +0 -4
- model_inference.py +9 -1
app.py
CHANGED
|
@@ -11,10 +11,6 @@ from model_inference import load_model, predict_from_input, download_from_hf
|
|
| 11 |
# β
Redirect HuggingFace & NLTK cache
|
| 12 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf_cache"
|
| 13 |
os.environ["HF_HOME"] = "/tmp/hf_cache"
|
| 14 |
-
nltk_data_dir = "/tmp/nltk_data"
|
| 15 |
-
os.makedirs(nltk_data_dir, exist_ok=True)
|
| 16 |
-
nltk.data.path.append(nltk_data_dir)
|
| 17 |
-
os.environ["NLTK_DATA"] = nltk_data_dir
|
| 18 |
|
| 19 |
app = FastAPI(title="Question Difficulty/Discrimination Predictor")
|
| 20 |
|
|
|
|
| 11 |
# β
Redirect HuggingFace & NLTK cache
|
| 12 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf_cache"
|
| 13 |
os.environ["HF_HOME"] = "/tmp/hf_cache"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
app = FastAPI(title="Question Difficulty/Discrimination Predictor")
|
| 16 |
|
model_inference.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import numpy as np
|
| 3 |
import textstat
|
| 4 |
from utils.preprocess import compute_text_features
|
| 5 |
from model_architecture import EnsembleBertBiLSTMRegressor
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
-
import os
|
| 8 |
|
| 9 |
HF_REPO = "hathimazman/sqb-predict"
|
| 10 |
MODEL_CACHE = "/tmp/models" # β
Writable on Hugging Face Spaces
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import nltk
|
| 3 |
+
|
| 4 |
+
# β
Force NLTK to save/download in /tmp (writeable in Hugging Face Spaces)
|
| 5 |
+
nltk_data_dir = "/tmp/nltk_data"
|
| 6 |
+
os.makedirs(nltk_data_dir, exist_ok=True)
|
| 7 |
+
os.environ["NLTK_DATA"] = nltk_data_dir
|
| 8 |
+
nltk.data.path = [nltk_data_dir]
|
| 9 |
+
|
| 10 |
import torch
|
| 11 |
import numpy as np
|
| 12 |
import textstat
|
| 13 |
from utils.preprocess import compute_text_features
|
| 14 |
from model_architecture import EnsembleBertBiLSTMRegressor
|
| 15 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 16 |
|
| 17 |
HF_REPO = "hathimazman/sqb-predict"
|
| 18 |
MODEL_CACHE = "/tmp/models" # β
Writable on Hugging Face Spaces
|