Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,7 @@ import pickle
|
|
| 14 |
import torch
|
| 15 |
from transformers import BertModel, BertTokenizer
|
| 16 |
from model import PredictModel
|
|
|
|
| 17 |
|
| 18 |
# Import your local helper files
|
| 19 |
# (These must be uploaded to the same folder as app.py)
|
|
@@ -25,9 +26,17 @@ SEEDS = [2023, 2024, 2025]
|
|
| 25 |
TASK = 'PDC'
|
| 26 |
|
| 27 |
# --- 3. LOAD PROTBERT (The "Brain" for Peptides) ---
|
| 28 |
-
print("📦 Downloading
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Move to CPU (Hugging Face Free Tier is CPU-only usually)
|
| 33 |
bert_model.eval()
|
|
|
|
| 14 |
import torch
|
| 15 |
from transformers import BertModel, BertTokenizer
|
| 16 |
from model import PredictModel
|
| 17 |
+
from huggingface_hub import snapshot_download
|
| 18 |
|
| 19 |
# Import your local helper files
|
| 20 |
# (These must be uploaded to the same folder as app.py)
|
|
|
|
| 26 |
TASK = 'PDC'
|
| 27 |
|
| 28 |
# --- 3. LOAD PROTBERT (The "Brain" for Peptides) ---
|
| 29 |
+
print("📦 Downloading ProtBERT Model safely...")
|
| 30 |
+
|
| 31 |
+
# SMART DOWNLOAD: Only download the PyTorch files (skips the huge TensorFlow file)
|
| 32 |
+
model_path = snapshot_download(
|
| 33 |
+
repo_id="Rostlab/prot_bert",
|
| 34 |
+
allow_patterns=["*.json", "pytorch_model.bin", "vocab.txt"],
|
| 35 |
+
local_files_only=False
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
tokenizer = BertTokenizer.from_pretrained(model_path, do_lower_case=False)
|
| 39 |
+
bert_model = BertModel.from_pretrained(model_path)
|
| 40 |
|
| 41 |
# Move to CPU (Hugging Face Free Tier is CPU-only usually)
|
| 42 |
bert_model.eval()
|