def forward(self, bottom, top):
     self.iterations += 1
     try:
         printProgress(self.iterations,
                       config.steps,
                       prefix='Progress: ',
                       suffix='Complete',
                       barLength=50)
     except:
         pass
     item = self.item
     for i in range(len(item)):
         top[i].data[...] = item[i]
     # properly terminate the sub process, once an epoch is finished
     if self.iterations == config.steps:
         self.process.terminate()
Exemplo n.º 2
0
        # gen mask
        ret = gen_masks(net,
                        img,
                        config,
                        dest_shape=(spider.origin_height, spider.origin_width),
                        image=args.debug)

        if args.useCats:
            ret_masks, ret_scores, ret_cats = ret
        else:
            ret_masks, ret_scores = ret

        printProgress(i,
                      len(ds),
                      prefix='Progress: ',
                      suffix='Complete',
                      barLength=50)
        for _ in range(len(ret_masks)):
            cat = 1
            if args.useCats:
                cat = spider.dataset.getCatIds()[int(ret_cats[_].argmax())]
                score = float(ret_cats[_].max())
            else:
                score = float(ret_scores[_])
            objn = float(ret_scores[_])
            results.append({
                'image_id': image_id,
                'category_id': cat,
                'segmentation': encode(ret_masks[_]),
                'score': score,
Exemplo n.º 3
0
    with open('results/%s.json' % args.model, 'rb') as f:
        input_results = cjson.decode(f.read())
        results = []
        _ = 0
        while _ < len(input_results):
            sub_results = []
            start = _
            while _ < len(input_results) and input_results[start][
                    'image_id'] == input_results[_]['image_id']:
                sub_results.append(input_results[_])
                _ += 1

            printProgress(_,
                          len(input_results),
                          'Results preprocess: ',
                          suffix='Complete',
                          barLength=50)

            sub_results.sort(key=lambda item: item['objn'], reverse=True)
            # nms
            keep = np.ones(len(sub_results)).astype(np.bool)
            if args.nms_threshold < 1:
                for i in range(len(sub_results)):
                    if keep[i]:
                        for j in range(i + 1, len(sub_results)):
                            if keep[j] and iou(sub_results[i]['segmentation'],
                                               sub_results[j]['segmentation'],
                                               [False]) > args.nms_threshold:
                                keep[j] = False