Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,14 +7,15 @@ import joblib
|
|
| 7 |
import numpy as np
|
| 8 |
import torch.nn.functional as F
|
| 9 |
from Bio.Blast import NCBIWWW, NCBIXML
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
-
import spaces
|
| 13 |
|
| 14 |
# ===================================
|
| 15 |
-
# 1. LOAD AI MODELS (GLOBALLY CACHED)
|
| 16 |
# ===================================
|
| 17 |
-
print("Waking up the Genomic Oracle...\n")
|
| 18 |
|
| 19 |
# A. Kadir's Gatekeeper
|
| 20 |
clf_coding = joblib.load("coding_classifier_universal.joblib")
|
|
@@ -33,9 +34,10 @@ model_promoter.eval()
|
|
| 33 |
lgbm_path = hf_hub_download(repo_id="Geonomic/Genomic-Oracle-Weights", filename="dnabert_lightgbm_model_feature_type.pkl")
|
| 34 |
lightgbm_model = joblib.load(lgbm_path)
|
| 35 |
|
| 36 |
-
# E. Custom
|
| 37 |
-
tokenizer_pheno =
|
| 38 |
-
|
|
|
|
| 39 |
model_pheno.eval()
|
| 40 |
|
| 41 |
FEATURE_DICT = {
|
|
@@ -46,8 +48,12 @@ FEATURE_DICT = {
|
|
| 46 |
# ==============================================
|
| 47 |
# 2. CORE INFERENCE ENGINE (ZeroGPU Accelerated)
|
| 48 |
# ==============================================
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
def run_deep_learning_cascade(dna_sequence):
|
|
|
|
| 51 |
device = torch.device("cuda")
|
| 52 |
clean_seq = "".join(dna_sequence.split()).upper()
|
| 53 |
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
import torch.nn.functional as F
|
| 9 |
from Bio.Blast import NCBIWWW, NCBIXML
|
| 10 |
+
|
| 11 |
+
# 🚨 Colab Native Imports for the Phenotype model!
|
| 12 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModel, BertTokenizer, BertForSequenceClassification, AutoConfig
|
| 13 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 14 |
|
| 15 |
# ===================================
|
| 16 |
+
# 1. LOAD AI MODELS (GLOBALLY CACHED ON CPU)
|
| 17 |
# ===================================
|
| 18 |
+
print("Waking up the Genomic Oracle... Loading models safely into CPU RAM.\n")
|
| 19 |
|
| 20 |
# A. Kadir's Gatekeeper
|
| 21 |
clf_coding = joblib.load("coding_classifier_universal.joblib")
|
|
|
|
| 34 |
lgbm_path = hf_hub_download(repo_id="Geonomic/Genomic-Oracle-Weights", filename="dnabert_lightgbm_model_feature_type.pkl")
|
| 35 |
lightgbm_model = joblib.load(lgbm_path)
|
| 36 |
|
| 37 |
+
# E. Custom Lean/Obese Phenotype BERT (🚨 Forced Native Architecture via Colab Fix!)
|
| 38 |
+
tokenizer_pheno = BertTokenizer.from_pretrained("Geonomic/Genomic-Oracle-Weights", do_lower_case=False)
|
| 39 |
+
config_pheno = AutoConfig.from_pretrained("Geonomic/Genomic-Oracle-Weights", trust_remote_code=True)
|
| 40 |
+
model_pheno = BertForSequenceClassification.from_pretrained("Geonomic/Genomic-Oracle-Weights", config=config_pheno)
|
| 41 |
model_pheno.eval()
|
| 42 |
|
| 43 |
FEATURE_DICT = {
|
|
|
|
| 48 |
# ==============================================
|
| 49 |
# 2. CORE INFERENCE ENGINE (ZeroGPU Accelerated)
|
| 50 |
# ==============================================
|
| 51 |
+
# 🚨 DELAYED IMPORT: ZeroGPU is activated ONLY AFTER CPU loading is perfectly finished!
|
| 52 |
+
import spaces
|
| 53 |
+
|
| 54 |
+
@spaces.GPU
|
| 55 |
def run_deep_learning_cascade(dna_sequence):
|
| 56 |
+
# We send the inputs to cuda, and ZeroGPU natively handles teleporting the models!
|
| 57 |
device = torch.device("cuda")
|
| 58 |
clean_seq = "".join(dna_sequence.split()).upper()
|
| 59 |
|