Home

Awesome

Pytorch_CamouflageImages

Generate Camouflage Images by Pytorch

Sample

this implementation is mainly based on Deep Camouflage Images

Usage

Setup Environment

<details> <summary> Dependencies </summary> </details>

In the case of conda.

conda create -n camouflage python=3.8
conda activate camouflage

and then, install pytorch / torchvision, reference to official website

finally, install dependent libraries

pip install -r requirements.txt

Test

python camouflage_HRNet.py --params <path to parameter python file>

For quick test, you can generate camouflage images by python camouflage_HRNet.py --params params_Canyon

Here is process window

cliff|

Preparaion

For custom images, you should prepare

Parameters

initial setting

- input_path : path to foreground image
- mask_path : path to foreground image mask
- bg_path : path to background image
- output_dir : directory for generated images
- name : prefix name for generated image
- seed : pytorch seed

mask setting

- mask_scale : scale ratio for foreground image mask
- crop : crop foreground image mask to bounding box
- hidden_selected : If None, use hidden recommendation. If you wouldn't like to use hidden recommendation, you should give [y1_start,x1_start] for this parameter

train setting

- epoch : iteration for training
- lr : learning rate for adam

loss setting

- erode_border : If True, erode attention map
- style_weight_dic : dictionary of weights for style loss
- style_all : If True, use all background image for style loss. If False, use corresponding background image for style loss.
- alpha1 : scale parameter for leave loss
- alpha2 : scale parameter for remove loss
- mu : ratio of remove loss for camouflage loss
- lambda_weights : dictionary of weights for all loss

log setting

- show_every : interval for displaying intermediate result
- save_process : If True, save intermediate result by every `show_every`
- show_comp : compressino ratio for display

Influence by loss function

According to Deep Camouflage Images, losses has following impact for generated image:

stylestyle+cam
stylestyle+cam
style+cam+regstyle+cam+reg+tv
style+cam+regstyle+cam+reg+tv

Gallary

SeaMountainCliffRiver
seamountaincliffriver
MountainCliff
mountaincanyon