Coder Social home page Coder Social logo

Harmonization IndexError about consingan HOT 4 CLOSED

tohinz avatar tohinz commented on July 18, 2024
Harmonization IndexError

from consingan.

Comments (4)

tohinz avatar tohinz commented on July 18, 2024

Hi,
it seems something goes wrong when reading your --naive_img.
Can you print the shape of the image after the image is loaded (so print(x.shape) after x = img.imread('%s' % (opt.input_name)))?
It should have three dimensions (width, height, channels). If the image you're loading is grayscale (black-white only) the loaded array would only have two dimensions (width, height) in which case you would have to convert the image to RGB format first before continuing.

from consingan.

pipponino avatar pipponino commented on July 18, 2024

Yes, the error was about the RGB/gray format. Really thank you.
I know this problem is not related to this issue and I'm going to close it soon, but now I'm getting this:

Traceback (most recent call last):
  File "main_train.py", line 113, in <module>
    train(opt)
  File "/home/me/ConSinGAN/ConSinGAN/training_harmonization_editing.py", line 22, in train
    real = functions.read_image(opt)
  File "/home/me/ConSinGAN/ConSinGAN/functions.py", line 132, in read_image
    x = np2torch(x,opt)
  File "/home/me/ConSinGAN/ConSinGAN/functions.py", line 155, in np2torch
    x = x.type(torch.cuda.FloatTensor) if not(opt.not_cuda) else x.type(torch.FloatTensor)
RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.

How could I solve?

from consingan.

tohinz avatar tohinz commented on July 18, 2024

Do you have an NVIDIA GPU on your computer or only CPU?
If you have a GPU I don't know how to fix this error as I don't know what the ATen_cuda library is. Reinstalling PyTorch from scratch via pip or conda should fix this I would hope (make sure you install it for the correct CUDA version you have on your system).
If you don't have a GPU you can add the flag --not_cuda to run everything on CPU but this will be a lot slower. Also, to be honest, I'm not 100% sure if I have everything running on CPU, sometimes I might have just put tensors on GPU directly without checking for the --not_cuda flag. In this case you will get an error that a tensor was expected on a different device, so you might have to fix a couple of lines to make tensors be on CPU instead of the GPU (you'll usually only have to change torch.cuda.FloatTensor to torch.FloatTensor or add .to(opt.device) or .to("cpu") to any tensors/models).

from consingan.

pipponino avatar pipponino commented on July 18, 2024

The --not_cuda flag seems to be working.
Thank you again!!

from consingan.

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.