Function mindspore::dataset::Coco

Function Documentation

inline std::shared_ptr<CocoDataset> mindspore::dataset::Coco(const std::string &dataset_dir, const std::string &annotation_file, const std::string &task = "Detection", const bool &decode = false, const std::shared_ptr<Sampler> &sampler = std::make_shared<RandomSampler>(), const std::shared_ptr<DatasetCache> &cache = nullptr, const bool &extra_metadata = false)

Function to create a CocoDataset.

Note

The generated dataset has multi-columns :

  • task=’Detection’, column: [[‘image’, dtype=uint8], [‘bbox’, dtype=float32], [‘category_id’, dtype=uint32], [‘iscrowd’, dtype=uint32]].

  • task=’Stuff’, column: [[‘image’, dtype=uint8], [‘segmentation’,dtype=float32], [‘iscrowd’, dtype=uint32]].

  • task=’Keypoint’, column: [[‘image’, dtype=uint8], [‘keypoints’, dtype=float32], [‘num_keypoints’, dtype=uint32]].

  • task=’Panoptic’, column: [[‘image’, dtype=uint8], [‘bbox’, dtype=float32], [‘category_id’, dtype=uint32], [‘iscrowd’, dtype=uint32], [‘area’, dtype=uitn32]].

Parameters
  • dataset_dir[in] Path to the root directory that contains the dataset.

  • annotation_file[in] Path to the annotation json.

  • task[in] Set the task type of reading coco data, now support ‘Detection’/’Stuff’/’Panoptic’/’Keypoint’.

  • decode[in] Decode the images after reading.

  • sampler[in] Shared pointer to a sampler object used to choose samples from the dataset. If sampler is not given, a RandomSampler will be used to randomly iterate the entire dataset (default = RandomSampler()).

  • cache[in] Tensor cache to use (default=nullptr which means no cache is used).

  • extra_metadata[in] Flag to add extra meta-data to row. (default=false)

Returns

Shared pointer to the CocoDataset.