Spaces:
Running
on
Zero
Running
on
Zero
Anton Bushuiev
commited on
Commit
·
c53be73
1
Parent(s):
6e6eb6f
Download spectral library and pre-download weights
Browse files
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from functools import partial
|
3 |
|
4 |
import pandas as pd
|
@@ -15,6 +17,19 @@ from dreams.api import dreams_embeddings
|
|
15 |
from dreams.definitions import *
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def predict(lib_pth, in_pth):
|
19 |
in_pth = Path(in_pth)
|
20 |
# in_pth = Path('DreaMS/data/MSV000086206/peak/mzml/S_N1.mzML') # Example dataset
|
@@ -80,6 +95,7 @@ def predict(lib_pth, in_pth):
|
|
80 |
return df, str(df_path)
|
81 |
|
82 |
|
|
|
83 |
app = gr.Blocks(theme=gr.themes.Default(primary_hue="green", secondary_hue="pink"))
|
84 |
with app:
|
85 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import urllib.request
|
3 |
+
import os
|
4 |
from functools import partial
|
5 |
|
6 |
import pandas as pd
|
|
|
17 |
from dreams.definitions import *
|
18 |
|
19 |
|
20 |
+
def setup():
|
21 |
+
# Download spectra library
|
22 |
+
os.makedirs('./DreaMS/data', exist_ok=True)
|
23 |
+
url = 'https://huggingface.co/datasets/roman-bushuiev/GeMS/resolve/main/data/auxiliary/MassSpecGym_DreaMS.hdf5'
|
24 |
+
target_path = './DreaMS/data/MassSpecGym_DreaMS.hdf5'
|
25 |
+
if not os.path.exists(target_path):
|
26 |
+
urllib.request.urlretrieve(url, target_path)
|
27 |
+
|
28 |
+
# Run simple example as a test and to download weights
|
29 |
+
embs = dreams_embeddings('DreaMS/data/examples/example_5_spectra.mgf')
|
30 |
+
print("Setup complete")
|
31 |
+
|
32 |
+
|
33 |
def predict(lib_pth, in_pth):
|
34 |
in_pth = Path(in_pth)
|
35 |
# in_pth = Path('DreaMS/data/MSV000086206/peak/mzml/S_N1.mzML') # Example dataset
|
|
|
95 |
return df, str(df_path)
|
96 |
|
97 |
|
98 |
+
setup()
|
99 |
app = gr.Blocks(theme=gr.themes.Default(primary_hue="green", secondary_hue="pink"))
|
100 |
with app:
|
101 |
|