Skip to content

Hurricane-k/Replay-HowToRunFFCConYourPC

Repository files navigation

Replay: run Fast Fourier Color Constancy (FFCC MATLAB Toolkit) on Windows

Background

I was curious about FFCC(Fast Fourier Color Constancy). However, the original version is based on Linux. The issuses of Pathes stops from running the inital code smoothly. I take down the process of modify code in case you encounter the same problems.

Firstly download Fast Fourier Color Constancy Matlab Toolbox and minFunc library from Mark Schmidt.

Configuration

  1. MATLAB 2023b
  2. Windows 11

Goals

  1. focus on the cross-camera (agnostic) performance, modify the code can test the performance of the ffcc model trained by Cam A on the Cam B dataset.
  2. statistic results of cross-validation.

How to use them

  1. When tuning hyperparamter for new Dataset, run Tune_mainfunc.m instead of Tune.m. Change line 8 and line 9 to set DataSet.
  2. When test (cross-validation), run Test_CV_main.m. Change line 11-13 to set the model and test DataSet.

    NameLabel is easy to distinguish different DataSet, for example Gehler-Shi or NUS.
    NameCamdst you can regard as the test dataset that might be agnostic to the model. when strcmp(NameCamdst, NameCamsrc) == 1, test dataset and train dataset are from the same domain.
    NameCamsrc you can regard as the dataset used to tuning hyperparameters and train model.

  3. Visulaization.m is not my target. Cannot make sure it would be gonna work.
  4. Change_DataPath.m to automatically change the script DataPath.m in \internal\.
  5. params.HISTOGRAM.STARTING_UV is one hyperparameter that the inital code skip to tune. When load New Dataset, it is possible to warn.

    Change_PrecomputeTrainingData('Tune') means to correct this value to ignore the warning as much as possible.
    Change_PrecomputeTrainingData('Test') means to comment out the code related to this.

  6. in .\projects\, DefaultConstants.m and DefaultHyperparams.m is to initialization for the first time to tune hyperparameters for new Dataset.
  7. demo dataset in \data\ is data_NUS_Canon1DsMkIII, the structure of data fold follows the inital version.

Details that should be modified

  1. in /internal/DataPath.m, two variables paths.gehler_shi and paths.cheng should be corrected based on your env.

  2. When you set project_name in Train.m, Visualization.m, and Visualization.m as Folder Names in \projects, like project_name='GehlerShi', no need to generate data followed by Preparation and Folder Structure because training data are directly linked to /data/cheng/preprocessed or /data/shi_gehler/preprocessed.
    You can set project_name as 'ChengCanon1DsMkIII', ChengCanon600D, etc, but project_name = 'Cheng' fails because one .m necessary file misses.

  3. In PrivateConstants.m, from Line 20 to Line 28 need to change if your plantform is Windows. I slightly change them in order to make them run smoothly on both systems.

if ~ispc()
    params.TRAINING.OUTPUT_MODEL_FOLDER = 'models/';
else 
    params.TRAINING.OUTPUT_MODEL_FOLDER = 'models\';
end
warning off all

if ~ispc()
    system(['mkdir ', params.TRAINING.OUTPUT_MODEL_FOLDER, ' &> /dev/null']);
else
    system(['mkdir ', params.TRAINING.OUTPUT_MODEL_FOLDER, ' > nul 2>&1']);
end
warning on all;

if ~ispc() 
    params.TRAINING.OUTPUT_VISUALIZATION_ROOT = 'vis/';
else 
    params.TRAINING.OUTPUT_VISUALIZATION_ROOT = 'vis\';
end
warning off all

if ~ispc()
    system(['mkdir ', params.TRAINING.OUTPUT_VISUALIZATION_ROOT, ' &> /dev/null']);
else
    system(['mkdir ', params.TRAINING.OUTPUT_VISUALIZATION_ROOT, ' > nul 2>&1']);
end
warning on all;
  1. in PrecomputerTraining.m in ./internal, line 34 should be corrected based on platforms, otherwise it fails to find the training folder on Windows.
  if ~ispc()
    print_name = folder(1+find(folder(1:end-1) == '/', 1, 'last'):end);
  else
    print_name = folder(1+find(folder(1:end-1) == '\', 1, 'last'):end);
  end
  1. in ScrapeFolder.m in ./internal, In terms of Line 52, it fails to work well for MATLAB Win ver. it cannot seperate subfolders well. it should be modified for Windows platforms well.

    % [subfolder, subfolder_string] = strtok(subfolder_string, ':');
    [subfolder, subfolder_string] = strtok(subfolder_string, ';');
    
  2. in ChengSonyA57Constants.m in ./projects/. the variable params.TRAINING.CROSSVALIDATION_DATA_FOLDER should be modified. Line 23 and Line 24, the absolute path fails to work when you set project_name='ChengAS57'.

    paths = DataPaths;
    params.TRAINING.CROSSVALIDATION_DATA_FOLDER ...
      = fullfile(paths.cheng, 'preprocessed/Cheng/SonyA57/');
    

    similarly, in ChengSonyA57ThumbConstants.m in ./projects/, the variable should be modified especially when you wanna train ChengSongyA57 Thumb DataSet.

  3. If you set project_name = Cheng, Train.m, Tune.m and Visualize.m does not work because there is no ChengHyperparams.m. You need to Tune to get the ooptimal hyperparameters for the whole Cheng Dataset (cross-camera). But there is no DefaultConstants.m like DefaultHyperparams.m in the initial version it means that if you use other dataset, it would abort. Don't worry, I set one for the first time to tune hyperparameters for new dataset.

About

How to run Fast Fourier Color Constancy on your PC

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors