Spaces:
Runtime error
Runtime error
Commit ·
d54895f
1
Parent(s): 7ec6647
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,13 +43,13 @@ model7 = torch.load("model7.pt", map_location=torch.device('cpu'))
|
|
| 43 |
|
| 44 |
def fn(glycan, model):
|
| 45 |
# Draw graph
|
| 46 |
-
graph = glycan_to_nxGraph(glycan)
|
| 47 |
-
node_labels = nx.get_node_attributes(graph, 'string_labels')
|
| 48 |
-
labels = {i:node_labels[i] for i in range(len(graph.nodes))}
|
| 49 |
-
graph = nx.relabel_nodes(graph, labels)
|
| 50 |
-
graph = nx.drawing.nx_pydot.to_pydot(graph)
|
| 51 |
-
graph.set_prog("dot")
|
| 52 |
-
graph.write_png("graph.png")
|
| 53 |
# write_dot(graph, "graph.dot")
|
| 54 |
# graph=pgv.AGraph("graph.dot")
|
| 55 |
# graph.layout(prog='dot')
|
|
@@ -96,13 +96,13 @@ def fn(glycan, model):
|
|
| 96 |
pred = np.exp(pred)/sum(np.exp(pred)) # Softmax
|
| 97 |
pred = [float(x) for x in pred]
|
| 98 |
pred = {class_list[i]:pred[i] for i in range(15)}
|
| 99 |
-
return pred
|
| 100 |
|
| 101 |
|
| 102 |
demo = gr.Interface(
|
| 103 |
fn=fn,
|
| 104 |
inputs=[gr.Textbox(label="Glycan sequence", value="Man(a1-2)Man(a1-3)[Man(a1-3)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc"), gr.Radio(label="Model",choices=["No data augmentation", "Random node deletion", "Random edge deletion", "Ensemble", "Bootstrap ensemble", "Hierarchy substitution", "Adjusted class weights"])],
|
| 105 |
-
outputs=[gr.Label(num_top_classes=15, label="Prediction")
|
| 106 |
allow_flagging="never",
|
| 107 |
title="SweetNet demo",
|
| 108 |
examples=[
|
|
|
|
| 43 |
|
| 44 |
def fn(glycan, model):
|
| 45 |
# Draw graph
|
| 46 |
+
#graph = glycan_to_nxGraph(glycan)
|
| 47 |
+
#node_labels = nx.get_node_attributes(graph, 'string_labels')
|
| 48 |
+
#labels = {i:node_labels[i] for i in range(len(graph.nodes))}
|
| 49 |
+
#graph = nx.relabel_nodes(graph, labels)
|
| 50 |
+
#graph = nx.drawing.nx_pydot.to_pydot(graph)
|
| 51 |
+
#graph.set_prog("dot")
|
| 52 |
+
#graph.write_png("graph.png")
|
| 53 |
# write_dot(graph, "graph.dot")
|
| 54 |
# graph=pgv.AGraph("graph.dot")
|
| 55 |
# graph.layout(prog='dot')
|
|
|
|
| 96 |
pred = np.exp(pred)/sum(np.exp(pred)) # Softmax
|
| 97 |
pred = [float(x) for x in pred]
|
| 98 |
pred = {class_list[i]:pred[i] for i in range(15)}
|
| 99 |
+
return pred
|
| 100 |
|
| 101 |
|
| 102 |
demo = gr.Interface(
|
| 103 |
fn=fn,
|
| 104 |
inputs=[gr.Textbox(label="Glycan sequence", value="Man(a1-2)Man(a1-3)[Man(a1-3)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc"), gr.Radio(label="Model",choices=["No data augmentation", "Random node deletion", "Random edge deletion", "Ensemble", "Bootstrap ensemble", "Hierarchy substitution", "Adjusted class weights"])],
|
| 105 |
+
outputs=[gr.Label(num_top_classes=15, label="Prediction")],
|
| 106 |
allow_flagging="never",
|
| 107 |
title="SweetNet demo",
|
| 108 |
examples=[
|