wfs123456 / CCTrans

Code Reproduction
56 stars 8 forks source link

Error on train.py - ShanghaiTech/part_A/ #1

Closed francescotaioli closed 2 years ago

francescotaioli commented 2 years ago

Error when training on ShanghaiTech/part_A/.

I have cloned your repo, made a small fix (the utils folder was not in the repo, in train.py you do from train_helper_PVT import Trainer but the name I think is train_helper_ALTGVT.py, I can make a Pull later on to fix this) Then i execute train.py, but as soon the code reaches the model creations, I get:

number of img: 300
number of img: 182
Traceback (most recent call last):
  File "train.py", line 63, in <module>
    trainer.setup()
  File "/train_folder/head_detection/CCTrans/train_helper_ALTGVT.py", line 77, in setup
    self.model = ALTGVT.alt_gvt_large(pretrained=True)
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 549, in alt_gvt_large
    model = ALTGVT(
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 496, in __init__
    super(ALTGVT, self).__init__(img_size, patch_size, in_chans, num_classes, embed_dims, num_heads,
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 483, in __init__
    super(PCPVT, self).__init__(img_size, patch_size, in_chans, num_classes, embed_dims, num_heads,
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 417, in __init__
    super(CPVTV2, self).__init__(img_size, patch_size, in_chans, num_classes, embed_dims, num_heads, mlp_ratios,
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 309, in __init__
    _block = nn.ModuleList([
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 310, in <listcomp>
    block_cls(
  File "/train_folder/head_detection/CCTrans/Networks/ALTGVT.py", line 236, in __init__
    super(GroupBlock, self).__init__(dim, num_heads, mlp_ratio, qkv_bias, qk_scale, drop, attn_drop,
TypeError: __init__() takes from 3 to 10 positional arguments but 11 were given
francescotaioli commented 2 years ago

Ok, this error goes away with timm==0.3.2 (I was using the latest timm 0.4.12 version)

After having fixed this, I have issue with another piece of code ( torch '1.10.0+cu113' version):

 File "/root/miniconda3/envs/head_detection/lib/python3.8/site-packages/timm/models/layers/helpers.py", line 6, in <module>
    from torch._six import container_abcs
ImportError: cannot import name 'container_abcs' from 'torch._six' (/root/miniconda3/envs/head_detection/lib/python3.8/site-packages/torch/_six.py)

The fix to this issue is to upgrade timm, but if I do this I have the positional arguments issue

francescotaioli commented 2 years ago

The error is in the qk_scale parameter. Your code: https://github.com/wfs123456/CCTrans/blob/07cdc756050bd5bfdf3def52769cb2aa4b26e7fd/Networks/ALTGVT.py#L236

Timm: https://github.com/rwightman/pytorch-image-models/blob/f7d210d759beb00a3d0834a3ce2d93f6e17f3d38/timm/models/vision_transformer.py#L213

wfs123456 commented 2 years ago

Please install timm=0.3.2, otherwise the above error will occur!

---Original--- From: "Francesco @.> Date: Tue, Dec 14, 2021 21:58 PM To: @.>; Cc: @.***>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/(Issue #1)

Ok, this error goes away with timm==0.3.2 (I was using the latest timm 0.4.12 version)

After having fixed this, I have issue with another piece of code ( torch '1.10.0+cu113' version):

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

francescotaioli commented 2 years ago

Thanks for the response. However, with timm=0.3.2 I have another error (cannot import name 'container_abcs' from 'torch._six')

wfs123456 commented 2 years ago

The version of torch should be 1.7!

---Original--- From: "Francesco @.> Date: Tue, Dec 14, 2021 22:48 PM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/ (Issue #1)

Thanks for the response. However, with timm=0.3.2 I have another error (cannot import name 'container_abcs' from 'torch._six')

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

francescotaioli commented 2 years ago

Unfortunately, I must use the last version of torch in order to use the last gen gpu

wfs123456 commented 2 years ago

U may creat conda virtual environment without affecting the local! Also, pytorch either 1.7 or 1.8 are available,because 1.9 and later version do not contain 'container_abcs' from 'torch._six'!

---Original--- From: "Francesco @.> Date: Wed, Dec 15, 2021 00:35 AM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/ (Issue #1)

Unfortunately, I have to upgrade torch to last version in order to use the last gen gpu

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

francescotaioli commented 2 years ago

This was not a environment problem, but I fixed it in the pull request. Also, there is a way I can contact you? I have a few question about the implementation, I think that some parts are not coherent with the original paper. Hope to hear you soon

wfs123456 commented 2 years ago

Thanks for the fix! You can contact me through email @.***)!

---Original--- From: "Francesco @.> Date: Mon, Dec 20, 2021 23:50 PM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/(Issue #1)

This was not a environment problem, but I fixed it in the pull request. Also, there is a way I can contact you? I have a few question about the implementation that I think is not coherent with the original paper. Hope to hear you soon

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

francescotaioli commented 2 years ago

I would, but I'm unable to find you email :)

wfs123456 commented 2 years ago

The above one is my Tencent mailbox, also,you can contact me by the university mailbox. @.***)

---Original--- From: "Francesco @.> Date: Tue, Dec 21, 2021 00:33 AM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/ (Issue #1)

I would, but I'm unable to find you email :)

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

wfs123456 commented 2 years ago

If the above not, NetEase mailbox can also be considered ! @.***)

---Original--- From: "Francesco @.> Date: Tue, Dec 21, 2021 00:33 AM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/ (Issue #1)

I would, but I'm unable to find you email :)

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

francescotaioli commented 2 years ago

I understand why I cannot view your email. When you write some address in the content of the issue email, as you did, GitHub will replace the address with @.***. Take a look at your message in the GitHub UI. You can find my address in my profile, please send an email so we can continue the discussion of the paper.

wfs123456 commented 2 years ago

My Tencent email:  @.***,please take out all the '-'

---Original--- From: "Francesco @.> Date: Tue, Dec 21, 2021 03:43 AM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/(Issue #1)

I understand why I cannot view your email. When you write some address in the content of the issue email, as you did, GitHub will replace the address with @.***. Take a look at your message in the GitHub UI.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

francescotaioli commented 2 years ago

OH, THIS IS WHAT I SEE, I CAN'T VIEW YOUR EMAIL! My Tencent email:  @.***,please take out all the '-'

wfs123456 commented 2 years ago

You can try to send me your email address, or transmit a paper with your email address to me, and then I will contact you!

---Original--- From: "Francesco @.> Date: Tue, Dec 21, 2021 23:29 PM To: @.>; Cc: @.**@.>; Subject: Re: [wfs123456/CCTrans] Error on train.py - ShanghaiTech/part_A/(Issue #1)

OH, THIS IS WHAT I SEE, I CAN'T VIEW YOUR EMAIL! My Tencent email:  @.***,please take out all the '-'

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

francescotaioli commented 2 years ago

Thank you! This is my email developer email: francescotdev@gmail.com