Alibaba-MIIL / TResNet

Official Pytorch Implementation of "TResNet: High-Performance GPU-Dedicated Architecture" (WACV 2021)
Apache License 2.0
471 stars 63 forks source link

something get wrong when loading model #41

Closed myh12138 closed 2 years ago

myh12138 commented 2 years ago

Traceback (most recent call last): File "infer.py", line 99, in main() File "infer.py", line 35, in main aaa = torch.jit.script(model2) File "/home/kpl/.conda/envs/ASL/lib/python3.6/site-packages/torch/jit/_script.py", line 898, in script obj, torch.jit._recursive.infer_methods_to_compile File "/home/kpl/.conda/envs/ASL/lib/python3.6/site-packages/torch/jit/_recursive.py", line 352, in create_script_module return create_script_module_impl(nn_module, concrete_type, stubs_fn) File "/home/kpl/.conda/envs/ASL/lib/python3.6/site-packages/torch/jit/_recursive.py", line 410, in create_script_module_impl create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs) File "/home/kpl/.conda/envs/ASL/lib/python3.6/site-packages/torch/jit/_recursive.py", line 304, in create_methods_and_properties_from_stubs concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults) RuntimeError: Tried to set nonexistent attribute: embeddings. Did you forget to initialize it in init()?: File "/home/kpl/code/multilabel/TResNet/src/models/tresnet/tresnet.py", line 190 def forward(self, x): x = self.body(x) self.embeddings = self.global_pool(x)


        logits = self.head(self.embeddings)
        return logits
myh12138 commented 2 years ago

I tried python infer.py --remove_aa_jit still can't work

myh12138 commented 2 years ago

the inplace_abn my version is v1.0.12 is that influence? thanks.

mrT23 commented 2 years ago

for jit acceleration, try changing

self.embeddings = self.global_pool(x)
logits = self.head(self.embeddings)

to

embeddings = self.global_pool(x)
logits = self.head(embeddings)
myh12138 commented 2 years ago

for jit acceleration, try changing

self.embeddings = self.global_pool(x)
logits = self.head(self.embeddings)

to

embeddings = self.global_pool(x)
logits = self.head(embeddings)

thanks,I can tun your ASL successfully, I will try your suggestion later.