개정판 ef414ad3
issue #1366: fix tile
DTI_PID/WebServer/app/recognition/index.py | ||
---|---|---|
60 | 60 |
data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)) + '\\..\\..\\symbol_training\\Data\\', data['name']) |
61 | 61 |
|
62 | 62 |
boxes = test_doftech_all_images.get_symbol(imgs, data['name'], root_path=data_path, trained_model1=os.path.join(data_path, 'checkpoint', data['name'] + "_only_params.pth"), \ |
63 |
trained_model2=None, save=False)
|
|
63 |
trained_model2=None, save=True)
|
|
64 | 64 |
|
65 | 65 |
return jsonify({'symbol_box': boxes[0]}) |
66 | 66 |
|
DTI_PID/WebServer/symbol_recognition/test_doftech_all_images.py | ||
---|---|---|
205 | 205 |
logits = model(data) |
206 | 206 |
predictions = post_processing(logits, opt.image_size, DOFTECH_CLASSES, model.anchors, opt.conf_threshold, |
207 | 207 |
opt.nms_threshold) |
208 |
output_image = cv2.cvtColor(np.array(pil_image.img), cv2.COLOR_RGB2BGR) |
|
208 | 209 |
if len(predictions) != 0: |
209 | 210 |
predictions = predictions[0] |
210 |
output_image = cv2.cvtColor(np.array(pil_image.img), cv2.COLOR_RGB2BGR) |
|
211 |
#output_image = cv2.cvtColor(np.array(pil_image.img), cv2.COLOR_RGB2BGR)
|
|
211 | 212 |
for pred in predictions: |
212 | 213 |
if opc == True and pred[5] in bigs: |
213 | 214 |
if pred[4] > 0.4:#pred[5] == "opc" and pred[4] > 0.4: # Classification threshold |
... | ... | |
229 | 230 |
output_image, pred[5] + ' : %.2f' % pred[4], |
230 | 231 |
(xmin, ymin + text_size[1] + 4), cv2.FONT_HERSHEY_PLAIN, 1, |
231 | 232 |
(255, 255, 255), 1) |
232 |
elif opc == False and pred[5] not in bigs:
|
|
233 |
elif opc == False and pred[5] not in bigs: |
|
233 | 234 |
if pred[4] > 0.1: # Classification threshold |
234 | 235 |
xmin = int(max(pred[0] / width_ratio, 0)) |
235 | 236 |
ymin = int(max(pred[1] / height_ratio, 0)) |
... | ... | |
250 | 251 |
(xmin, ymin + text_size[1] + 4), cv2.FONT_HERSHEY_PLAIN, 1, |
251 | 252 |
(255, 255, 255), 1) |
252 | 253 |
# -----------------------fill king image-------------------------------------- |
253 |
if save_root: |
|
254 |
cv2.imwrite(save_root+"{}_prediction.png".format(idx), output_image) |
|
255 | 254 |
pil_image.setObjectNum(len(predictions)) |
255 |
if save_root: |
|
256 |
cv2.imwrite(save_root+"{}_prediction.png".format(idx), output_image) |
|
256 | 257 |
return symbol_list |
257 | 258 |
|
258 | 259 |
def merge_fn(total_img, total_symbole_list, save_root=None): |
... | ... | |
303 | 304 |
t_y = 0 if row == 0 else row * overlap_size |
304 | 305 |
t_x = 0 if col == 0 else col * overlap_size |
305 | 306 |
|
306 |
bbox = (t_y, t_x, t_y + patch_size, t_x + patch_size)
|
|
307 |
bbox = (t_x, t_y, t_x + patch_size, t_y + patch_size)
|
|
307 | 308 |
|
308 | 309 |
crop_img = image.crop(bbox) |
309 |
patch = Patch(t_x, t_y, crop_img, True)
|
|
310 |
patch = Patch(t_y, t_x, crop_img, True)
|
|
310 | 311 |
tile_info_list.append(patch) |
311 | 312 |
|
312 | 313 |
return tile_info_list |
내보내기 Unified diff