dalexanderch commited on
Commit
2eac51e
1 Parent(s): b7d6d94

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -8,8 +8,6 @@ import torch
8
  import torch.nn as nn
9
  from glycowork.motif.graph import glycan_to_nxGraph
10
  import networkx as nx
11
- import matplotlib.pyplot as plt
12
- from networkx.drawing.nx_agraph import write_dot
13
  import pydot
14
  # import pygraphviz as pgv
15
 
@@ -46,6 +44,7 @@ def fn(glycan, model):
46
  labels = {i:node_labels[i] for i in range(len(graph.nodes))}
47
  graph = nx.relabel_nodes(graph, labels)
48
  graph = nx.drawing.nx_pydot.to_pydot(graph)
 
49
  graph.write_png("graph.png")
50
  # write_dot(graph, "graph.dot")
51
  # graph=pgv.AGraph("graph.dot")
@@ -88,7 +87,7 @@ demo = gr.Interface(
88
  fn=fn,
89
  inputs=[gr.Textbox(label="Glycan sequence"), gr.Radio(label="Model",choices=["No data augmentation", "Random node deletion", "Ensemble"])],
90
  outputs=[gr.Label(num_top_classes=15, label="Prediction"), gr.Image(label="Glycan graph")],
91
- allow_flagging=False,
92
  title="SweetNet demo",
93
  examples=[["GlcOSN(a1-4)GlcA(b1-4)GlcOSN(a1-4)GlcAOS(b1-4)GlcOSN(a1-4)GlcOSN", "No data augmentation"],
94
  ["Man(a1-2)Man(a1-3)[Man(a1-3)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc", "Random node deletion"],
 
8
  import torch.nn as nn
9
  from glycowork.motif.graph import glycan_to_nxGraph
10
  import networkx as nx
 
 
11
  import pydot
12
  # import pygraphviz as pgv
13
 
 
44
  labels = {i:node_labels[i] for i in range(len(graph.nodes))}
45
  graph = nx.relabel_nodes(graph, labels)
46
  graph = nx.drawing.nx_pydot.to_pydot(graph)
47
+ graph.set_prog("neato")
48
  graph.write_png("graph.png")
49
  # write_dot(graph, "graph.dot")
50
  # graph=pgv.AGraph("graph.dot")
 
87
  fn=fn,
88
  inputs=[gr.Textbox(label="Glycan sequence"), gr.Radio(label="Model",choices=["No data augmentation", "Random node deletion", "Ensemble"])],
89
  outputs=[gr.Label(num_top_classes=15, label="Prediction"), gr.Image(label="Glycan graph")],
90
+ allow_flagging="Never",
91
  title="SweetNet demo",
92
  examples=[["GlcOSN(a1-4)GlcA(b1-4)GlcOSN(a1-4)GlcAOS(b1-4)GlcOSN(a1-4)GlcOSN", "No data augmentation"],
93
  ["Man(a1-2)Man(a1-3)[Man(a1-3)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc", "Random node deletion"],