Spaces:
Running on Zero
Running on Zero
Minjun Kang commited on
Commit ·
da6eaac
1
Parent(s): d728005
initial code
Browse files- .gitignore +1 -0
- app.py +13 -5
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
models/prot_t5_xl_half_uniref50-enc/
|
app.py
CHANGED
|
@@ -114,13 +114,21 @@ def load_t5():
|
|
| 114 |
_modeling_utils.check_torch_load_is_safe = _noop
|
| 115 |
|
| 116 |
try:
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
dev = get_device()
|
| 119 |
dtype = torch.float16 if dev == "cuda" else torch.float32
|
| 120 |
|
| 121 |
-
_t5_tokenizer = AutoTokenizer.from_pretrained(
|
|
|
|
|
|
|
| 122 |
_t5_model = (
|
| 123 |
-
T5EncoderModel.from_pretrained(
|
|
|
|
|
|
|
| 124 |
.to(dev)
|
| 125 |
.eval()
|
| 126 |
)
|
|
@@ -259,7 +267,7 @@ _SPINNER_HTML = """
|
|
| 259 |
<span style="color:#555;font-size:14px;font-weight:500;line-height:1.5;">
|
| 260 |
ProtT5-XL feature extraction in progress…<br>
|
| 261 |
<span style="font-size:12px;color:#999;font-weight:400;">
|
| 262 |
-
First run
|
| 263 |
</span>
|
| 264 |
</span>
|
| 265 |
</div>
|
|
@@ -474,7 +482,7 @@ with gr.Blocks(
|
|
| 474 |
gr.Markdown("## Step 2 — Extract ProtT5 Feature")
|
| 475 |
gr.Markdown(
|
| 476 |
"Runs the [**ProtT5-XL**](https://github.com/agemagician/ProtTrans) encoder to produce a 1024-dim mean-pool embedding. \n"
|
| 477 |
-
"⏳ *First call
|
| 478 |
)
|
| 479 |
extract_btn = gr.Button("🔬 Extract Feature", variant="primary", size="lg")
|
| 480 |
extract_status = gr.HTML("")
|
|
|
|
| 114 |
_modeling_utils.check_torch_load_is_safe = _noop
|
| 115 |
|
| 116 |
try:
|
| 117 |
+
# Pre-fetched into the HF cache at Docker build time (see Dockerfile's
|
| 118 |
+
# snapshot_download step), so ZeroGPU calls never hit the network here —
|
| 119 |
+
# a cold download would blow past the GPU-allocation time budget and
|
| 120 |
+
# get aborted. local_files_only=True enforces that guarantee.
|
| 121 |
+
repo_id = "Rostlab/prot_t5_xl_half_uniref50-enc"
|
| 122 |
dev = get_device()
|
| 123 |
dtype = torch.float16 if dev == "cuda" else torch.float32
|
| 124 |
|
| 125 |
+
_t5_tokenizer = AutoTokenizer.from_pretrained(
|
| 126 |
+
repo_id, do_lower_case=False, local_files_only=True
|
| 127 |
+
)
|
| 128 |
_t5_model = (
|
| 129 |
+
T5EncoderModel.from_pretrained(
|
| 130 |
+
repo_id, torch_dtype=dtype, local_files_only=True
|
| 131 |
+
)
|
| 132 |
.to(dev)
|
| 133 |
.eval()
|
| 134 |
)
|
|
|
|
| 267 |
<span style="color:#555;font-size:14px;font-weight:500;line-height:1.5;">
|
| 268 |
ProtT5-XL feature extraction in progress…<br>
|
| 269 |
<span style="font-size:12px;color:#999;font-weight:400;">
|
| 270 |
+
First run loads the model onto the GPU — this may take a moment.
|
| 271 |
</span>
|
| 272 |
</span>
|
| 273 |
</div>
|
|
|
|
| 482 |
gr.Markdown("## Step 2 — Extract ProtT5 Feature")
|
| 483 |
gr.Markdown(
|
| 484 |
"Runs the [**ProtT5-XL**](https://github.com/agemagician/ProtTrans) encoder to produce a 1024-dim mean-pool embedding. \n"
|
| 485 |
+
"⏳ *First call loads the model onto the GPU and may take a moment.*"
|
| 486 |
)
|
| 487 |
extract_btn = gr.Button("🔬 Extract Feature", variant="primary", size="lg")
|
| 488 |
extract_status = gr.HTML("")
|