ngaggion commited on
Commit
789c75e
·
1 Parent(s): 2b369df

Update app

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -6,6 +6,7 @@ from models.HybridGNet2IGSC import Hybrid
6
  from utils.utils import scipy_to_torch_sparse, genMatrixesLungsHeart
7
  import scipy.sparse as sp
8
  import torch
 
9
 
10
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
11
  hybrid = None
@@ -43,11 +44,11 @@ def drawOnTop(img, landmarks):
43
  # Draw the landmarks as dots
44
 
45
  for l in RL:
46
- image = cv2.circle(image, (int(l[0]), int(l[1])), 1, (1, 1, 0), -1)
47
  for l in LL:
48
- image = cv2.circle(image, (int(l[0]), int(l[1])), 1, (1, 1, 0), -1)
49
  for l in H:
50
- image = cv2.circle(image, (int(l[0]), int(l[1])), 1, (0, 1, 1), -1)
51
 
52
  return image
53
 
@@ -132,10 +133,18 @@ def segment(input_img):
132
 
133
  with torch.no_grad():
134
  output = hybrid(data)[0].cpu().numpy().reshape(-1, 2) * 1024
135
-
136
- return drawOnTop(img, output)
 
 
 
 
 
 
 
 
137
 
138
 
139
  if __name__ == "__main__":
140
- demo = gr.Interface(segment, gr.Image(type="filepath"), "image")
141
  demo.launch()
 
6
  from utils.utils import scipy_to_torch_sparse, genMatrixesLungsHeart
7
  import scipy.sparse as sp
8
  import torch
9
+ import pandas as pd
10
 
11
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
12
  hybrid = None
 
44
  # Draw the landmarks as dots
45
 
46
  for l in RL:
47
+ image = cv2.circle(image, (int(l[0]), int(l[1])), 5, (1, 0, 1), -1)
48
  for l in LL:
49
+ image = cv2.circle(image, (int(l[0]), int(l[1])), 5, (1, 0, 1), -1)
50
  for l in H:
51
+ image = cv2.circle(image, (int(l[0]), int(l[1])), 5, (1, 1, 0), -1)
52
 
53
  return image
54
 
 
133
 
134
  with torch.no_grad():
135
  output = hybrid(data)[0].cpu().numpy().reshape(-1, 2) * 1024
136
+
137
+ outseg = drawOnTop(img, output)
138
+
139
+ output = output.astype('int')
140
+
141
+ RL = pd.DataFrame(output[0:44], columns=["x","y"])
142
+ LL = pd.DataFrame(output[44:94], columns=["x","y"])
143
+ H = pd.DataFrame(output[94:], columns=["x","y"])
144
+
145
+ return outseg #, RL, LL, H
146
 
147
 
148
  if __name__ == "__main__":
149
+ demo = gr.Interface(segment, gr.Image(type="filepath", height=750), outputs=gr.Image(type="filepath", height=750), title="Chest X-ray HybridGNet Segmentation")
150
  demo.launch()