CartoonGAN-Test-Pytorch-Torch icon indicating copy to clipboard operation
CartoonGAN-Test-Pytorch-Torch copied to clipboard

Can this code work on CPU?

Open syz825211943 opened this issue 6 years ago • 10 comments

syz825211943 avatar Aug 25 '18 02:08 syz825211943

--gpu -1

Yijunmaverick avatar Aug 25 '18 04:08 Yijunmaverick

@Yijunmaverick I set the gpu -1 as you say,but the result image i got is unreasonable.The grayscale value of output image is all around 0.5,and as a result, the output image is gray.Do you have some suggesstions? I use a 8G cpu on Alibaba Cloud with torch.

syz825211943 avatar Aug 25 '18 05:08 syz825211943

Emm...not sure about your case. I just test it on my PC and the result is good.

My CPU: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz

Yijunmaverick avatar Aug 25 '18 05:08 Yijunmaverick

@Yijunmaverick Thanks very much! If there are some reasons you think may result in such case,please tell me,i will be extremely appreciated. because this problem troubled me for a real long time.Thanks again.

syz825211943 avatar Aug 25 '18 05:08 syz825211943

Not familiar with Alibaba Cloud. Can you try it on a local regular desktop (with Ubuntu)? You may use a small image size if the CPU memory is limited.

Can you post your results here?

Yijunmaverick avatar Aug 25 '18 05:08 Yijunmaverick

@Yijunmaverick I use pictures size 256*256,and only change the parameter of gpu and picture paths,it can work though comes out undesired results. Got information below.

[admin@izwz9gqe9a9t5dpaseck9cz CartoonGAN-Test-Pytorch-Torch]$ th test.lua -input_dir /usr/develop/img/input/ -style Hosoda -gpu -1 CPU mode Extracting image paths: /usr/develop/img/input/ /usr/develop/img/input/2016-06-13_20_48_43.jpg Done!

input picture and output picture are in file. 2016-06-13_20_48_43 2016-06-13_20_48_43_hosoda

syz825211943 avatar Aug 25 '18 06:08 syz825211943

This is my result: 44615561-57a3f800-a86f-11e8-8ec3-1fe97d7a86fd_hosoda

Check here and see if reinstalling the nn package will help.

Yijunmaverick avatar Aug 25 '18 06:08 Yijunmaverick

@Yijunmaverick Thanks very much! I will try!

syz825211943 avatar Aug 25 '18 07:08 syz825211943

@Yijunmaverick It doesn't work on my desktop computer, the result i got is the same.And i reinstalling the nn package,it also doesn't work. Sad. I want to check something. After cloning your code,i comment out some lines,

--require 'cutorch'require 'nn' --require 'cunn' require 'image' require 'nngraph' require 'paths' require 'src/InstanceNormalization

and change the parameters of gpu and paths.

local cmd = torch.CmdLine() --cmd:option('-input_dir','test_img','the path of input') cmd:option('-input_dir', '/usr/develop/img/input'); --cmd:option('-output_dir','test_output','the path of output') cmd:option('-output_dir', '/usr/develop/img/output', 'Path to save stylized image.') cmd:option('-load_size', 256) cmd:option('-gpu', -1, '-1 for CPU mode') cmd:option('-model_path', './pretrained_model/') cmd:option('-style', 'Hosoda')

If there are other things i need to do or something i make mistakse?

syz825211943 avatar Aug 25 '18 12:08 syz825211943

the code can work in the cpu,may be you need more Menmory

Wentao795 avatar Apr 08 '19 01:04 Wentao795