mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 21:52:49 +00:00
拡張子の大文字小文字を無視するようにした
This commit is contained in:
parent
6989f81f4e
commit
22bbffe1d8
@ -2,12 +2,14 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Commctrl.h>
|
#include <Commctrl.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@ -233,7 +235,11 @@ private:
|
|||||||
tokenizer tokens(inputFileExt, sep);
|
tokenizer tokens(inputFileExt, sep);
|
||||||
|
|
||||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||||
extList.push_back("." + *tok_iter);
|
{
|
||||||
|
std::string ext(*tok_iter);
|
||||||
|
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||||
|
extList.push_back("." + ext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NotSyncCropSize)
|
if (!NotSyncCropSize)
|
||||||
@ -268,16 +274,22 @@ private:
|
|||||||
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(input_path),
|
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(input_path),
|
||||||
boost::filesystem::recursive_directory_iterator()))
|
boost::filesystem::recursive_directory_iterator()))
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(p) && std::find(extList.begin(), extList.end(), p.extension().string()) != extList.end())
|
|
||||||
|
if (!boost::filesystem::is_directory(p))
|
||||||
{
|
{
|
||||||
auto mat = Waifu2x::LoadMat(p.string());
|
std::string ext(p.extension().string());
|
||||||
if (mat.empty())
|
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||||
continue;
|
if (std::find(extList.begin(), extList.end(), ext) != extList.end())
|
||||||
|
{
|
||||||
|
auto mat = Waifu2x::LoadMat(p.string());
|
||||||
|
if (mat.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto size = mat.size();
|
auto size = mat.size();
|
||||||
mat.release();
|
mat.release();
|
||||||
|
|
||||||
gcd = boost::math::gcd(size.width, size.height);
|
gcd = boost::math::gcd(size.width, size.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,14 +388,19 @@ private:
|
|||||||
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(path),
|
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::recursive_directory_iterator(path),
|
||||||
boost::filesystem::recursive_directory_iterator()))
|
boost::filesystem::recursive_directory_iterator()))
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(p) && std::find(extList.begin(), extList.end(), p.extension().string()) != extList.end())
|
if (!boost::filesystem::is_directory(p))
|
||||||
{
|
{
|
||||||
const auto out_relative = relativePath(p, input_path);
|
std::string ext(p.extension().string());
|
||||||
const auto out_absolute = output_path / out_relative;
|
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||||
|
if (std::find(extList.begin(), extList.end(), ext) != extList.end())
|
||||||
|
{
|
||||||
|
const auto out_relative = relativePath(p, input_path);
|
||||||
|
const auto out_absolute = output_path / out_relative;
|
||||||
|
|
||||||
const auto out = (out_absolute.branch_path() / out_absolute.stem()).string() + outputExt;
|
const auto out = (out_absolute.branch_path() / out_absolute.stem()).string() + outputExt;
|
||||||
|
|
||||||
file_paths.emplace_back(p.string(), out);
|
file_paths.emplace_back(p.string(), out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <algorithm>
|
||||||
#include <tclap/CmdLine.h>
|
#include <tclap/CmdLine.h>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@ -179,7 +180,11 @@ int main(int argc, char** argv)
|
|||||||
tokenizer tokens(cmdInputFileExt.getValue(), sep);
|
tokenizer tokens(cmdInputFileExt.getValue(), sep);
|
||||||
|
|
||||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||||
extList.push_back("." + *tok_iter);
|
{
|
||||||
|
std::string ext(*tok_iter);
|
||||||
|
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||||
|
extList.push_back("." + ext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 変換する画像の入力、出力パスを取得
|
// 変換する画像の入力、出力パスを取得
|
||||||
@ -202,14 +207,19 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (std::find(extList.begin(), extList.end(), p.extension().string()) != extList.end())
|
else
|
||||||
{
|
{
|
||||||
const auto out_relative = relativePath(p, input_path);
|
std::string ext(p.extension().string());
|
||||||
const auto out_absolute = output_path / out_relative;
|
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
|
||||||
|
if (std::find(extList.begin(), extList.end(), ext) != extList.end())
|
||||||
|
{
|
||||||
|
const auto out_relative = relativePath(p, input_path);
|
||||||
|
const auto out_absolute = output_path / out_relative;
|
||||||
|
|
||||||
const auto out = (out_absolute.branch_path() / out_absolute.stem()).string() + outputExt;
|
const auto out = (out_absolute.branch_path() / out_absolute.stem()).string() + outputExt;
|
||||||
|
|
||||||
file_paths.emplace_back(p.string(), out);
|
file_paths.emplace_back(p.string(), out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user