Skip to content

Commit

Permalink
GUIでバッチサイズを設定できるようにした
Browse files Browse the repository at this point in the history
CropSizeで出力が変わるモデルでCropSizeを変えずに高速化するため
  • Loading branch information
lltcggie committed Oct 24, 2018
1 parent 6effe0d commit 1428d36
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
4 changes: 3 additions & 1 deletion bin/lang/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,7 @@
"IDC_STATIC_USE_GPU_NO":"Use GPU No",
"IDC_RADIO_MODEL_UPCONV_RGB":"2-D illust (UpRGB Model)",
"IDC_RADIO_MODEL_UPCONV_PHOTO":"Photo (UpPhoto Model)",
"MessageLogFatalError":"A fatal error has occurred.\r\nThere is a possibility the split size is too large"
"MessageLogFatalError":"A fatal error has occurred.\r\nThere is a possibility the split size is too large",
"IDC_STATIC_BATCH_SIZE":"Batch size",
"MessageBatchSizeCheckError":"Batch size must be greater than 0",
}
4 changes: 3 additions & 1 deletion bin/lang/japanese.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,7 @@
"IDC_STATIC_USE_GPU_NO":"使用GPU No",
"IDC_RADIO_MODEL_UPCONV_RGB":"2次元イラスト (UpRGBモデル)",
"IDC_RADIO_MODEL_UPCONV_PHOTO":"写真・アニメ (UpPhotoモデル)",
"MessageLogFatalError":"致命的なエラーが発生しました。\r\n分割サイズが大きすぎる可能性があります"
"MessageLogFatalError":"致命的なエラーが発生しました。\r\n分割サイズが大きすぎる可能性があります",
"IDC_STATIC_BATCH_SIZE":"バッチサイズ",
"MessageBatchSizeCheckError":"バッチサイズは0より大きい整数である必要があります"
}
47 changes: 46 additions & 1 deletion waifu2x-caffe-gui/MainDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

const size_t AR_PATH_MAX(1024);

const int MaxBatchSizeList = 20;

const int MinCommonDivisor = 50;
const int DefaultCommonDivisor = 128;
const std::pair<int, int> DefaultCommonDivisorRange = {90, 140};
Expand All @@ -38,6 +40,7 @@ const TCHAR * const MultiFileStr = TEXT("(Multi File)");

const UINT_PTR nIDEventTimeLeft = 1000;


LangStringList DialogEvent::langStringList;
HWND DialogEvent::dh;

Expand Down Expand Up @@ -488,6 +491,22 @@ bool DialogEvent::SyncMember(const bool NotSyncCropSize, const bool silent)
}
}

{
TCHAR buf[AR_PATH_MAX] = TEXT("");
GetWindowText(GetDlgItem(dh, IDC_COMBO_BATCH_SIZE), buf, _countof(buf));
buf[_countof(buf) - 1] = TEXT('\0');

TCHAR *ptr = nullptr;
batch_size = _tcstol(buf, &ptr, 10);
if (!ptr || *ptr != '\0' || batch_size <= 0)
{
batch_size = 1;
ret = false;

MessageBox(dh, langStringList.GetString(L"MessageBatchSizeCheckError").c_str(), langStringList.GetString(L"MessageTitleError").c_str(), MB_OK | MB_ICONERROR);
}
}

use_tta = SendMessage(GetDlgItem(dh, IDC_CHECK_TTA), BM_GETCHECK, 0, 0) == BST_CHECKED;

return ret;
Expand Down Expand Up @@ -1116,6 +1135,8 @@ void DialogEvent::SaveIni(const bool isSyncMember)

WritePrivateProfileString(TEXT("Setting"), TEXT("LastInputDirFix"), tInputDirFix.c_str(), getTString(SettingFilePath).c_str());
WritePrivateProfileString(TEXT("Setting"), TEXT("LastOutputDirFix"), tOutputDirFix.c_str(), getTString(SettingFilePath).c_str());

WritePrivateProfileString(TEXT("Setting"), TEXT("LastBatchSize"), to_tstring(batch_size).c_str(), getTString(SettingFilePath).c_str());
}

struct stFindParam
Expand Down Expand Up @@ -1596,6 +1617,7 @@ void DialogEvent::SetWindowTextLang()
SET_WINDOW_TEXT(IDC_BUTTON_OUTPUT_REF);
SET_WINDOW_TEXT(IDC_BUTTON_APP_SETTING);
SET_WINDOW_TEXT(IDC_BUTTON_CLEAR_OUTPUT_DIR);
SET_WINDOW_TEXT(IDC_STATIC_BATCH_SIZE);

#undef SET_WINDOW_TEXT

Expand Down Expand Up @@ -1794,6 +1816,21 @@ void DialogEvent::Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
}
}

{
HWND hbatch = GetDlgItem(dh, IDC_COMBO_BATCH_SIZE);

// バッチサイズリストに数列を突っ込んでいく
int mindiff = INT_MAX;
int defaultListIndex = -1;
for(int i = 1; i <= MaxBatchSizeList; i++)
{
tstring str(to_tstring(i));
SendMessage(hbatch, CB_ADDSTRING, 0, (LPARAM)str.c_str());
}

SendMessage(hbatch, CB_SETCURSEL, 0, 0);
}

{
HWND hcrop = GetDlgItem(dh, IDC_COMBO_CROP_SIZE);

Expand Down Expand Up @@ -1896,6 +1933,8 @@ void DialogEvent::Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
GetPrivateProfileString(TEXT("Setting"), TEXT("LastOutputDirFix"), TEXT(""), tmp, _countof(tmp), getTString(SettingFilePath).c_str());
tmp[_countof(tmp) - 1] = TEXT('\0');
tOutputDirFix = tmp;

batch_size = GetPrivateProfileInt(TEXT("Setting"), TEXT("LastBatchSize"), 1, getTString(SettingFilePath).c_str());
}

TCHAR *ptr = nullptr;
Expand Down Expand Up @@ -2069,6 +2108,11 @@ void DialogEvent::Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
else
SendMessage(GetDlgItem(hWnd, IDC_CHECK_TTA), BM_SETCHECK, BST_UNCHECKED, 0);

if (1 <= batch_size && batch_size <= MaxBatchSizeList)
{
SendMessage(GetDlgItem(dh, IDC_COMBO_BATCH_SIZE), CB_SETCURSEL, batch_size - 1, 0);
}

SetWindowText(GetDlgItem(hWnd, IDC_EDIT_SCALE_RATIO), tScaleRatio.c_str());
SetWindowText(GetDlgItem(hWnd, IDC_EDIT_SCALE_WIDTH), tScaleWidth.c_str());
SetWindowText(GetDlgItem(hWnd, IDC_EDIT_SCALE_HEIGHT), tScaleHeight.c_str());
Expand Down Expand Up @@ -2440,7 +2484,8 @@ void DialogEvent::Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)

if (cmdBatchSizeFile.isSet())
{
batch_size = cmdBatchSizeFile.getValue();
SetWindowText(GetDlgItem(dh, IDC_COMBO_CROP_SIZE), to_tstring(cmdCropSizeFile.getValue()).c_str());
//batch_size = cmdBatchSizeFile.getValue();

isSetParam = true;
}
Expand Down
Binary file modified waifu2x-caffe-gui/Resource.rc
Binary file not shown.
Binary file modified waifu2x-caffe-gui/resource.h
Binary file not shown.

0 comments on commit 1428d36

Please sign in to comment.