Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train your own dataset #222

Open
hydwjy opened this issue Jul 31, 2022 · 1 comment
Open

Train your own dataset #222

hydwjy opened this issue Jul 31, 2022 · 1 comment

Comments

@hydwjy
Copy link

hydwjy commented Jul 31, 2022

I want to train my dataset and what to do

@Ahmadreza1365
Copy link

Ahmadreza1365 commented Sep 4, 2023

If you have your own dataset, you need to prepare them as follow:
let's say you have a folder called "blurred_sharp" in the directory that you cloned "DeblurGAN-master".
you make two sub-folders and let's call them "blurred" and "sharp". In each of these folders, again you need to make two subfolders and call them "train" and "test". So now you have:

-DeblurGAN-master

- blurred_sharp

  - blurred
      - train
      - test
    
  - sharp
      - train
      - test

You need to put your sharp and blurred images in these folders accordingly. Make sure for example, when you put the blurred image, in the "..\blurred\train" folder, you put it's associate sharp image in "..\sharp\train" folder.

Now you need to create another folder, let's call it "combine" and put it in the following directory:
..\DeblurGAN-master\blurred_sharp\combine

via cmd or VScode (any platform that you are using) go to the "DeblurGAN-master" folder and "run combine_A_and_B.py". below is an example:

python datasets/combine_A_and_B.py --fold_A "C:\TEMP\DeblurGAN-master\blurred_sharp\blurred" --fold_B "C:\TEMP\DeblurGAN-master\blurred_sharp\sharp" --fold_AB "C:\TEMP\DeblurGAN-master\blurred_sharp\combine"

It will create two subfolders (train and test) in the "combine" folder that you created earlier. You will see the blurred and sharp images concatenated.


Now make sure you have visdom package correctly installed in your python.
Then open cmd and run:

python -m visdom.server

you will probably get the following message:


Checking for scripts.
It's Alive!
INFO:root:Application Started
INFO:root:Working directory: C:\Users\u109980.visdom
You can navigate to http://localhost:8097

Then copy/paste "http://localhost:8097" in your browser to be able to monitor the training progress.

now you can run the following code for training:

python train.py --dataroot "C:\TEMP\DeblurGAN-master\blurred_sharp\combine" --learn_residual --resize_or_crop crop --fineSize 256


When the training is completed after 300 epochs, put your test images in a folder (let's say "..\DeblurGAN-master\TEST" ).
Now you can test it with the following command.

python test.py --dataroot "C:\TEMP_TEST\DeblurGAN-master\TEST" --model test --dataset_mode single --learn_residual

remember if your device cannot handle parallel processing, in the "test.py" change the number of threads to zero as follow:
opt.nThreads = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants