Coder Social home page Coder Social logo

Comments (6)

sssqfaa avatar sssqfaa commented on August 17, 2024 3

Hello, I modified the code according to the method you said, but it still failed to reach the result you showed. I suspect it may be related to the learning rate. Could you please tell me the learning rate and batchsize you have used?

from transreid.

Soar-Sir avatar Soar-Sir commented on August 17, 2024 2

Hello, I modified the code according to the method you said, but it still failed to reach the result you showed. I suspect it may be related to the learning rate. Could you please tell me the learning rate and batchsize you have used?

I also encountered the same situation, the accuracy of the swin model is not as high as expected.

from transreid.

michuanhaohao avatar michuanhaohao commented on August 17, 2024

Hi.

Swin transformer performs well in person ReID. There are some results:

Model Market Duke
Vit-base (Imagenet21k pre-training) 86.8/94.4 78.9/89.3
Swin-base (Imagenet21k pre-training) 89.3/95.4 81.2/90.4

from transreid.

Soar-Sir avatar Soar-Sir commented on August 17, 2024

Thanks! I want to know what codes you have changed?After I changed Backbone to swin-transformer, at the same time, I changed some codes in make_model.py, but the improvement effect is not obvious. Maybe my parameters are not set properly? If possible, can you share your files? It will be very helpful to me. Thanks again.

from transreid.

michuanhaohao avatar michuanhaohao commented on August 17, 2024

I only changed the window size for some special resolutions. You can try 224*224 resolution at first., which needs no change. The pre-trained models are pre-trained on ImageNet21K.

def pre_settings(img_size, drop_rate, attn_drop_rate, drop_path_rate):
    if img_size in ([256,128],[256,256],[384,128]):
        window_size = 8
    elif img_size in ([224,224],[224,112]):
        window_size =7
    elif img_size in ([384,384],[384,192]):
        window_size = 12
    elif img_size in ([192,192],):
        window_size = 6
    else:
        print('Window size dose not match!')
    print('Window size is set to %d'%window_size)
    print('using drop_out rate is : {}'.format(drop_rate))
    print('using attn_drop_out rate is : {}'.format(attn_drop_rate))
    print('using drop_path rate is : {}'.format(drop_path_rate))
    return window_size

def swin_base_patch4_window7_224(img_size=224,drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.1,camera_num=0, view_num=0, **kwargs):
    window_size = pre_settings(img_size, drop_rate, attn_drop_rate, drop_path_rate)
    model = SwinTransformer(img_size = img_size, patch_size=4, window_size=window_size, embed_dim=128, depths=(2, 2, 18, 2), num_heads=(4, 8, 16, 32), drop_path_rate=drop_path_rate, drop_rate=drop_rate, attn_drop_rate=attn_drop_rate, **kwargs)
    return model

def swin_small_patch4_window7_224(img_size=224,drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.1,camera_num=0, view_num=0, **kwargs):
    window_size = pre_settings(img_size, drop_rate, attn_drop_rate, drop_path_rate)
    model = SwinTransformer(img_size = img_size, patch_size=4, window_size=window_size, embed_dim=96, depths=(2, 2, 18, 2), num_heads=(3, 6, 12, 24), drop_path_rate=drop_path_rate, drop_rate=drop_rate, attn_drop_rate=attn_drop_rate, **kwargs)
    return model

from transreid.

CarrieYpi avatar CarrieYpi commented on August 17, 2024

I only changed the window size for some special resolutions. You can try 224*224 resolution at first., which needs no change. The pre-trained models are pre-trained on ImageNet21K.

def pre_settings(img_size, drop_rate, attn_drop_rate, drop_path_rate):
    if img_size in ([256,128],[256,256],[384,128]):
        window_size = 8
    elif img_size in ([224,224],[224,112]):
        window_size =7
    elif img_size in ([384,384],[384,192]):
        window_size = 12
    elif img_size in ([192,192],):
        window_size = 6
    else:
        print('Window size dose not match!')
    print('Window size is set to %d'%window_size)
    print('using drop_out rate is : {}'.format(drop_rate))
    print('using attn_drop_out rate is : {}'.format(attn_drop_rate))
    print('using drop_path rate is : {}'.format(drop_path_rate))
    return window_size

def swin_base_patch4_window7_224(img_size=224,drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.1,camera_num=0, view_num=0, **kwargs):
    window_size = pre_settings(img_size, drop_rate, attn_drop_rate, drop_path_rate)
    model = SwinTransformer(img_size = img_size, patch_size=4, window_size=window_size, embed_dim=128, depths=(2, 2, 18, 2), num_heads=(4, 8, 16, 32), drop_path_rate=drop_path_rate, drop_rate=drop_rate, attn_drop_rate=attn_drop_rate, **kwargs)
    return model

def swin_small_patch4_window7_224(img_size=224,drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.1,camera_num=0, view_num=0, **kwargs):
    window_size = pre_settings(img_size, drop_rate, attn_drop_rate, drop_path_rate)
    model = SwinTransformer(img_size = img_size, patch_size=4, window_size=window_size, embed_dim=96, depths=(2, 2, 18, 2), num_heads=(3, 6, 12, 24), drop_path_rate=drop_path_rate, drop_rate=drop_rate, attn_drop_rate=attn_drop_rate, **kwargs)
    return model

我也在更换为swin-transformer时,遇见了问题,代码中我是加载了预训练模型但似乎没有加载上,效果非常差,请问您能够分享更改为swin transformer完整的backbone代码以及make_model中的代码吗,非常感谢!!

from transreid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.