Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,28 +11,10 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification, Auto
|
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
import spaces
|
| 13 |
|
| 14 |
-
# ==========================================
|
| 15 |
-
# 🚨 THE ALIBI ZERO-GPU BUGFIX PATCH 🚨
|
| 16 |
-
# ==========================================
|
| 17 |
-
# Hugging Face ZeroGPU uses a "meta" device to trace memory.
|
| 18 |
-
# DNABERT's custom ALiBi code hardcodes CPU tensors, causing a fatal collision.
|
| 19 |
-
# We intercept PyTorch's arange function to dynamically align the tensors.
|
| 20 |
-
_orig_arange = torch.arange
|
| 21 |
-
def _alibi_safe_arange(*args, **kwargs):
|
| 22 |
-
tensor = _orig_arange(*args, **kwargs)
|
| 23 |
-
try:
|
| 24 |
-
# If ZeroGPU has forced the environment into 'meta' mode, we align the tensor
|
| 25 |
-
if torch.Tensor().device.type == 'meta' or getattr(torch, 'get_default_device', lambda: torch.device('cpu'))().type == 'meta':
|
| 26 |
-
return tensor.to('meta')
|
| 27 |
-
except:
|
| 28 |
-
pass
|
| 29 |
-
return tensor
|
| 30 |
-
torch.arange = _alibi_safe_arange
|
| 31 |
-
|
| 32 |
# ===================================
|
| 33 |
# 1. LOAD AI MODELS (GLOBALLY CACHED)
|
| 34 |
# ===================================
|
| 35 |
-
print("Waking up the Genomic Oracle...
|
| 36 |
|
| 37 |
# A. Kadir's Gatekeeper
|
| 38 |
clf_coding = joblib.load("coding_classifier_universal.joblib")
|
|
@@ -64,7 +46,7 @@ FEATURE_DICT = {
|
|
| 64 |
# ==============================================
|
| 65 |
# 2. CORE INFERENCE ENGINE (ZeroGPU Accelerated)
|
| 66 |
# ==============================================
|
| 67 |
-
@spaces.GPU # ZeroGPU
|
| 68 |
def run_deep_learning_cascade(dna_sequence):
|
| 69 |
device = torch.device("cuda")
|
| 70 |
clean_seq = "".join(dna_sequence.split()).upper()
|
|
|
|
| 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")
|
|
|
|
| 46 |
# ==============================================
|
| 47 |
# 2. CORE INFERENCE ENGINE (ZeroGPU Accelerated)
|
| 48 |
# ==============================================
|
| 49 |
+
@spaces.GPU # ZeroGPU natively manages the global models!
|
| 50 |
def run_deep_learning_cascade(dna_sequence):
|
| 51 |
device = torch.device("cuda")
|
| 52 |
clean_seq = "".join(dna_sequence.split()).upper()
|