Giter Club home page Giter Club logo

spatialattentiongan's Issues

Encounting `TypeError` when execute the training script

Can you give me an example of colab notebook to train the model? since i've tried execute a script in Google Colab, however, what i've got is that

The command to run a script (in Google Colab)

!python3 /content/SpatialAttentionGAN/train.py --experiment-name celeba_128_eyeglasses --target-attr Eyeglasses --gpu

Error encounted

Namespace(data_path='./data/celeba', attr_path='./data/list_attr_celeba.txt', target_attr='Goatee', image_size=128, batch_size=16, lr=0.0002, beta1=0.5, beta2=0.999, l1=20, l2=100, lgp=10, d_iters=3, total_kimg=1000, tick_kimg=5.0, sample_ticks=1, save_ticks=10, num_samples=64, experiment_name='celeba_128_eyeglasses2', gpu=False)
Traceback (most recent call last):
  File "/content/SpatialAttentionGAN/train.py", line 119, in <module>
    vutils.save_image(fixed_reals, join(sample_path, '{:07d}_real.jpg'.format(0)), nrow=8, padding=0, normalize=True, range=(-1., 1.))
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torchvision/utils.py", line 146, in save_image
    grid = make_grid(tensor, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
TypeError: make_grid() got an unexpected keyword argument 'range'

About cuda

Hi!
When I run train.py, it occured:
Traceback (most recent call last):
File "train.py", line 148, in
fakes, _ = G(reals, target_labels)
File "/home/rain/software/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/rain/nlp/etrump/txt2img/SAGAN_celeba/sagan.py", line 95, in forward
y = self.AMN(x, a)
File "/home/rain/software/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/rain/nlp/etrump/txt2img/SAGAN_celeba/sagan.py", line 83, in forward
x = torch.cat((x, a), dim=1)
RuntimeError: Expected object of backend CUDA but got backend CPU for sequence element 1 in sequence argument at position #1 'tensors'

Can you help me with it?

Thank you so much!

how can i use it for my use case.

My use case is I'm gonna pass a face image to the GAN model and it should return the same image with eyeglasses.
can i use your code to do it ? If yes , i need some suggestion.
Thanks .

CUDA problem in generate.py

Thanks for your excellent work, but I got similar problem as #1.

Traceback (most recent call last):
  File "generate.py", line 80, in <module>
    samples, masks = G(reals, target_labels)
  File "/home/zhiyong/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/zhiyong/temp_test/SpatialAttentionGAN/sagan.py", line 98, in forward
    y = self.AMN(x, a)
  File "/home/zhiyong/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/zhiyong/temp_test/SpatialAttentionGAN/sagan.py", line 86, in forward
    x = torch.cat((x, a), dim=1)
RuntimeError: Expected object of backend CUDA but got backend CPU for sequence element 1 in sequence argument at position #1 'tensors'

And I fixed it by modify the code in line76, generate.py.

reals, labels = reals.to(device), labels.type_as(reals).to(device)

Maybe you can update the generate.py to fix it.

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.