Giter VIP home page Giter VIP logo

Comments (12)

ianni67 avatar ianni67 commented on May 21, 2024 4

you have to set the desired width and height in config.py and songToData.py
[EDIT: >THIS IS WRONG!]

from pytorch-cyclegan-and-pix2pix.

junyanz avatar junyanz commented on May 21, 2024 2

It only depends on the generator. You are free to use 'resnet_6blocks' or 'resnet_9blocks' which should support some rectangular inputs. I think 'unet_128' and 'unet_256' only support square input images. There are other workaround solutions. (1) You can load the image as rectangular images, and crop square patches for example. Or (2) resize the image to a square image, run the training/test, and resize the result back to the original rectangular image during the test time.

from pytorch-cyclegan-and-pix2pix.

ianni67 avatar ianni67 commented on May 21, 2024 1

yeah you get this error because you're using the "aligned" mode, but the code in my fork is only modified to work on rectangular images with the "unaligned" mode.

from pytorch-cyclegan-and-pix2pix.

yeguixin avatar yeguixin commented on May 21, 2024

I try to modify the aligned_dataset.py as follows:

    AB = AB.resize((160 * 2, 70), Image.BICUBIC)
    AB = self.transform(AB)

    self.opt.loadSize = 160
    self.opt.fineSize = 160

Here the size of my image is 160*70pix,but error occurs when runing train.py. The erroe messagge is:
RuntimeError: CUDNN_STATUS_BAD_PARAM
I don't know where is wrong. Did you solved it? @ianni67
In addition, can the program only to train square images? @junyanz
Thank you.

from pytorch-cyclegan-and-pix2pix.

junyanz avatar junyanz commented on May 21, 2024

The current code assumes width==height. However, it is possible to modify the code to work on the rectangular cases. You need to modify the dataset class under /data subdirectory.

from pytorch-cyclegan-and-pix2pix.

ianni67 avatar ianni67 commented on May 21, 2024

Thank you very much for your kind response. I made a fork of the project, where I'm playing with the code. I hope you don't mind. If I find anything useful, I'll let you know.
Currently my main change actually implements the change in the size of the slices, as described in the changelog.

from pytorch-cyclegan-and-pix2pix.

yeguixin avatar yeguixin commented on May 21, 2024

Can the forking project train the rectangle images? If it can, how to set the options? @junyanz

from pytorch-cyclegan-and-pix2pix.

yeguixin avatar yeguixin commented on May 21, 2024

Thanks. But I didn't find the config.py and songToData.py in the project. Could you give me a link? Thanks again.

from pytorch-cyclegan-and-pix2pix.

ianni67 avatar ianni67 commented on May 21, 2024

I'm very sorry. I got confused in my previous post, as I have two related projects with similar issues.
The height has to be passed as a parameter in your command line, see the file base_options.py in the options folder.
Also make sure that --resize_or_crop is set to no-resize
and the no-flip switch is set in your command line.

from pytorch-cyclegan-and-pix2pix.

yeguixin avatar yeguixin commented on May 21, 2024

Got it. Thanks for your timely replay. Suppose the size of the image is 160*70pix. I can set in the command line as "--loadSize 160 --loadHeight 70 --resize_or_crop no_resize no_flip". Isn't is?
When I train the mode as follows, the error occurs:

python train.py --dataroot ./datasets/captcha/ --name captcha_mdoel --model pix2pix --which_model_netG unet_256 --which_direction AtoB --lambda_A 100 --dataset_mode aligned --use_dropout --no_lsgan --norm batch --loadSize 100 --loadHeight 70 --resize_or_crop no_resize --no_flip

errors:

CustomDatasetDataLoader
dataset [AlignedDataset] was created
Traceback (most recent call last):
File "train.py", line 8, in
data_loader = CreateDataLoader(opt)
File "/home/gxy/kx/program/pytorch-CycleGAN-and-pix2pix/data/data_loader.py", line 6, in CreateDataLoader
data_loader.initialize(opt)
File "/home/gxy/kx/program/pytorch-CycleGAN-and-pix2pix/data/custom_dataset_data_loader.py", line 30, in initialize
self.dataset = CreateDataset(opt)
File "/home/gxy/kx/program/pytorch-CycleGAN-and-pix2pix/data/custom_dataset_data_loader.py", line 20, in CreateDataset
dataset.initialize(opt)
File "/home/gxy/kx/program/pytorch-CycleGAN-and-pix2pix/data/aligned_dataset.py", line 18, in initialize
assert(opt.resize_or_crop == 'resize_and_crop')
AssertionError

from pytorch-cyclegan-and-pix2pix.

yeguixin avatar yeguixin commented on May 21, 2024

When I use the unaligned dataset. I encounter the error as follows:
------------ Options -------------
batchSize: 1
beta1: 0.5
checkpoints_dir: ./checkpoints
continue_train: False
dataroot: ./datasets/captcha/
dataset_mode: unaligned
display_freq: 100
display_id: 1
display_port: 8097
display_single_pane_ncols: 0
display_winsize: 256
fineSize: 100
gpu_ids: [0]
identity: 0.0
input_nc: 3
isTrain: True
lambda_A: 100.0
lambda_B: 10.0
loadSize: 100
lr: 0.0002
max_dataset_size: inf
model: pix2pix
nThreads: 2
n_layers_D: 3
name: captcha_model
ndf: 64
ngf: 64
niter: 100
niter_decay: 100
no_flip: False
no_html: False
no_lsgan: True
norm: batch
output_nc: 3
phase: train
pool_size: 50
print_freq: 100
resize_or_crop: scale_width
save_epoch_freq: 5
save_latest_freq: 5000
serial_batches: False
use_dropout: False
which_direction: AtoB
which_epoch: latest
which_model_netD: basic
which_model_netG: unet_256
-------------- End ----------------
CustomDatasetDataLoader
dataset [UnalignedDataset] was created
#training images = 20000
pix2pix
Traceback (most recent call last):
File "train.py", line 13, in
model = create_model(opt)
File "/home/nisl/gxye/program/pytorch-CycleGAN-and-pix2pix_rectangle/models/models.py", line 10, in create_model
assert(opt.dataset_mode == 'aligned')
AssertionError

Where the command line as follows:
python train.py --dataroot ./datasets/captcha/ --name captcha_model --model pix2pix --which_model_netG unet_256 --which_direction AtoB --lambda_A 100 --dataset_mode unaligned --no_lsgan --norm batch --loadSize 100 --fineSize 100 --resize_or_crop scale_width

I read the code in details to analyze the reason and found that the pix2pix model has to use the aligned dataset. That is the training images must to be square using pix2pix model. Isn't it? Sorry for do not clear which model that I used before. Nevertheless, Thank you very much.

from pytorch-cyclegan-and-pix2pix.

ianni67 avatar ianni67 commented on May 21, 2024

@yeguixin yes you are right. At the time being, the code for pix2pix still requires square image.

from pytorch-cyclegan-and-pix2pix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.