Spaces:
Runtime error
Runtime error
dalexanderch
commited on
Commit
•
0fbae15
1
Parent(s):
06e8090
Upload app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,13 @@ from glycowork.glycan_data.loader import lib
|
|
10 |
|
11 |
|
12 |
def fn(model, class_list):
|
13 |
-
def f(glycan):
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
glycan = [glycan]
|
15 |
label = [0]
|
16 |
data = next(iter(dataset_to_dataloader(glycan, label, batch_size=1)))
|
@@ -30,8 +36,6 @@ def fn(model, class_list):
|
|
30 |
return pred
|
31 |
return f
|
32 |
|
33 |
-
model = torch.load("model.pt")
|
34 |
-
model.eval()
|
35 |
class_list=['Amoebozoa', 'Animalia', 'Bacteria', 'Bamfordvirae', 'Chromista', 'Euryarchaeota', 'Excavata', 'Fungi', 'Heunggongvirae',
|
36 |
'Orthornavirae', 'Pararnavirae', 'Plantae', 'Proteoarchaeota', 'Protista', 'Riboviria']
|
37 |
|
@@ -39,12 +43,11 @@ f = fn(model, class_list)
|
|
39 |
|
40 |
demo = gr.Interface(
|
41 |
fn=f,
|
42 |
-
inputs=[gr.Textbox(label="Glycan sequence")],
|
43 |
-
outputs=[gr.Label(num_top_classes=15, label="
|
44 |
allow_flagging=False,
|
45 |
title="SweetNet demo",
|
46 |
-
examples=["GlcOSN(a1-4)GlcA(b1-4)GlcOSN(a1-4)GlcAOS(b1-4)GlcOSN(a1-4)GlcOSN",
|
47 |
-
"Man(a1-2)Man(a1-3)[Man(a1-3)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc",
|
48 |
-
"Neu5Ac(a2-3)Gal(b1-3)[Neu5Ac(a2-6)]GlcNAc(b1-3)Gal(b1-4)Glc-ol"]
|
49 |
)
|
50 |
demo.launch(debug=True)
|
|
|
10 |
|
11 |
|
12 |
def fn(model, class_list):
|
13 |
+
def f(glycan, model):
|
14 |
+
if model == "No data augmentation":
|
15 |
+
model = torch.load("model1.pt")
|
16 |
+
model.eval()
|
17 |
+
else:
|
18 |
+
model = torch.load("mode2.pt")
|
19 |
+
model.eval()
|
20 |
glycan = [glycan]
|
21 |
label = [0]
|
22 |
data = next(iter(dataset_to_dataloader(glycan, label, batch_size=1)))
|
|
|
36 |
return pred
|
37 |
return f
|
38 |
|
|
|
|
|
39 |
class_list=['Amoebozoa', 'Animalia', 'Bacteria', 'Bamfordvirae', 'Chromista', 'Euryarchaeota', 'Excavata', 'Fungi', 'Heunggongvirae',
|
40 |
'Orthornavirae', 'Pararnavirae', 'Plantae', 'Proteoarchaeota', 'Protista', 'Riboviria']
|
41 |
|
|
|
43 |
|
44 |
demo = gr.Interface(
|
45 |
fn=f,
|
46 |
+
inputs=[gr.Textbox(label="Glycan sequence"), gr.Radio(label="Model",choices=["No data augmentation", "Random node deletion"])],
|
47 |
+
outputs=[gr.Label(num_top_classes=15, label="Prediction")],
|
48 |
allow_flagging=False,
|
49 |
title="SweetNet demo",
|
50 |
+
examples=[["GlcOSN(a1-4)GlcA(b1-4)GlcOSN(a1-4)GlcAOS(b1-4)GlcOSN(a1-4)GlcOSN", "No data augmentation"],
|
51 |
+
["Man(a1-2)Man(a1-3)[Man(a1-3)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc", "Random node deletion"]]
|
|
|
52 |
)
|
53 |
demo.launch(debug=True)
|