Comments (6)
I used this:
class MedicalNet(nn.Module):
def __init__(self, path_to_weights, device):
super(MedicalNet, self).__init__()
self.model = resnet34(sample_input_D=1, sample_input_H=112, sample_input_W=112, num_seg_classes=2)
self.model.conv_seg = nn.Sequential(
nn.AdaptiveMaxPool3d(output_size=(1, 1, 1)),
nn.Flatten(start_dim=1),
nn.Dropout(0.1)
)
net_dict = self.model.state_dict()
pretrained_weights = torch.load(path_to_weights, map_location=torch.device(device))
pretrain_dict = {
k.replace("module.", ""): v for k, v in pretrained_weights['state_dict'].items() if k.replace("module.", "") in net_dict.keys()
}
net_dict.update(pretrain_dict)
self.model.load_state_dict(net_dict)
self.fc = nn.Linear(512, 1)
def forward(self, x):
features = self.model(x)
return self.fc(features)
Then:
model = MedicalNet(path_to_weights="pretrain/resnet_34.pth", device=device)
for param_name, param in model.named_parameters():
if param_name.startswith("conv_seg"):
param.requires_grad = True
else:
param.requires_grad = False
from medicalnet.
What I'm doing is replace the FC layers to my classification layers, although the performance was not good. Happy to discuss more if you are interested in.
from medicalnet.
Hi @JasperHG90 Do you have the code for training classification? because in train.py there are some parts that connected to the segmentation for example masks etc
from medicalnet.
@Batush123 I'm not entirely sure what you're asking for. Are you asking me what my input data & training loop look like?
from medicalnet.
Hi @JasperHG90, I am looking at a similar problem and I would be glad if you could share your code including the data/training loop, if possible. Thanks!
from medicalnet.
Hello @JasperHG90, same here, would you be able to share your data/training loop? Thank you very much :)
from medicalnet.
Related Issues (20)
- pretrain code
- same for network pretrain code
- What's the input resolution for the pretrained model
- The dataset list of 23 datasets for the pre-trained model HOT 1
- Landmark detection in 3D point clouds
- Starting experiments with MedicalNet; question one: what are parameters --input_D, --input_H, --input_W? HOT 2
- Sharing models through Hugging Face Hub
- Cannot load checkpoints
- on which datasets the models are pretrained ? HOT 1
- Is there any classification code ?
- Contribution to the Open Source Hugging Face community.
- resent 50pth HOT 2
- SRS
- If I want to transfer to my own dataset, do I have to preprocess my data in the same way as you mentioned in your paper?
- Pre-trained models' results
- Project dependencies may have API risk issues
- Classification code with modification of train.py and datasets/brains18.py HOT 16
- Query: Can this be used to identify Chronic Kidney Diseases with Ultrasound scans?
- How to get the pretrained model
- Utilizing resnet_50.pth for 3D Feature Map Extraction HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from medicalnet.