BicycleGAN icon indicating copy to clipboard operation
BicycleGAN copied to clipboard

Regarding Training your Own Images

Open kuruvilla2087 opened this issue 3 years ago • 4 comments

Hi Juyanz,

How are you !hope all is fine .

I want to train this algo on different images ,I was thinking how to train them on self images , 1)What pre-processing steps do i need to take here .Can you please guide me .? 2)The model is not saving to any directory ,Can you please let know where the trained model saves(for our own images) ?

kuruvilla2087 avatar Jul 06 '21 04:07 kuruvilla2087

Hello Abraham, I'm also trying to do the same thing and find a way to train our own images.

The dataset structure required here should be like: datasetsample

The way to make this kind of dataset you can refer to the image pre-processing method offered by the author @junyanz here: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/datasets.md

  1. Create folder /path/to/data with subfolders A and B. A and B should each have their own subfolders train, val, test, etc. In /path/to/data/A/train, put training images in style A. In /path/to/data/B/train, put the corresponding images in style B. Repeat same for other data splits (val, test, etc). ( Corresponding images in a pair {A,B} must be the same size and have the same filename, e.g., /path/to/data/A/train/1.jpg is considered to correspond to /path/to/data/B/train/1.jpg. )

  2. Once the data is formatted this way, call:

python path/to/combine_A_and_B.py --fold_A /path/to/data/A --fold_B /path/to/data/B --fold_AB /path/to/data

This will combine each pair of images (A,B) into a single image file, which is the dataset ready for training the BicycleGAN.

combine_A_and_B.py file can be found here: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/datasets/combine_A_and_B.py

twentyfiveYang avatar Jul 19 '21 14:07 twentyfiveYang

Hi yang,

Thanks for preprocessing steps ,I will check this.

1.By the way how do we create input images from ground truth images ( I am creating edges from the ground truth for now )? 2.Also how do we control color generation from the model ?

On Mon, 19 Jul 2021, 19:42 twentyfiveYang, @.***> wrote:

Hello Abraham, I'm also trying to do the same thing and find a way to train our own images.

The dataset structure required here should be like: [image: datasetsample] https://user-images.githubusercontent.com/20677807/126171935-14d53473-5f7d-4c38-8d9f-61743f852861.png

The way to make this kind of dataset you can refer to the image pre-processing method offered by the author @junyanz https://github.com/junyanz here: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/datasets.md

Create folder /path/to/data with subfolders A and B. A and B should each have their own subfolders train, val, test, etc. In /path/to/data/A/train, put training images in style A. In /path/to/data/B/train, put the corresponding images in style B. Repeat same for other data splits (val, test, etc). ( Corresponding images in a pair {A,B} must be the same size and have the same filename, e.g., /path/to/data/A/train/1.jpg is considered to correspond to /path/to/data/B/train/1.jpg. ) 2.

Once the data is formatted this way, call:

python path/to/combine_A_and_B.py --fold_A /path/to/data/A --fold_B /path/to/data/B --fold_AB /path/to/data

This will combine each pair of images (A,B) into a single image file, which is the dataset ready for training the BicycleGAN.

combine_A_and_B.py file can be found here:

https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/datasets/combine_A_and_B.py

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/junyanz/BicycleGAN/issues/94#issuecomment-882581739, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJK54CITKBGK2OED2XPGF73TYQXDJANCNFSM473YQ2RA .

kuruvilla2087 avatar Jul 19 '21 18:07 kuruvilla2087

Thanks @twentyfiveYang. This post helped. I guess many would keep the same directory structure as in CycleGAN as nothing is mentioned in the official readme.

AvirupJU avatar Feb 02 '22 04:02 AvirupJU

Thanks for the reply. It follows the pix2pix directory structure rather than CycleGAN's.

junyanz avatar Mar 09 '22 07:03 junyanz