MECLabTUDA / M3d-Cam

MIT License
306 stars 40 forks source link

Suggestions for regression-based 3D attention #18

Open sgbaird opened 2 years ago

sgbaird commented 2 years ago

Any alternative codebases that might help out with regression? (instead of classification/segmentation).

ravikiranrao commented 2 years ago

@sgbaird Did you get anything? I am looking for regression for Video input (Batch_size, time_frames, Height, Width, Channels).

sgbaird commented 2 years ago

@ravikiranrao not yet, I think we're going to try a fully connected neural network to change the shape to 2D (and use PyTorch's built-in), but if we find something I'll try to remember to post back here.

Karol-G commented 2 years ago

Hi,

sorry for the late answer. M3D-Cam is designed for segmentation and classification, but it should also be adaptable to regression. Maybe it works out-of-the-box, but I have not tested that. However, you probably need to adapt some parts of the postprocessing in medcam_inject.py. Best would be for you to just try the default usage and work yourself up from that in case of errors. However, I won't be able to help you with that (if you try it) as I don't really have time currently.

# Import M3d-CAM
from medcam import medcam

# Init your model and dataloader
model = MyCNN()
data_loader = DataLoader(dataset, batch_size=1, shuffle=False)

# Inject model with M3d-CAM
model = medcam.inject(model, output_dir="attention_maps", save_maps=True)

# Continue to do what you're doing...
# In this case inference on some new data
model.eval()
for batch in data_loader:
    # Every time forward is called, attention maps will be generated and saved in the directory "attention_maps"
    output = model(batch)
    # more of your code...

Best Karol