Spaces:
Running
on
Zero
Running
on
Zero
Anton Bushuiev
commited on
Commit
·
3a7f59d
1
Parent(s):
6a3bcfb
Adapt to zero gpu
Browse files- app.py +8 -6
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import urllib.request
|
3 |
import os
|
4 |
from datetime import datetime
|
@@ -140,6 +141,12 @@ def setup():
|
|
140 |
print("Setup complete")
|
141 |
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
def _predict_core(lib_pth, in_pth, progress):
|
144 |
"""Core prediction function without error handling"""
|
145 |
in_pth = Path(in_pth)
|
@@ -154,7 +161,7 @@ def _predict_core(lib_pth, in_pth, progress):
|
|
154 |
msdata = MSData.load(in_pth)
|
155 |
|
156 |
progress(0.2, desc="Computing DreaMS embeddings...")
|
157 |
-
embs =
|
158 |
print('Shape of the query embeddings:', embs.shape)
|
159 |
|
160 |
progress(0.4, desc="Computing similarity matrix...")
|
@@ -293,10 +300,6 @@ with app:
|
|
293 |
examples=["./data/example_5_spectra.mgf", "./data/example_piper_2k_spectra.mgf"],
|
294 |
inputs=[in_pth],
|
295 |
label="Examples (click on a file to load as input)",
|
296 |
-
# TODO
|
297 |
-
# cache_examples=True
|
298 |
-
# outputs=[df, df_file],
|
299 |
-
# fn=predict,
|
300 |
)
|
301 |
|
302 |
# Predict GUI
|
@@ -315,7 +318,6 @@ with app:
|
|
315 |
show_fullscreen_button=True,
|
316 |
show_row_numbers=False,
|
317 |
show_search='filter',
|
318 |
-
# pinned_columns= # TODO
|
319 |
)
|
320 |
|
321 |
# Main logic
|
|
|
1 |
import gradio as gr
|
2 |
+
import spaces
|
3 |
import urllib.request
|
4 |
import os
|
5 |
from datetime import datetime
|
|
|
141 |
print("Setup complete")
|
142 |
|
143 |
|
144 |
+
@spaces.GPU
|
145 |
+
def _predict_gpu(msdata):
|
146 |
+
embs = dreams_embeddings(msdata)
|
147 |
+
return embs
|
148 |
+
|
149 |
+
|
150 |
def _predict_core(lib_pth, in_pth, progress):
|
151 |
"""Core prediction function without error handling"""
|
152 |
in_pth = Path(in_pth)
|
|
|
161 |
msdata = MSData.load(in_pth)
|
162 |
|
163 |
progress(0.2, desc="Computing DreaMS embeddings...")
|
164 |
+
embs = _predict_gpu(msdata)
|
165 |
print('Shape of the query embeddings:', embs.shape)
|
166 |
|
167 |
progress(0.4, desc="Computing similarity matrix...")
|
|
|
300 |
examples=["./data/example_5_spectra.mgf", "./data/example_piper_2k_spectra.mgf"],
|
301 |
inputs=[in_pth],
|
302 |
label="Examples (click on a file to load as input)",
|
|
|
|
|
|
|
|
|
303 |
)
|
304 |
|
305 |
# Predict GUI
|
|
|
318 |
show_fullscreen_button=True,
|
319 |
show_row_numbers=False,
|
320 |
show_search='filter',
|
|
|
321 |
)
|
322 |
|
323 |
# Main logic
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
-
dreams @ git+https://github.com
|
2 |
# gradio
|
|
|
|
1 |
+
dreams @ git+https://github.com/pluskal-lab/DreaMS.git@gradio
|
2 |
# gradio
|
3 |
+
# spaces
|