Giter Club home page Giter Club logo

singlegan's People

Contributors

xiaoming-yu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

singlegan's Issues

PyTorch>=0.5 compatibility data[0] to data.item()

Thank you for this work.

This version gives the following error with recent PyTorch versions:
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
as the index of 0-dim tensor is invalid since PyTorch>0.5 if I remember correctly.

Fix: All data[0]s in single_gan.py - get_current_errors function needs to be changed to data.item().

Cheers!

Confusion about the code

Hi, @Xiaoming-Yu !

Although i have read your paper, i still am still confused about the meaning of the following codes.

c_enc, mu, logvar = self.E(self.real,sourceDC)

What's the meaning of c_enc, mu and logvar resepctively ?
I think that the c_enc acts like the style latent code to enhance the variation.
Am i right?

The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable.

:\Users\caocao\Anaconda3\python.exe D:/work/work11/SingleGAN-master/train.py --dataroot datasets/apple2orange --checkpoints_dir checkpoints --display_id 3 --name base_apple2orange --mode base --loadSize 143 --fineSize 138 --input_nc 3 --niter 100 --niter_decay 100 --lambda_ide 1 --display_port 8097 --batchSize 1 --ngf 64 --ndf 64
------------ Options -------------
batchSize: 1
c_gan_mode: lsgan
c_num: 0
checkpoints_dir: checkpoints
continue_train: False
d_num: 2
dataroot: datasets/apple2orange
display_freq: 400
display_id: 3
display_port: 8097
display_winsize: 256
e_blocks: 6
fineSize: 138
gpu: 0
init_type: xavier
input_nc: 3
isTrain: True
is_flip: 1
lambda_c: 0.5
lambda_cyc: 10.0
lambda_ide: 1.0
lambda_kl: 0.01
loadSize: 143
lr: 0.0002
mode: base
nThreads: 4
name: base_apple2orange
ndf: 64
nef: 64
ngf: 64
niter: 100
niter_decay: 100
no_html: False
norm: instance
output_nc: 3
print_freq: 200
save_epoch_freq: 5
save_latest_freq: 10000
up_type: Trp
update_html_freq: 4000
which_epoch: latest
-------------- End ----------------
Start preprocessing dataset..!
Finished preprocessing dataset..!
create web directory checkpoints\base_apple2orange\2018_10_18_15_52_57\web...
D:\work\work11\SingleGAN-master\models\model.py:46: UserWarning: nn.init.xavier_normal is now deprecated in favor of nn.init.xavier_normal_.
init.xavier_normal(m.weight.data, gain=math.sqrt(2))
D:\work\work11\SingleGAN-master\models\model.py:56: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
init.constant(m.bias.data, 0.0)
------------ Options -------------
batchSize: 1
c_gan_mode: lsgan
c_num: 0
checkpoints_dir: checkpoints
continue_train: False
d_num: 2
dataroot: datasets/apple2orange
display_freq: 400
display_id: 3
display_port: 8097
display_winsize: 256
e_blocks: 6
fineSize: 138
gpu: 0
init_type: xavier
input_nc: 3
isTrain: True
is_flip: 1
lambda_c: 0.5
lambda_cyc: 10.0
lambda_ide: 1.0
lambda_kl: 0.01
loadSize: 143
lr: 0.0002
mode: base
nThreads: 4
name: base_apple2orange
ndf: 64
nef: 64
ngf: 64
niter: 100
niter_decay: 100
no_html: False
norm: instance
output_nc: 3
print_freq: 200
save_epoch_freq: 5
save_latest_freq: 10000
up_type: Trp
update_html_freq: 4000
which_epoch: latest
-------------- End ----------------
Start preprocessing dataset..!
Finished preprocessing dataset..!
create web directory checkpoints\base_apple2orange\2018_10_18_15_53_02\web...
D:\work\work11\SingleGAN-master\models\model.py:46: UserWarning: nn.init.xavier_normal is now deprecated in favor of nn.init.xavier_normal_.
init.xavier_normal(m.weight.data, gain=math.sqrt(2))
D:\work\work11\SingleGAN-master\models\model.py:56: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
init.constant(m.bias.data, 0.0)
Traceback (most recent call last):
File "", line 1, in
Traceback (most recent call last):
File "D:/work/work11/SingleGAN-master/train.py", line 24, in
for i, data in enumerate(data_loader):
File "C:\Users\caocao\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 451, in iter
return _DataLoaderIter(self)
File "C:\Users\caocao\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 239, in init
w.start()
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\process.py", line 105, in start
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\spawn.py", line 106, in spawn_main
self._popen = self._Popen(self)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\context.py", line 212, in _Popen
exitcode = _main(fd)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\spawn.py", line 115, in _main
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\context.py", line 313, in _Popen
prepare(preparation_data)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\spawn.py", line 226, in prepare
return Popen(process_obj)
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 66, in init
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
reduction.dump(process_obj, to_child)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\reduction.py", line 59, in dump
run_name="mp_main")
File "C:\Users\caocao\Anaconda3\lib\runpy.py", line 254, in run_path
ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe
pkg_name=pkg_name, script_name=fname)
File "C:\Users\caocao\Anaconda3\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\caocao\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\work\work11\SingleGAN-master\train.py", line 24, in
for i, data in enumerate(data_loader):
File "C:\Users\caocao\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 451, in iter
return _DataLoaderIter(self)
File "C:\Users\caocao\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 239, in init
w.start()
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\context.py", line 212, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\context.py", line 313, in _Popen
return Popen(process_obj)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 34, in init
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\spawn.py", line 144, in get_preparation_data
_check_not_importing_main()
File "C:\Users\caocao\Anaconda3\lib\multiprocessing\spawn.py", line 137, in _check_not_importing_main
is not going to be frozen to produce an executable.''')
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

Process finished with exit code 1

Cannot start training on linux machine

Hi, @Xiaoming-Yu,

Thanks for your work and code! It's amazing!

Unfortunately, when running this bash ./scripts/train_base.sh apple2orange as stated in README. Error message like the following appears:

Traceback (most recent call last):
  File "./train.py", line 9, in <module>
    opt = TrainOptions().parse()
  File "/xxx/SingleGAN/options/base_options.py", line 57, in parse
    if not continue_train:
NameError: name 'continue_train' is not defined

Any suggestions? Thanks again, and in advance.

ConnectionRefusedError: [Errno 111] Connection refused. Would you please tell me how to do next?,thanks!

File "/home/anaconda3/lib/python3.7/site-packages/urllib3/connection.py", line 196, in connect
conn = self._new_conn()

File "/home/anaconda3/lib/python3.7/site-packages/urllib3/connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f0de31dcd68>: Failed to establish a new connection: [Errno 111] Connection refused

File "/home/anaconda3/lib/python3.7/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0de31dcd68>: Failed to establish a new connection: [Errno 111] Connection refused'))

File "/home/SingleGAN-master/models/model.py", line 181, in init
block += [spectral_norm(Conv2dBlock(dim_in, dim_out, kernel_size=4, stride=2, padding=1,bias=False,nl_layer=nl_layer))]
File "/home/anaconda3/lib/python3.7/site-packages/torch/nn/utils/spectral_norm.py", line 128, in spectral_norm
SpectralNorm.apply(module, name, n_power_iterations, dim, eps)
File "/home/anaconda3/lib/python3.7/site-packages/torch/nn/utils/spectral_norm.py", line 61, in apply
weight = module._parameters[name]
KeyError: 'weight'

Color transformation during day2night translation

Thanks for both the paper the the implementation. I found it clever and interesting.
Well done and Well written!

I trained the model for a day2night translation using bdd100k dataset and the results looks quite good.
Unfortunately, I ran into some unplanned color transformation phenomena.
See attached image of "night to day" translation as an example, where green traffic lights turned unfortunately red..

image
https://user-images.githubusercontent.com/73229978/171182305-1c0a020e-3390-4f87-b3b5-cb61834757af.png

This phenomena of color transformation is repeating through the whole test set (red<->green, yellow<->purple etc.)
Do you have any clue or suggestion?

Thx!
Or

Multi-gpu issue.

Thanks for your contribution of CBIN layer.

I have a short question of lines of code of CBIN.

In the the class _CBINorm(_BatchNorm) of cbin.py file, ,
https://github.com/Xiaoming-Yu/SingleGAN/blob/608551b40fe6107c9e5ce48e27cb8ca29b3b7a8c/models/cbin.py#L31
https://github.com/Xiaoming-Yu/SingleGAN/blob/608551b40fe6107c9e5ce48e27cb8ca29b3b7a8c/models/cbin.py#L32

The url indicates the line 31 and 32 in the cbin.py file.
self.running_mean.copy_(running_mean.view(b, c).mean(0, keepdim=False))
self.running_var.copy_(running_var.view(b, c).mean(0, keepdim=False))

Why this operation is needed??
I check that for the multi-gpu issue, this raise a runtime error.
"RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation"

In short, my question is the necessity of the two lines and the multi-gpu operation issue.
I currently use torch 0.4.1 and cuda 9.0.

Multi-modal training

Hi, @Xiaoming-Yu .
I really appreaciate your work.
But i found some problems duraing the multi-modal training.

When i run sh ./scripts/train_multimodal.sh edges2handbags ,
i met the following error.

Traceback (most recent call last):
File "./train.py", line 57, in
main()
File "./train.py", line 16, in main
model.initialize(opt)
File "/data2/valentina/SingleGAN-master/models/single_gan.py", line 23, in initialize
self.build_models()
File "/data2/valentina/SingleGAN-master/models/single_gan.py", line 32, in build_models
self.E = Encoder(input_nc=self.opt.input_nc, output_nc=self.opt.c_num, nef=self.opt.nef, nd=self.opt.d_num, n_blocks=4, norm_typ
File "/data2/valentina/SingleGAN-master/models/model.py", line 245, in init
conv_layers += [BasicBlock(input_ndf, output_ndf, c_norm_layer, nl_layer)]
File "/data2/valentina/SingleGAN-master/models/model.py", line 225, in init
self.shortcut = meanpoolConv(inplanes, outplanes)
File "/data2/valentina/SingleGAN-master/models/model.py", line 207, in meanpoolConv
sequence += [spectral_norm(Conv2dBlock(inplanes, outplanes, kernel_size=1, stride=1, padding=0, bias=True))]
File "/usr/local/lib/python2.7/dist-packages/torch/nn/utils/spectral_norm.py", line 128, in spectral_norm
SpectralNorm.apply(module, name, n_power_iterations, dim, eps)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/utils/spectral_norm.py", line 61, in apply
weight = module._parameters[name]
KeyError: 'weight'

Could you please fix this problem?
Many thanks!

ValueError: empty range for randrange() (0,0, 0) in test.py

E:\Users\Raytine\Anaconda3\python.exe F:/zhaiyao/SingleGAN-master/ptest.py --dataroot ./datasets/apple2orange --checkpoints_dir ./checkpoints --time_dir 2018_11_21_15_55_28 --name base_apple2orange --mode base --loadSize 128 --fineSize 128 --input_nc 3 --how_many 50 --which_epoch latest --is_flip 0 --batchSize 1 --ngf 64
------------ Options -------------
batchSize: 1
c_gan_mode: lsgan
c_num: 0
checkpoints_dir: ./checkpoints
d_num: 2
dataroot: ./datasets/apple2orange
display_id: 1
display_port: 8000
display_winsize: 256
e_blocks: 6
fineSize: 128
gpu: 0
how_many: 50
init_type: xavier
input_nc: 3
isTrain: False
is_flip: 0
loadSize: 128
mode: base
nThreads: 4
n_samples: 5
name: base_apple2orange
ndf: 64
nef: 64
ngf: 64
norm: instance
output_nc: 3
results_dir:
time_dir: 2018_11_21_15_55_28
up_type: Trp
which_epoch: latest
-------------- End ----------------
Start preprocessing dataset..!
Finished preprocessing dataset..!
Traceback (most recent call last):
File "F:/zhaiyao/SingleGAN-master/ptest.py", line 31, in
main()
File "F:/zhaiyao/SingleGAN-master/ptest.py", line 22, in main
for i, data in enumerate(islice(data_loader, opt.how_many)):
File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 106, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 106, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "F:\zhaiyao\SingleGAN-master\data\dataloader.py", line 86, in getitem
index_d = index if index < self.num[d] else random.randint(0,self.num[d]-1)
File "E:\Users\Raytine\Anaconda3\lib\random.py", line 218, in randint
return self.randrange(a, b+1)
File "E:\Users\Raytine\Anaconda3\lib\random.py", line 196, in randrange
raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0,0, 0)

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.