bigmed@bigmed commited on
Commit
67849dc
1 Parent(s): 2cb8177

edited error

Browse files
Files changed (3) hide show
  1. app.py +6 -6
  2. pipline.py +5 -3
  3. requirements.txt +3 -1
app.py CHANGED
@@ -106,7 +106,7 @@ def Final_Compute_regression_results_Sample(Model, batch_sampler,num_head=2):
106
  if ratios.vcdr < 0.6:
107
  glaucoma = 'None (Rule of thumb ~0.6 or greater is suspicious)'
108
  else:
109
- glaucoma = 'There May be a risk of Glaucoma (Rule of thumb ~0.6 or greater is suspicious)'
110
 
111
  # print('Galucoma:')
112
 
@@ -134,8 +134,8 @@ def infer(img):
134
  result, ratio, diagnosis, cropped = Final_Compute_regression_results_Sample(DeepLab, sample_batch, num_head=2)
135
 
136
  # cropped = cv2.cvtColor(np.asarray(cropped), cv2.COLOR_BGR2RGB)
137
- cropped = result[cropped['cord'][0] -100 :cropped['cord'][1] +100,
138
- cropped['cord'][2] -100 :cropped['cord'][3] +100]
139
 
140
  return ratio, diagnosis, result, cropped
141
 
@@ -156,7 +156,7 @@ with gr.Blocks(css='#title {text-align : center;} ') as demo:
156
  )
157
  with gr.Row():
158
  with gr.Column():
159
- prompt = gr.Image(label="Enter Your Retina Image")
160
  btn = gr.Button(value='Submit')
161
  examples = gr.Examples(
162
  ['M00027.png','M00056.png','M00073.png','M00093.png', 'M00018.png', 'M00034.png'],
@@ -165,8 +165,8 @@ with gr.Blocks(css='#title {text-align : center;} ') as demo:
165
  with gr.Row():
166
  text1 = gr.Textbox(label="Vertical Cup to Disc Ratio:")
167
  text2 = gr.Textbox(label="Predicted Diagnosis")
168
- img = gr.Image(label='labeled image')
169
- zoom = gr.Image(label='zoomed in')
170
 
171
  outputs = [text1,text2,img,zoom]
172
 
 
106
  if ratios.vcdr < 0.6:
107
  glaucoma = 'None (Rule of thumb ~0.6 or greater is suspicious)'
108
  else:
109
+ glaucoma = 'May be thre is a risk of Glaucoma (Rule of thumb ~0.6 or greater is suspicious)'
110
 
111
  # print('Galucoma:')
112
 
 
134
  result, ratio, diagnosis, cropped = Final_Compute_regression_results_Sample(DeepLab, sample_batch, num_head=2)
135
 
136
  # cropped = cv2.cvtColor(np.asarray(cropped), cv2.COLOR_BGR2RGB)
137
+ cropped = result[cropped['cord'][0] :cropped['cord'][1] ,
138
+ cropped['cord'][2] :cropped['cord'][3] ]
139
 
140
  return ratio, diagnosis, result, cropped
141
 
 
156
  )
157
  with gr.Row():
158
  with gr.Column():
159
+ prompt = gr.Image(label="Upload Your Retinal Fundus Image")
160
  btn = gr.Button(value='Submit')
161
  examples = gr.Examples(
162
  ['M00027.png','M00056.png','M00073.png','M00093.png', 'M00018.png', 'M00034.png'],
 
165
  with gr.Row():
166
  text1 = gr.Textbox(label="Vertical Cup to Disc Ratio:")
167
  text2 = gr.Textbox(label="Predicted Diagnosis")
168
+ img = gr.Image(label='Detected disc and cup')
169
+ zoom = gr.Image(label='Croppped')
170
 
171
  outputs = [text1,text2,img,zoom]
172
 
pipline.py CHANGED
@@ -111,6 +111,7 @@ class ASPP(nn.Module):
111
  return x21
112
 
113
 
 
114
  class Transformer_Regression(nn.Module):
115
  def __init__(self, image_dim=224, dim_patch=24, num_classes=3, scale=1, feat_dim=192):
116
  super(Transformer_Regression, self).__init__()
@@ -164,8 +165,6 @@ class Transformer_Regression(nn.Module):
164
  return Score
165
 
166
 
167
-
168
-
169
  Ratios = namedtuple("Ratios", 'cdr hcdr vcdr')
170
  eps = np.finfo(np.float32).eps
171
 
@@ -219,4 +218,7 @@ def compute_ratios(mask_image):
219
  hcdr = (cup_horz + eps) / (disc_horz + eps)
220
  vcdr = (cup_vert + eps) / (disc_vert + eps)
221
 
222
- return Ratios(cdr, hcdr, vcdr)
 
 
 
 
111
  return x21
112
 
113
 
114
+
115
  class Transformer_Regression(nn.Module):
116
  def __init__(self, image_dim=224, dim_patch=24, num_classes=3, scale=1, feat_dim=192):
117
  super(Transformer_Regression, self).__init__()
 
165
  return Score
166
 
167
 
 
 
168
  Ratios = namedtuple("Ratios", 'cdr hcdr vcdr')
169
  eps = np.finfo(np.float32).eps
170
 
 
218
  hcdr = (cup_horz + eps) / (disc_horz + eps)
219
  vcdr = (cup_vert + eps) / (disc_vert + eps)
220
 
221
+ return Ratios(cdr, hcdr, vcdr)
222
+
223
+
224
+
requirements.txt CHANGED
@@ -3,4 +3,6 @@ timm
3
  scikit-image
4
  numpy
5
  opencv-python
6
- Pillow
 
 
 
3
  scikit-image
4
  numpy
5
  opencv-python
6
+ Pillow
7
+ gradio
8
+ torchvision