Closed ezreal1129 closed 6 years ago
Same with #34 . This is because the net is feed by no img data. Just following the README.md
to use tools/gen_posetrack_json.py
.
Your IM_DIR
should be the directory to your renamed images. For me, it's:
'posetrack_v1.0_train': {
IM_DIR: 'lib/datasets/data/PoseTrack/posetrack_data/images_renamed/',
ANN_FN: 'lib/datasets/lists/PoseTrack/v1.0/posetrack_train.json',
# ANN_DN: 'lib/datasets/data/PoseTrackV1.0_Annots_train_json/',
}
So on and so forth.
@yanxiangyi i fix it ,thank you very much
@ezreal1129 @yanxiangyi can you help me? my issue as #62 thanks~
i have same problem with #35 ,and my json_dataset.py as follow: ##############################################################
Copyright (c) 2018-present, Facebook, Inc.
All rights reserved.
#
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
##############################################################
from future import absolute_import from future import division from future import print_function from future import unicode_literals
import os import numpy as np import scipy.sparse import cPickle as pickle import copy from tqdm import tqdm import math
import utils.boxes as box_utils from utils.timer import Timer
COCO API
from pycocotools.coco import COCO from pycocotools import mask as COCOmask
from core.config import cfg from utils.general import static_vars
import logging logger = logging.getLogger(name)
IM_DIR = 'image_directory' ANN_FN = 'annotation_file'
Set to true if the ROIDB needs to be split into frames
SPLIT_INTO_FRAMES = 'split_into_frames'
Set to true if the frames need to be decoded from videos
FRAMES_FROM_VIDEO = 'frames_from_video'
Function to read from the weakly labeled outputs
COMPUTED_ANNOTATIONS_INFO = 'computed_annotations_info'
Optional annotation directory. Used to store additional stuff like for
jsons for posetrack evaluations
ANN_DN = 'annotation_directory' DATASETS = { 'posetrack_v1.0_train': { IM_DIR: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrack/', ANN_FN: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/lists/PoseTrack/v1.0/posetrack_train.json', ANN_DN: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrackV1.0_Annots_train_json/', }, 'posetrack_v1.0_val': { IM_DIR: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrack/', ANN_FN: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/lists/PoseTrack/v1.0/posetrack_val.json', ANN_DN: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrackV1.0_Annots_val_json', }, 'posetrack_v1.0_test': { IM_DIR: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrack/', ANN_FN: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/lists/PoseTrack/v1.0/posetrack_test.json', ANN_DN: '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrackV1.0_Annots_test_json', }, }
Important conventions for ROIDB
frame_id: 1-indexed. The reader is 0-indexed, so I make the conversion in
utils/image.py
class JsonDataset(object): def init(self, name): assert name in DATASETS.keys(), 'Unknown dataset name' logger.debug('Creating: {}'.format(name)) self.name = name self.image_directory = DATASETS[name][IM_DIR] self.debug_timer = Timer() self.COCO = COCO(DATASETS[name][ANN_FN]) self.annotation_directory = DATASETS[name][ANN_DN] if ANN_DN in \ DATASETS[name] else ''
Set up dataset classes
def _merge_proposal_boxes_into_roidb(roidb, box_list): assert len(box_list) == len(roidb) for i, entry in enumerate(roidb): boxes = box_list[i] num_boxes = boxes.shape[0] gt_overlaps = np.zeros( (num_boxes, entry['gt_overlaps'].shape[1]), dtype=entry['gt_overlaps'].dtype) box_to_gt_ind_map = -np.ones( (num_boxes), dtype=entry['box_to_gt_ind_map'].dtype)
def _filter_crowd_proposals(roidb, crowd_thresh): """Finds proposals that are inside crowd regions and marks them as overlap = -1 with each ground-truth rois, which means they will be excluded from training. """ for entry in roidb: gt_overlaps = entry['gt_overlaps'].toarray() crowd_inds = np.where(entry['is_crowd'] == 1)[0] non_gt_inds = np.where(entry['gt_classes'] == 0)[0] if len(crowd_inds) == 0 or len(non_gt_inds) == 0: continue crowd_boxes = box_utils.xyxy_to_xywh(entry['boxes'][crowd_inds, :]) non_gt_boxes = box_utils.xyxy_to_xywh(entry['boxes'][non_gt_inds, :]) iscrowd_flags = [int(True)] * len(crowd_inds) ious = COCOmask.iou(non_gt_boxes, crowd_boxes, iscrowd_flags) bad_inds = np.where(ious.max(axis=1) > crowd_thresh)[0] gt_overlaps[non_gt_inds[bad_inds], :] = -1 entry['gt_overlaps'] = scipy.sparse.csr_matrix(gt_overlaps)
def _add_class_assignments(roidb): for entry in roidb: gt_overlaps = entry['gt_overlaps'].toarray()
max overlap with gt over classes (columns)
def _sort_proposals(proposals, id_field): order = np.argsort(proposals[id_field]) fields_to_sort = ['boxes', id_field, 'scores'] for k in fields_to_sort: proposals[k] = [proposals[k][i] for i in order]
def add_proposals(roidb, rois, scales): """Add proposal boxes (rois) to an roidb that has ground-truth annotations but no proposals. If the proposals are not at the original image scale, specify the scale factor that separate them in scales. """ box_list = [] for i in range(len(roidb)): inv_im_scale = 1. / scales[i] idx = np.where(rois[:, 0] == i)[0] box_list.append(rois[idx, 1:] * inv_im_scale) _merge_proposal_boxes_into_roidb(roidb, box_list)
For historical consistency, not filter crowds (TODO(rbg): investigate)
def _assign_shard_id_to_roidb(roidb, num_splits, tot_vids): """ Returns: list with one element for each entry in roidb (shard_dir_name, (start_frame_id (0-indexed, included), end_frame_id (0-indexed, not included))) """ shards = [] vids_per_job = int(math.ceil(tot_vids / num_splits)) last_proc = 0 for start_id in range(num_splits): this_end_pos = min(last_proc + vids_per_job, tot_vids + 1) this_outdir = '{0:05d}range{1}_{2}'.format( start_id, last_proc, this_end_pos)
run through the entries that get assigned to this shard, and set
def pickle_cached_load(fpath, cache): if fpath in cache: return cache[fpath] with open(fpath, 'r') as fin: data = pickle.load(fin) cache.clear() cache[fpath] = data return data
@static_vars(weak_annot_cache={}) def _read_weak_annotations(shard_info, data_dir='', det_file_name='detections.pkl', fixed_str='test/kinetics_unlabeled_train/keypoint_rcnn'): det_fpath = os.path.join(data_dir, shard_info[0], fixed_str, det_file_name) data = pickle_cached_load(det_fpath, _read_weak_annotations.weak_annot_cache) boxes = data['all_boxes'][1][shard_info[1][0]: shard_info[1][1]] poses = data['all_keyps'][1][shard_info[1][0]: shard_info[1][1]] tracks = data['all_tracks'][1][shard_info[1][0]: shard_info[1][1]] assert(len(boxes) == len(poses)) assert(len(boxes) == len(tracks)) return {'boxes': boxes, 'poses': poses, 'tracks': tracks}
the '/home/amax/Documents/sangyi/DetectAndTrack/lib/datasets/data/PoseTrack/' is my image directory.
how can i fix it, i need anyone's help! thank you very muchi.
@rohitgirdhar