예제 #1
0
 def __init__(self, cfg_path):
     '''
     Argument
     --------
     cfg_path: str
         A path to config file.
         Example: github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg
     '''
     super(Darknet, self).__init__()
     self.layers_info = parse_cfg(cfg_path)
     self.net_info, self.layers_list = self.create_layers(self.layers_info)
     # take the number of classes from the last (yolo) layer of the network.
     self.classes = self.layers_list[-1][0].classes
     self.model_width = self.layers_list[-1][0].model_width
     # print('INFO: shortcut is using output[i-1] instead of x check whether works with x')
     print('INFO: changing predictions in the NMS loop make sure that it is not used later')
     print('INFO: not adding +1 in nms')
     print('INFO: loss: w and h aren`t put through sqroot' )
예제 #2
0
        draw.text((5, 5), class_name, (0, 255, 0), font=font_text)
        img = cv2.cvtColor(np.asarray(img), cv2.COLOR_RGB2BGR)
        img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

        print('Class name:', class_name, 'Confidence:', str(confidence) + '%')
        self.statusbar.showMessage('Class name: ' + class_name +
                                   ' Confidence: ' + str(confidence) + '%')

        h, w = img.shape[:2]
        img = QImage(img, w, h, QImage.Format_RGB888)
        img = QPixmap.fromImage(img)
        self.img_label.setPixmap(img)  # show on img label
        self.img_label.setScaledContents(True)  # self adaption
        self.isChecking = True
        self.dish_label.setText("菜品名称:" + class_name)
        self.price_label.setText("金额:" + self.prices[class_name] + "元")

    def confirm(self):
        self.isChecking = False
        self.dish_label.setText("菜品名称:")
        self.price_label.setText("金额:")


if __name__ == '__main__':
    weight_path, cfg_path, cam_width, cam_height = args.weights, args.cfg, args.cam_width, args.cam_height
    cfg = parse_cfg(cfg_path)

    app = QApplication(sys.argv)
    window = Window(weight_path, cfg, cam_width, cam_height)
    sys.exit(app.exec_())
예제 #3
0
from test import TESTS
from utils import _init_fn, set_seed, parse_cfg, create_logger, resume_last, resume_best, resume_from, save_model, apply_dataparallel, model_to_device


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('cfg')
    parser.add_argument('--resume_best', action='store_true', help='Resume the model from the best checkpoint')
    parser.add_argument('--resume_last', action='store_true', help='Resume the model from the latest checkpoint')
    parser.add_argument('--resume_from', help='Resume from a specified checkpoint')
    parser.add_argument('--non_deterministic', help='Do not use a fixed seed')
    parser.add_argument('--no_save', action='store_true', help='Do not save checkpoints')
    parser.add_argument('--max_epoch', type=int, default=200, help='Max epoch during training')
    parser.add_argument('--runs', type=int, default=1, help='Number of times to run')
    args = parser.parse_args()
    cfg, stem = parse_cfg(args.cfg)
    if not args.non_deterministic:
        set_seed(666)

    # work directory
    work_dir = join('work_dirs', stem)
    if not isdir(work_dir):
        makedirs(work_dir)

    # create logger
    logger = create_logger(work_dir)

    best_test_acc_runs = []

    # multiple runs
    if cfg['dataset']['type'] == 'ShapeNet':
예제 #4
0
 def __init__(self, cfgfile):
     super(Darknet, self).__init__()
     self.blocks = utils.parse_cfg(cfgfile)
     self.net_info, self.module_list = utils.create_modules(self.blocks)
예제 #5
0
 def create_model(self, cfg_file):
     blocks = parse_cfg(cfg_file)
     self.model = create_model(blocks)
     self.initialized = False
     self.loaded = False
     print("Model created")
예제 #6
0
 def __init__(self, cfgfile, reso):
     super(YOLOv3, self).__init__()
     self.blocks = parse_cfg(cfgfile)
     self.reso = reso
     self.module_list = self.build_model(self.blocks)
     self.nms = NMSLayer()