SydCaption / SAAT

MIT License
62 stars 21 forks source link

About extraction of 3D feature #15

Closed BBBoundary closed 3 years ago

BBBoundary commented 4 years ago

Hello!I'm trying to use your project code to test my own video. Thanks for providing the code to extract the features. We import the models in 3D-ResNets-Pytorch demo you linked into the misc folder, but we have the following problems when extracting 3D features:

Traceback (most recent call last): File "./misc/extract_featsmotion.py", line 82, in model, = generate_model(opt) File "/media/louyu/DATA/SAAT/misc/model.py", line 51, in generate_model n_classes=opt.n_classes) File "/media/louyu/DATA/SAAT/misc/models/resnext.py", line 66, in generate_model **kwargs) File "/media/louyu/DATA/SAAT/misc/models/resnext.py", line 53, in init shortcut_type, n_classes) File "/media/louyu/DATA/SAAT/misc/models/resnet.py", line 132, in init shortcut_type) File "/media/louyu/DATA/SAAT/misc/models/resnet.py", line 189, in _make_layer downsample=downsample)) TypeError: init() got an unexpected keyword argument 'in_planes'

I wonder how to solve this problem. Thanks!

SydCaption commented 4 years ago

Hi, the feature is from the layer before the last fc-layer. I made two changes

diff --git a/models/resnext.py b/models/resnext.py
index 857560f..c604983 100644
--- a/models/resnext.py
+++ b/models/resnext.py
@@ -118,7 +118,7 @@ class ResNeXt(nn.Module):

         for m in self.modules():
             if isinstance(m, nn.Conv3d):
-                m.weight = nn.init.kaiming_normal(m.weight, mode='fan_out')
+                m.weight = nn.init.kaiming_normal_(m.weight, mode='fan_out')
             elif isinstance(m, nn.BatchNorm3d):
                 m.weight.data.fill_(1)
                 m.bias.data.zero_()
@@ -169,7 +169,7 @@ class ResNeXt(nn.Module):
         x = self.avgpool(x)

         x = x.view(x.size(0), -1)
-        x = self.fc(x)
+        #x = self.fc(x)

         return x

Hope this can help~

BBBoundary commented 4 years ago

Thanks for your quick reply~ But unfortunately we are new to this field, so we still can't this problem. We modified the code according to your help but it still reported the previous error. We guess there's something wrong with the previous code or we misunderstood your method. Since we don't have much experience in coding of Deep Learning, we hope we can learn from solving this problem. So it'll be highly appreciated if you can send the models files(resnet.py, resnext.py etc.) to our email@culaccino_9350@163.com QAQ!!

tangyuhao2016 commented 4 years ago

Hello,sir. When I try the code you open to extract motion features, I have the same problem.

TypeError: init() got an unexpected keyword argument 'in_planes

May you give the model file such as resnet.py resnext.py to the email 1552981316@qq.com. Thank you very much,sir

tangyuhao2016 commented 4 years ago

Thanks for your quick reply~ But unfortunately we are new to this field, so we still can't this problem. We modified the code according to your help but it still reported the previous error. We guess there's something wrong with the previous code or we misunderstood your method. Since we don't have much experience in coding of Deep Learning, we hope we can learn from solving this problem. So it'll be highly appreciated if you can send the models files(resnet.py, resnext.py etc.) to our email@culaccino_9350@163.com QAQ!!

Hi,have you solved this problem?

SydCaption commented 4 years ago

Hi, I uploaded the files in 3D-ResNets-Pytorch/models @tangyuhao2016