下のプログラムの下から7行目のfor文の意味が分かりません。
for category(変数)in coco_json['categories']:
coco_jsonはファイルを定義しているので、
coco_jsonの中に'categories'の個数が複数あり, それをfor文でループ処理しているということでしょうか。
file['name']のような書き方のときに何を示しているのか、
教えていただきたく思います。
class CocoLikeDataset(utils.Dataset): """ Generates a COCO-like dataset, i.e. an image dataset annotated in the style of the COCO dataset. See http://cocodataset.org/#home for more information. """ def load_data(self, annotation_json, images_dir): """ Load the coco-like dataset from json Args: annotation_json: The path to the coco annotations json file images_dir: The directory holding the images referred to by the json file """ # Load json from file json_file = open(annotation_json) coco_json = json.load(json_file) json_file.close() # Add the class names using the base method from utils.Dataset source_name = "coco_like" for category in coco_json['categories']: class_id = category['id'] class_name = category['name'] if class_id < 1: print('Error: Class id for "{}" cannot be less than one. (0 is reserved for the background)'.format(class_name)) return self.add_class(source_name, class_id, class_name)
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/10 00:59