fradinho commited on
Commit
8f860c6
·
1 Parent(s): 4eeb9d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -4
app.py CHANGED
@@ -76,11 +76,39 @@ def predict_2(image):
76
  patches_img.shape[2], patches_img.shape[3]])
77
 
78
  unpatched_prediction = unpatchify(patched_prediction, (image.shape[0], image.shape[1]))
 
 
 
79
  unpatched_prediction = targets_classes_colors[unpatched_prediction]
 
80
 
81
- return 'Predicted Masked Image', unpatched_prediction
82
-
83
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  targets_classes_colors = np.array([[ 0, 0, 0],
85
  [128, 64, 128],
86
  [130, 76, 0],
@@ -162,7 +190,7 @@ with my_app:
162
  img_source = gr.Image(label="Please select source Image")
163
  source_image_loader = gr.Button("Load above Image")
164
  with gr.Column():
165
- output_label = gr.Label(label="Image Info")
166
  img_output = gr.Image(label="Image Output")
167
  source_image_loader.click(
168
  predict_2,
 
76
  patches_img.shape[2], patches_img.shape[3]])
77
 
78
  unpatched_prediction = unpatchify(patched_prediction, (image.shape[0], image.shape[1]))
79
+ labels = LABEL_NAMES
80
+ res = np.bincount(unpatched_prediction)/unpatched_prediction.shape[0]
81
+ out = dict(list(zip(labels, res)))
82
  unpatched_prediction = targets_classes_colors[unpatched_prediction]
83
+
84
 
85
+ return out, unpatched_prediction
86
+
87
+ LABEL_NAMES = ["unlabeled",
88
+ "paved-area",
89
+ "dirt",
90
+ "grass",
91
+ "gravel",
92
+ "water",
93
+ "rocks",
94
+ "pool",
95
+ "vegetation",
96
+ "roof",
97
+ "wall",
98
+ "window",
99
+ "door",
100
+ "fence",
101
+ "fence-pole",
102
+ "person",
103
+ "dog",
104
+ "car",
105
+ "bicycle",
106
+ "tree",
107
+ "bald-tree",
108
+ "ar-marker",
109
+ "obstacle",
110
+ "conflicting",
111
+ ]
112
  targets_classes_colors = np.array([[ 0, 0, 0],
113
  [128, 64, 128],
114
  [130, 76, 0],
 
190
  img_source = gr.Image(label="Please select source Image")
191
  source_image_loader = gr.Button("Load above Image")
192
  with gr.Column():
193
+ output_label = gr.Label(label="Predicted Masked Image")
194
  img_output = gr.Image(label="Image Output")
195
  source_image_loader.click(
196
  predict_2,