Git Product home page Git Product logo

apdrawinggan's Issues

Recommended GPU memory

What is the minimum required GPU memory for training the data? I am trying to experiment on 1660 super with 6gb VRam but no luck, i can't even run training single batch size.

RuntimeError: The size of tensor a (3) must match the size of tensor b (9) at non-singleton dimension 0

Firstly, thanks for your excellent work! Now I am trying to train your model on my own dataset, but when I run the code, a RuntimeError appear. I am new to this area so have no idea why, the dataset I have already organized as the authors. As this:
'''
/data -- the aligned data
/train -- aligned train images (augmented)
/test -- aligned test images
/landmark -- 5 facial landmarks of train and test images
/ALL -- contains all landmark files
/mask -- background masks of train and test images
/ALL -- contains all background masks
'''
Looking forward to some help, thanks!

[Network GLMouth] Total number of parameters : 1.448 M
[Network GLHair] Total number of parameters : 1.710 M
[Network GLBG] Total number of parameters : 1.710 M
[Network GCombine] Total number of parameters : 0.158 M

create web directory ./checkpoints/first_try/web...
Traceback (most recent call last):
File "/home/wen/study/destyle-transfer/APDrawingGAN/train.py", line 25, in
for i, data in enumerate(dataset):
File "/home/wen/study/destyle-transfer/APDrawingGAN/data/init.py", line 72, in iter
for i, data in enumerate(self.dataloader):
File "/home/wen/.virtualenvs/APD2/local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "/home/wen/.virtualenvs/APD2/local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/home/wen/.virtualenvs/APD2/local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/wen/study/destyle-transfer/APDrawingGAN/data/aligned_dataset.py", line 188, in getitem
hair_A = (A/2+0.5) * mask.repeat(input_nc/output_nc,1,1) * mask2.repeat(input_nc/output_nc,1,1) * 2 - 1
RuntimeError: The size of tensor a (3) must match the size of tensor b (9) at non-singleton dimension 0

only integer tensors of a single element can be converted to an index

Excuse me,did u occur in this question?when I revised this question, I would occur in next question which may causeby this question.

Traceback (most recent call last):
  File "test.py", line 24, in <module>
    for i, data in enumerate(dataset):
  File "/home/jingjie/Pencil/APDrawing/APDrawingGAN/data/__init__.py", line 72, in __iter__
    for i, data in enumerate(self.dataloader):
  File "/home/jingjie/ENTER/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 819, in __next__
    return self._process_data(data)
  File "/home/jingjie/ENTER/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data
    data.reraise()
  File "/home/jingjie/ENTER/lib/python3.7/site-packages/torch/_utils.py", line 369, in reraise
    raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/jingjie/ENTER/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/jingjie/ENTER/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/jingjie/ENTER/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/jingjie/Pencil/APDrawing/APDrawingGAN/data/single_dataset.py", line 96, in __getitem__
    item[regions[i]+'_A'] = A[:,center[i,1]-rhs[i]/2:center[i,1]+rhs[i]/2,center[i,0]-rws[i]/2:center[i,0]+rws[i]/2]
TypeError: only integer tensors of a single element can be converted to an index

How about WGAN-GP?

Hello,

Appreciate your work!
Since Wasserstein GAN with Gradient Penalty is often used recently,
I wonder if you tried that?

Thanks

How to solve this TypeError: only integer tensors of a single element can be converted to an index

File "F:\compare_cartoon\APDrawingGAN-master\data\aligned_dataset.py", line 146, in getitem
item[regions[i]+'_A'] = A[:,center[i,1]-rhs[i]/2:center[i,1]+rhs[i]/2,center[i,0]-rws[i]/2:center[i,0]+rws[i]/2]
TypeError: only integer tensors of a single element can be converted to an index
[Network DLEyer] Total number of parameters : 2.767 M
[Network DLNose] Total number of parameters : 2.767 M
[Network DLMouth] Total number of parameters : 2.767 M
[Network DLHair] Total number of parameters : 2.767 M
[Network DLBG] Total number of parameters : 2.767 M
[Network GLEyel] Total number of parameters : 1.448 M
[Network GLEyer] Total number of parameters : 1.448 M
[Network GLNose] Total number of parameters : 1.448 M
[Network GLMouth] Total number of parameters : 1.448 M
[Network GLHair] Total number of parameters : 1.710 M
[Network GLBG] Total number of parameters : 1.710 M
[Network GCombine] Total number of parameters : 0.158 M

