Merge pull request #3613 from futz12/train-tools-cpp11-fix

修复train demo使用了cpp11以上标准的代码导致无法编译
This commit is contained in:
jxt1234 2025-06-13 13:24:09 +08:00 committed by GitHub
commit dcb8cc7cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ public:
auto converImagesToFormat = CV::RGB;
int resizeHeight = 224;
int resizeWidth = 224;
std::vector<float> scales = {1/255.0, 1/255.0, 1/255.0};
std::vector<float> scales = {1/255.0f, 1/255.0f, 1/255.0f};
std::shared_ptr<ImageDataset::ImageConfig> config(ImageDataset::ImageConfig::create(converImagesToFormat, resizeHeight, resizeWidth, scales));
bool readAllImagesToMemory = false;
auto dataset = ImageDataset::create(pathToImages, pathToImageTxt, config.get(), readAllImagesToMemory);

View File

@ -84,7 +84,7 @@ void _train(std::shared_ptr<Module> origin, std::shared_ptr<Module> optmized, st
int resizeHeight = 224;
int resizeWidth = 224;
std::vector<float> means = {127.5, 127.5, 127.5};
std::vector<float> scales = {1/127.5, 1/127.5, 1/127.5};
std::vector<float> scales = {1/127.5f, 1/127.5f, 1/127.5f};
std::vector<float> cropFraction = {0.875, 0.875}; // center crop fraction for height and width
bool centerOrRandomCrop = false; // true for random crop
std::shared_ptr<ImageDataset::ImageConfig> datasetConfig(ImageDataset::ImageConfig::create(converImagesToFormat, resizeHeight, resizeWidth, scales, means, cropFraction, centerOrRandomCrop));