dalexanderch commited on
Commit
fc829e4
1 Parent(s): ecff45a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -34,18 +34,29 @@ model3 = torch.load("model3.pt", map_location=torch.device('cpu'))
34
 
35
  def fn(glycan, model):
36
  if model == "No data augmentation":
37
- model = model1
38
- model.eval()
39
  elif model == "Ensemble":
40
- model = model3
41
- model.eval()
42
  else:
43
- model = model2
44
- model.eval()
 
45
  glycan = [glycan]
46
  label = [0]
47
  data = next(iter(dataset_to_dataloader(glycan, label, batch_size=1)))
48
- pred = model(data)
 
 
 
 
 
 
 
 
 
 
49
  pred = np.exp(pred)/sum(np.exp(pred)) # Softmax
50
  pred = [float(x) for x in pred]
51
  pred = {class_list[i]:pred[i] for i in range(15)}
 
34
 
35
  def fn(glycan, model):
36
  if model == "No data augmentation":
37
+ model_pred = model1
38
+ model_pred.eval()
39
  elif model == "Ensemble":
40
+ model_pred = model3
41
+ model_pred.eval()
42
  else:
43
+ model_pred = model2
44
+ model_pred.eval()
45
+
46
  glycan = [glycan]
47
  label = [0]
48
  data = next(iter(dataset_to_dataloader(glycan, label, batch_size=1)))
49
+ if model == "Ensemble":
50
+ pred = model_pred(data)
51
+ else:
52
+ device = "cpu"
53
+ x = data.labels
54
+ edge_index = data.edge_index
55
+ batch = data.batch
56
+ x = x.to(device)
57
+ edge_index = edge_index.to(device)
58
+ batch = batch.to(device)
59
+ pred = model_pred(x,edge_index, batch).cpu().detach().numpy()[0]
60
  pred = np.exp(pred)/sum(np.exp(pred)) # Softmax
61
  pred = [float(x) for x in pred]
62
  pred = {class_list[i]:pred[i] for i in range(15)}