Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A solution: HRNet Backbone Adopt_different_blocks_bug(BASIC//BOTTLENECK) #28

Open
Taylor-X76 opened this issue Sep 1, 2020 · 2 comments

Comments

@Taylor-X76
Copy link

https://github.com/HRNet/HRNet-Image-Classification/blob/8f158719e821836e21e6cba99a3241a12a13bc41/lib/models/cls_hrnet.py#L459~L473
If different block types are used in different stages, instead of the default bottleneck-basic-basic-basic in the original yaml file, the channel mismatch error as shown in the figure below will appear. To avoid this error, we change it in the transition layer and use conv3*3 between different stages to match the number of channels. The corrected code and results are shown in the figure below.
(The demonstration is only a proof of feasibility, not an actual demonstration of the code)

@Taylor-X76
Copy link
Author

HRNet_v2不同block_yaml文件
HRNet_v2不同block_bug
HRNet_v2不同block_改正
HRNet_v2不同block_bug代码更改

@Taylor-X76
Copy link
Author

`# ############################# Modified by Mingyang ##############################################################

##################### Adopt_different_blocks_bug(BASIC//BOTTLENECK)

    # x_list = []
    # for i in range(self.stage3_cfg['NUM_BRANCHES']):
    #     if self.transition2[i] is not None:
    #         x_list.append(self.transition2[i](y_list[-1]))
    #     else:
    #         x_list.append(y_list[i])
    # y_list = self.stage3(x_list)

    # x_list = []
    # for i in range(self.stage4_cfg['NUM_BRANCHES']):
    #     if self.transition3[i] is not None:
    #         x_list.append(self.transition3[i](y_list[-1]))
    #     else:
    #         x_list.append(y_list[i])
    # y_list = self.stage4(x_list)

    x_list = []
    for i in range(self.stage3_cfg['NUM_BRANCHES']):  # 3
        if self.transition2[i] is not None and i < self.stage2_cfg['NUM_BRANCHES']:  # 有通道数匹配卷积且处于平连阶段
            x_list.append(self.transition2[i](y_list[i]))   # #################bug
        elif self.transition2[i] is not None and i >= self.stage2_cfg['NUM_BRANCHES']:  # 下采样阶段
            x_list.append(self.transition2[i](y_list[-1]))  # #################bug
        else:                                      # ############应改为
            x_list.append(y_list[i])
    y_list = self.stage3(x_list)

    x_list = []
    for i in range(self.stage4_cfg['NUM_BRANCHES']): # 4
        if self.transition3[i] is not None and i < self.stage3_cfg['NUM_BRANCHES']:  # 有通道数匹配卷积且处于平连阶段:
            x_list.append(self.transition3[i](y_list[i]))   # #################bug
        elif self.transition3[i] is not None and i >= self.stage3_cfg['NUM_BRANCHES']:  # 下采样阶段
            x_list.append(self.transition3[i](y_list[-1]))  # #################bug
        else:
            x_list.append(y_list[i])
    y_list = self.stage4(x_list)  # stage4中的multi_scale_output不是False,所以产生[fuse_x0,fuse_x1,fuse_x2,fuse_x3]

############################# Adopt_different_blocks_bug(BASIC//BOTTLENECK) #############################################`

@Taylor-X76 Taylor-X76 changed the title HRNet Backbone Adopt_different_blocks_bug(BASIC//BOTTLENECK) A solution: HRNet Backbone Adopt_different_blocks_bug(BASIC//BOTTLENECK) Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant