Giter Site home page Giter Site logo

Comments (3)

Ram2314 avatar Ram2314 commented on June 12, 2024

Hi! @aeinkoupaei Did you figure out if this is the correct approach to get the feature map from a image? Also needing to use this make a feature map. Is there any reason you made num_seg_classes=1?

from medicalnet.

aeinkoupaei avatar aeinkoupaei commented on June 12, 2024

Hi @Ram2314,

To use a pre-trained ResNet model for extracting 3D feature maps, you'll need to focus on the ResNet class within the resnet.py file. Here's what to change:
1- Modifying the init function of ResNet class: Delete the entire self.conv_seg block. This removes the unnecessary layers for our feature extraction task.
2- Modifying the forward function of ResNet class: Delete this line: x = self.conv_seg(x). This ensures the model doesn't perform the final segmentation prediction, but instead outputs the feature map before that stage.

Here's an example of how to use a pre-trained ResNet-10 model for feature extraction:

resnet_10 = resnet10(shortcut_type='B', no_cuda=True)
pretrain = torch.load("resnet_10_23dataset.pth")
pretrained_dict = pretrain['state_dict']
new_state_dict = OrderedDict()
for k, v in pretrained_dict.items():
name = k[7:]
new_state_dict[name] = v

resnet_10.load_state_dict(new_state_dict)

from medicalnet.

Ram2314 avatar Ram2314 commented on June 12, 2024

@aeinkoupaei Awesome thanks! Also did you figure out the length, width, height issue? Seems I can set it to anything and it will work?

from medicalnet.

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.