55#include < ctime>
66#include < iomanip>
77#include < filesystem>
8+ #include " Filehelper.h"
89
910using namespace Windows ::AI::MachineLearning;
1011
@@ -35,7 +36,8 @@ void CommandLineArgs::PrintUsage()
3536 " will output all measurements"
3637 << std::endl;
3738 std::cout << " -Iterations : # times perf measurements will be run/averaged. (maximum: 1024 times)" << std::endl;
38- std::cout << " -Input <fully qualified path> : binds image or CSV to model" << std::endl;
39+ std::cout << " -Input <path to input file>: binds image or CSV to model" << std::endl;
40+ std::cout << " -InputImageFolder <path to directory of images> : specify folder of images to bind to model" << std::endl;
3941 std::cout << " -TopK <number> : print top <number> values in the result. Default to 1" << std::endl;
4042 std::cout << " -BaseOutputPath [<fully qualified path>] : base output directory path for results, default to cwd"
4143 << std::endl;
@@ -139,7 +141,13 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring>& args)
139141 }
140142 else if ((_wcsicmp (args[i].c_str (), L" -Input" ) == 0 ))
141143 {
142- m_inputData = args[++i];
144+ CheckNextArgument (args, i);
145+ m_inputData = FileHelper::GetAbsolutePath (args[++i]);
146+ }
147+ else if ((_wcsicmp (args[i].c_str (), L" -InputImageFolder" ) == 0 ))
148+ {
149+ CheckNextArgument (args, i);
150+ m_inputImageFolderPath = FileHelper::GetAbsolutePath (args[++i]);
143151 }
144152 else if ((_wcsicmp (args[i].c_str (), L" -PerfOutput" ) == 0 ))
145153 {
@@ -326,7 +334,7 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring>& args)
326334 if (m_inputData.find (L" .png" ) != std::string::npos || m_inputData.find (L" .jpg" ) != std::string::npos ||
327335 m_inputData.find (L" .jpeg" ) != std::string::npos)
328336 {
329- m_imagePath = m_inputData;
337+ m_imagePaths. push_back ( m_inputData) ;
330338 }
331339 else if (m_inputData.find (L" .csv" ) != std::string::npos)
332340 {
@@ -339,12 +347,31 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring>& args)
339347 throw hresult_invalid_argument (msg.c_str ());
340348 }
341349 }
342-
350+ if (!m_inputImageFolderPath.empty ())
351+ {
352+ PopulateInputImagePaths ();
353+ }
343354 SetupOutputDirectories (sBaseOutputPath , sPerfOutputPath , sPerIterationDataPath );
344355
345356 CheckForInvalidArguments ();
346357}
347358
359+ void CommandLineArgs::PopulateInputImagePaths ()
360+ {
361+ for (auto & it : std::filesystem::directory_iterator (m_inputImageFolderPath))
362+ {
363+ std::string path = it.path ().string ();
364+ if (it.path ().string ().find (" .png" ) != std::string::npos ||
365+ it.path ().string ().find (" .jpg" ) != std::string::npos ||
366+ it.path ().string ().find (" .jpeg" ) != std::string::npos)
367+ {
368+ std::wstring fileName;
369+ fileName.assign (path.begin (), path.end ());
370+ m_imagePaths.push_back (fileName);
371+ }
372+ }
373+ }
374+
348375void CommandLineArgs::SetupOutputDirectories (const std::wstring& sBaseOutputPath ,
349376 const std::wstring& sPerfOutputPath ,
350377 const std::wstring& sPerIterationDataPath )
@@ -420,4 +447,8 @@ void CommandLineArgs::CheckForInvalidArguments()
420447 {
421448 throw hresult_invalid_argument (L" Cannot save tensor output if no input data is provided!" );
422449 }
450+ if (m_imagePaths.size () > 1 && IsSaveTensor ())
451+ {
452+ throw hresult_not_implemented (L" Saving tensor output for multiple images isn't implemented." );
453+ }
423454}
0 commit comments