| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import logging
- logging.basicConfig(
- format='%(asctime)s [%(levelname)s] - %(message)s',
- level=logging.INFO)
- import os
- from vi_cls.cls_pred import cls_pred
- from config import config
- class eval(cls_pred):
- def __init__(self, cfg, args=None):
- cls_pred.__init__(self, cfg, args)
- self.pred_class = None
- #------------------------------------------------------------------------------
- # Predict Image Files
- #------------------------------------------------------------------------------
- def before_pred_file(self, img_file):
- split_num = 1
- # if img_file.find('100X') > 0 or img_file.find('100x') > 0:
- # split_num = 4
- # elif img_file.find('200X') > 0 or img_file.find('200x') > 0:
- # split_num = 2
- # elif img_file.find('500X') > 0 or img_file.find('500x') > 0:
- # split_num = 1
- # elif img_file.find('1000X') > 0 or img_file.find('1000x') > 0:
- # split_num = 1
- self.set_arg('splits_num', split_num)
-
- def after_pred_file(self, det_dict):
- self.pred_class = ''
- if len(det_dict) > 0:
- dets = sorted(det_dict.items(), lambda x, y : cmp(x[1], y[1]), reverse=True)
- self.pred_class = dets[0][0]
- def get_pred_result_text(self, det_dict, im_inp):
- return self.pred_class
- if __name__ == '__main__':
- cfg = config()
- e = eval(cfg)
- e.set_arg('img_dir', e._args.img_dir)
- e.set_arg('gray_image', 'True')
- e.set_arg('resize_w', 224)
- e.set_arg('resize_h', 224)
- e.set_arg('crop_w', 224)
- e.set_arg('crop_h', 224)
- e.pred_file()
|