Function mindspore::dataset::DIV2K

Function Documentation

inline std::shared_ptr<DIV2KDataset> mindspore::dataset::DIV2K(const std::string &dataset_dir, const std::string &usage, const std::string &downgrade, int32_t scale, bool decode = false, const std::shared_ptr<Sampler> &sampler = std::make_shared<RandomSampler>(), const std::shared_ptr<DatasetCache> &cache = nullptr)

Function to create a DIV2KDataset.

Note

The generated dataset has two columns [“hr_image”, “lr_image”].

Parameters
  • dataset_dir[in] The dataset dir to be read.

  • usage[in] The type of dataset. Acceptable usages include “train”, “valid” or “all”.

  • downgrade[in] The mode of downgrade. Acceptable downgrades include “bicubic”, “unknown”, “mild”, “difficult” or “wild”.

  • scale[in] The scale of downgrade. Acceptable scales include 2, 3, 4 or 8.

  • decode[in] Decode the images after reading (default=false).

  • 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).

Returns

Shared pointer to the current DIV2KDataset.

样例
/* Define dataset path and MindData object */
std::string dataset_path = "/path/to/div2k_dataset_directory";
std::shared_ptr<Dataset> ds = DIV2K(dataset_path, "train", "bicubic", 2);

/* Create iterator to read dataset */
std::shared_ptr<Iterator> iter = ds->CreateIterator();
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);

/* Note: In DIV2K dataset, each dictionary has keys "hr_image" and "lr_image" */
auto hr_image = row["hr_image"];