Coder Social home page Coder Social logo

Comments (6)

tom-a-horrocks avatar tom-a-horrocks commented on August 22, 2024 1

Hi,

I believe OP is correct. My code crashes on that line with rectangular input images. Regardless of what PIL uses behind the scenes, the Image.Resize function takes shape as (W,H):

image

Implementing OP's fix stops the crash and results in the correct CAM (I verified it against CAMs from other packages).

from pytorch-cnn-visualizations.

BartvanMarrewijk avatar BartvanMarrewijk commented on August 22, 2024 1

Indeed a problem, the solution of @zhaoxin111 helped. In addition there is another bug when using grad cam with larger image sizes. The adaptivepooling before the classification is not loaded for both alexnet and vgg. I solved it by adding following line before flattening line43:
x = self.pool.avgpool(x)

from pytorch-cnn-visualizations.

utkuozbulak avatar utkuozbulak commented on August 22, 2024

Hey,

Thanks for the notification! I will check/fix it by tonight.

from pytorch-cnn-visualizations.

utkuozbulak avatar utkuozbulak commented on August 22, 2024

Hello again,

Sorry for (very) late reply. I think it is correct as it is. PIL uses HWC and torch uses BCHW so HW channels are always one after another.

You can convince yourself that PIL uses HWC with

from PIL import Image
import numpy as np

im = Image.open('image.png')
im_arr = np.asarray(im)
print(im_arr.shape)

I will check the output with a model that accepts input with different H and W size and see if it is actually correct though. Thanks for the heads up.

from pytorch-cnn-visualizations.

utkuozbulak avatar utkuozbulak commented on August 22, 2024

Thanks for the heads up! I will have a look at it again!

from pytorch-cnn-visualizations.

Radha2020-py avatar Radha2020-py commented on August 22, 2024

hi

from pytorch-cnn-visualizations.

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.