Setting up a new session...
create web directory ./checkpoints/formal/web...
Traceback (most recent call last):
File "train.py", line 25, in
for i, data in enumerate(dataset):
File "/data/zzj/APDrawingGAN-master/data/init.py", line 72, in iter
for i, data in enumerate(self.dataloader):
File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next
return self._process_next_batch(batch)
File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
TypeError: Traceback (most recent call last):
File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/zzj/.conda/envs/th1.1/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/data/zzj/APDrawingGAN-master/data/aligned_dataset.py", line 146, in getitem
item[regions[i]+'_A'] = A[:,center[i,1]-rhs[i]/2:center[i,1]+rhs[i]/2,center[i,0]-rws[i]/2:center[i,0]+rws[i]/2]
TypeError: only integer tensors of a single element can be converted to an index

Does the training data has to be in pairs ?

I downloaded the training data and saw they were strictly in pairs. Does it mean that I need to prepare the similar format of training data if I want to train a new model for another painting style?

No grad_fn for "self.loss_G_chamfer2"

Hello,
Thanks for your great work! I'm pretty interested in your distance transform loss. But when I want to test the loss separately, I find there is no grad_fn for self.loss_G_chamfer2

self.loss_G_chamfer2 = (dt1gt[(fake_B_gray<0)&(fake_B_gray_line1<0)].sum() + dt2gt[(fake_B_gray>=0)&(fake_B_gray_line2>=0)].sum()) / bs * self.opt.lambda_chamfer2

Since real_B_gray is input label and doesn't require grad, I believe self.loss_G_chamfer2 should have no grad_fn. So what is the purpose to calculate it? Or is it redundant?

Sorry, we run your program but there is an error

Could you please tell me which causes that:

Traceback (most recent call last):
File "/home/suhao/PycharmProjects/APGAN-master/test.py", line 24, in
for i, data in enumerate(dataset):
File "/home/suhao/PycharmProjects/APGAN-master/data/init.py", line 72, in iter
for i, data in enumerate(self.dataloader):
File "/home/suhao/anaconda3/envs/py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "/home/suhao/anaconda3/envs/py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/home/suhao/anaconda3/envs/py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/suhao/anaconda3/envs/py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 106, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/suhao/PycharmProjects/APGAN-master/data/single_dataset.py", line 83, in getitem
center = torch.tensor([[feats[0,0],feats[0,1]-4ratio],[feats[1,0],feats[1,1]-4ratio],[feats[2,0],feats[2,1]-NOSE_H/2+16*ratio],[mouth_x,mouth_y]])
RuntimeError: Could not infer dtype of numpy.int64

test.py: error: the following arguments are required: --dataroot 请问下我运行后出现这个问题。

usage: test.py [-h] --dataroot DATAROOT [--batch_size BATCH_SIZE]
[--loadSize LOADSIZE] [--fineSize FINESIZE]
[--input_nc INPUT_NC] [--output_nc OUTPUT_NC] [--ngf NGF]
[--ndf NDF] [--netD NETD] [--netG NETG] [--nnG NNG]
[--n_layers_D N_LAYERS_D] [--gpu_ids GPU_IDS] [--name NAME]
[--dataset_mode DATASET_MODE] [--model MODEL] [--use_local]
[--comb_op COMB_OP] [--lm_dir LM_DIR] [--bg_dir BG_DIR]
[--soft_border SOFT_BORDER] [--EYE_H EYE_H] [--EYE_W EYE_W]
[--NOSE_H NOSE_H] [--NOSE_W NOSE_W] [--MOUTH_H MOUTH_H]
[--MOUTH_W MOUTH_W] [--which_direction WHICH_DIRECTION]
[--num_threads NUM_THREADS] [--checkpoints_dir CHECKPOINTS_DIR]
[--auxiliary_root AUXILIARY_ROOT] [--norm NORM]
[--serial_batches] [--display_winsize DISPLAY_WINSIZE]
[--display_id DISPLAY_ID] [--display_server DISPLAY_SERVER]
[--display_env DISPLAY_ENV] [--display_port DISPLAY_PORT]
[--no_dropout] [--max_dataset_size MAX_DATASET_SIZE]
[--resize_or_crop RESIZE_OR_CROP] [--no_flip]
[--init_type INIT_TYPE] [--init_gain INIT_GAIN] [--verbose]
[--suffix SUFFIX] [--ntest NTEST] [--results_dir RESULTS_DIR]
[--aspect_ratio ASPECT_RATIO] [--phase PHASE]
[--which_epoch WHICH_EPOCH] [--how_many HOW_MANY] [--save2]
test.py: error: the following arguments are required: --dataroot

