swathikirans / violence-recognition-pytorch

AVSS violence recognition in pytorch
69 stars 17 forks source link

How to use resnet-18 or resnet-50 instead of alexnet as pretrained model? #12

Open yugaljain1999 opened 3 years ago

yugaljain1999 commented 3 years ago

Can I use resnet18 or resnet50 instead of alexnet as pretrained model ? If yes, then what changes I should do in createModel.py file? I tried to extract children features of resnet18 like you did for alexnet but it gives an error RuntimeError: mat1 dim 1 must match mat2 dim 0..

What should I do to resolve this error? Please reply! It's very important for me to do.. Thanks

swathikirans commented 3 years ago

self.convNet = nn.Sequential(*list(self.resnet.children())[:-2]) Change the input dimension of ConvLSTM to 512 for ResNet18 or 2048 for ResNet50 in here

yugaljain1999 commented 3 years ago

@swathikirans Thanks for this solution.. I have one more query.. Training is taking too much time.. The reason for this time consuming may be the version of python and pytorch I am using? I am using python 3.7 with pytorch 1.7. Code is working on this version but it is taking too much time to complete even 1 epoch.. So do you think this version change may be the reason for too much time consuming?

thanks

swathikirans commented 3 years ago

I don't think it is because of the change in the version of pytorch or python. If you are loading the images from a harddisk it will take a lot of time.