Giter Site home page Giter Site logo

Comments (2)

dallaqua avatar dallaqua commented on July 21, 2024

Hi,
I tried to execute the demo command on README and get the below errors:

python demo.py --input images/101027.jpg
Traceback (most recent call last):
  File "demo.py", line 118, in <module>
    print (batch_idx, '/', args.maxIter, ':', nLabels, loss.data[0])
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

I'm not familiar with tensor though. Could you please suggest how to modify the code to solve this problem?
My system is Windows 10. Python version 3.7.3. PyTorch==1.2+cpu, opencv-python==4.1.1.26, scikit-image==0.15.0.

I had this same issue and I found that it happened because of PyTorch version. Mine is 1.2.0.
In demo.py you can find:

print (batch_idx, '/', args.maxIter, ':', nLabels, loss.data[0])

# for pytorch 1.0
#print (batch_idx, '/', args.maxIter, ':', nLabels, loss.item())

So what worked for me was to comment line 118 and uncomment line 121 - #print (batch_idx, '/', args.maxIter, ':', nLabels, loss.item())

from pytorch-unsupervised-segmentation.

kanezaki avatar kanezaki commented on July 21, 2024

I uncommented that line now. Thanks @dallaqua!

from pytorch-unsupervised-segmentation.

Related Issues (12)

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.