Align face images with smaller size

Hi,
In the provided matlab code face_align_512.m , I'm curious about the reason behind this line of code
coord5point = (coord5point-240)/560 * 512 + 256;

since I'm trying to preprocess smaller image (e.g. 128x128) as input which cost less time and memory usage.

Looking forward to some help, thanks!

Did you retrain the method in paper"...Automatic Portrait Segmentation...", when you get the background mask?

Dear authors:
This is an outstanding work, but here is a small problem.
1) In "Preprocessing steps>Prepare background masks" of APDrawingGAN, we run the code of paper "Automatic Portrait Segmentation for Image Stylization" obtained from the link "http://xiaoyongshen.me/webpage_portrait/index.html".
2) We use the pre-trained models proved by authors to test the code (we did not change anything in the codes), but it cannot achieve the effect of the paper, our test results as shown in the following Figures:
00321
2_aligned
1_aligned
3) Could you please tell me how you employ their code, whether you retrain it, and so on?

Very thanks!

How to use CPU to run the test.py?

Can I run test.py using CPU instead of GPU please?

Currently when run:

python test.py --dataroot dataset/data/test_single --name formal_author --model test --dataset_mode single --norm batch 
--use_local --which_epoch 300

got error:

Traceback (most recent call last):
File "test.py", line 10, in
opt = TestOptions().parse()
File "C:\repos\zzz\APDrawingGAN\options\base_options.py", line 131, in parse
torch.cuda.set_device(opt.gpu_ids[0])
File "C:\repos\zzz\APDrawingGAN\venv\lib\site-packages\torch\cuda_init_.py", line 314, in set_device
torch._C._cuda_setDevice(device)
AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

How to generate a new landmark txt file for a new photo?

I put a new photo test.png in folder dataset\data\test_single, run the command:
python test.py --dataroot dataset/data/test_single --name formal_author --model test --dataset_mode single --norm batch --use_local --which_epoch 300 --gpu_ids -1
got the below error:

FileNotFoundError: [Errno 2] No such file or directory: 'dataset/landmark/ALL\test.txt'

How to generate a new landmark txt file for this new photo?

FID metric

Hi, thanks a lot for your awesome work.
I tried to compare FID metric between the real APDrawings in the training set and the test set, and the result is 43.2385, which is lower than the value in the paper. Can you provide the evaluation code used in the paper?

About the "Line-promoting distance transform loss"

I think this loss is trying to keep the generated hair to be a streamline rather than discrete pixels, right ?
One part of your implemenation confused me was :

# Third, distance transform loss (chamfer matching)
if self.fake_B.shape[1] == 3:
tmp = self.fake_B[:,0,...]*0.299+self.fake_B[:,1,...]*0.587+self.fake_B[:,2,...]*0.114
fake_B_gray = tmp.unsqueeze(1)
else:
fake_B_gray = self.fake_B
if self.real_B.shape[1] == 3:
tmp = self.real_B[:,0,...]*0.299+self.real_B[:,1,...]*0.587+self.real_B[:,2,...]*0.114
real_B_gray = tmp.unsqueeze(1)
else:
real_B_gray = self.real_B

Why check the shape of axis=1 rather than 2? I assumed that the finally generated fake_B is the shape of HxWxC.

Dataset and Pre-train model

Hi, The APDarwingGAN is great
Currently I'm using this for my study. As you mention in paper you have published APDrawingDB dataset and pre-train model but I can't get into the link. Could you please fix the link or share them in another way?
Thank you so much.

预训练模型效果不如online demo

你好,我用同一张测试图,使用预训练下载的模型和网上的demo接口效果差距挺大的,能放一下网上demo对应的模型吗

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.