SeanChenxy / HandMesh

MIT License
339 stars 69 forks source link

[MobRecon] ResNet50 backbone reproduce #65

Closed clashroyaleisgood closed 1 year ago

clashroyaleisgood commented 2 years ago

Hi Xingyu,
我想請教關於重建 ResNet50 Backbone 的問題,以下是我照著 code 畫出來原版 Backbone 架構圖,以及我猜測的 ResNet50 Backbone 架構 請問這樣的架構正確嗎? 還是其實有某些地方是有問題的?

做的更改有

另外想請問: 在 image 大小的部分,是調整好 cfg.DATA.SIZE 就 OK 了嗎? 還是在 Dataset 裡面的 verts, joint_img 等也需要做更改嗎?

感謝!!!!

Backbone ResNet Backbone

SeanChenxy commented 2 years ago

Hi, ResNet50的改造看上去没有问题。可能有两个地方可以做修改(非必需):

  1. latent不需要降采样到4*4,可以保持7*7的分辨率。
  2. 28*28->784->128->64->2,这个过程可以考虑引入 avepool,从而变为 28*28 ->14*14->196->128->64->2。

image size变化后,不需要对verts,joint_img做额外修改。为确保数据没问题,可使用以下代码做可视化 https://github.com/SeanChenxy/HandMesh/blob/dbdca0d4fba75d7b010762edd4499b8102e06071/mobrecon/datasets/freihand.py#L345

clashroyaleisgood commented 2 years ago

感謝!! 我嘗試後再將結果分享上來

非常感謝

zhanpengxin commented 2 years ago

感謝!! 我嘗試後再將結果分享上來

非常感謝

期待你的结果!在学习如何复现resnet50 backbone...

clashroyaleisgood commented 1 year ago

Hi Xingyu, 我重建了 ResNet-50-Stack,但成果不盡理想,我使用 FreiHAND 官方 github 提供的 evaluation codeevaluation split annotations 跑出來的分數是:

xyz_al_mean3d( PJ ) mesh_al_mean3d( PV ) 單位
my-resnet50 0.644521 0.670844 cm
my-mrc_ds 0.685215 0.709544 cm
paper - pretrained backbone 5.7 5.8 mm
paper - not pretrained backbone 6.1 6.2 mm

其中 my-mrc_ds,是將作者提供的 mobrecon-densestack 重新訓練後跑出來的分數 my-resnet50,就是使用我重建的 ResNet-50-Stack Backbone

模型權重部分,與 ResNet50 同樣的部分( 兩個 Stack 中縮小的部分 - conv1, bn1, ..., layer4) 都使用 PyTorch 官方提供的 Pretrained Weight,沒有用 2D 資料先 Pretrained 過 Backbone,直接訓練整個 mobrecon-resnet50_stack。

雖然絕對不會像 paper-pretrained 那麼好,但我預期至少會跟 paper-not pretrained 差不多,結果卻差了一些,所以想再問一下模型架構是否還有需要調整的地方,因為後來發現實作上的困難,所以又調整了幾個地方。

ReaNetStack 修改:

ResNetStack 放大部分的 layer4 ~ layer1,我是用與 ReaNet50 的 layer 完全相同的 BottleNeck 大小 註1,在最後再接上 Upsample 放大 resolution,接上 Conv1x1 調整 channel 數,接上 BatchNorm 其他後方的 uv_reg 等,也根據您上次的回覆進行修正了。

註1: ResNet 中,各 layer 的第一層因為調整 resolution 與 channel 數,與後續幾層有不同的設計 我選擇的是後續幾層的 BottleNeck 大小。

Code 部分:

重建 ResNet_Stack commit 使用 PyTorch official weight @zhanpengxin 希望不會太晚~

架構圖呈現如下:

與原版 ResNet50, DenseStack 不同的部分用紅色與黃色特別標明 HandMesh-ResNet Backbone edited

感謝!!

jeffreyking23 commented 1 year ago

Hi Xingyu, 我重建了 ResNet-50-Stack,但成果不盡理想,我使用 FreiHAND 官方 github 提供的 evaluation codeevaluation split annotations 跑出來的分數是:

xyz_al_mean3d( PJ ) mesh_al_mean3d( PV ) 單位 my-resnet50 0.644521 0.670844 cm my-mrc_ds 0.685215 0.709544 cm paper - pretrained backbone 5.7 5.8 mm paper - not pretrained backbone 6.1 6.2 mm

其中 my-mrc_ds,是將作者提供的 mobrecon-densestack 重新訓練後跑出來的分數 my-resnet50,就是使用我重建的 ResNet-50-Stack Backbone

模型權重部分,與 ResNet50 同樣的部分( 兩個 Stack 中縮小的部分 - conv1, bn1, ..., layer4) 都使用 PyTorch 官方提供的 Pretrained Weight,沒有用 2D 資料先 Pretrained 過 Backbone,直接訓練整個 mobrecon-resnet50_stack。

雖然絕對不會像 paper-pretrained 那麼好,但我預期至少會跟 paper-not pretrained 差不多,結果卻差了一些,所以想再問一下模型架構是否還有需要調整的地方,因為後來發現實作上的困難,所以又調整了幾個地方。

ReaNetStack 修改:

ResNetStack 放大部分的 layer4 ~ layer1,我是用與 ReaNet50 的 layer 完全相同的 BottleNeck 大小 註1,在最後再接上 Upsample 放大 resolution,接上 Conv1x1 調整 channel 數,接上 BatchNorm 其他後方的 uv_reg 等,也根據您上次的回覆進行修正了。

註1: ResNet 中,各 layer 的第一層因為調整 resolution 與 channel 數,與後續幾層有不同的設計 我選擇的是後續幾層的 BottleNeck 大小。

Code 部分:

重建 ResNet_Stack commit 使用 PyTorch official weight @zhanpengxin 希望不會太晚~

架構圖呈現如下:

與原版 ResNet50, DenseStack 不同的部分用紅色與黃色特別標明 HandMesh-ResNet Backbone edited

感謝!!

你好,my_resnet.py能提供一下吗?或者是resnetstack.pth

clashroyaleisgood commented 1 year ago

你好,my_resnet.py能提供一下吗?或者是resnetstack.pth

啊! 其實 Bottleneck 跟 resnetstack.py 裡面的 Bottleneck 都一樣是從官方 Pytorch Resnet 搬過來的 code 忘了當初為什麼要從 my_resnet.py 那邊 import。

所以可以直接改從 resnetstack.py import 就好了。

jeffreyking23 commented 1 year ago

你好,my_resnet.py能提供一下吗?或者是resnetstack.pth

啊! 其實 Bottleneck 跟 resnetstack.py 裡面的 Bottleneck 都一樣是從官方 Pytorch Resnet 搬過來的 code 忘了當初為什麼要從 my_resnet.py 那邊 import。

所以可以直接改從 resnetstack.py import 就好了。

好的,成功了!感谢你!

SeanChenxy commented 1 year ago

Hi, sorry for late reply。可以尝试以下修改
resnet

clashroyaleisgood commented 1 year ago

非常感謝!!! 我再嘗試看看

brian208579 commented 1 year ago

@clashroyaleisgood Hi, Mengxue 請問您近期有什麼後續進展可以分享的嗎? 最近剛好在看這個 work 並且有興趣想嘗試用 tensorflow 實作看看這樣 謝謝您!

@SeanChenxy Hi, Xingyu 首先想先感謝您對此 work 的開源貢獻 這邊想 reproduce 您 paper 中的 MobileNet stack 想藉此請教您是否有相關的資料或是一些實作得細節可以提供給我參考的嗎? 還有一個疑問是請問您在 pre-train 時的 backbone ( hourglass ) 有兩個 stack,那這兩個 stack 都有參與 heatmap loss 的計算嗎?heatmap 與 key-points 的 loss function 分別是使用了什麼?是否有引入 loss weight?pre-train 後在 fine-tune 時是全部的 weights 都參與訓練還是只有某一部分呢? 不好意思,問題稍微有些多,期待您能在空閒時撥出時間替我解惑 謝謝您!

zhanpengxin commented 1 year ago

你好,我已收到你的邮件,我会及时处理^_^

clashroyaleisgood commented 1 year ago

@brian208579 您好! 抱歉近期都在忙著做畢業論文相關的研究與實驗...所以 backbone 部分就沒有再去推進度了

關於下面給作者的問題,有個應該可以幫忙回答,有誤再麻煩作者更正了

pre-train 後在 fine-tune 時是全部的 weights 都參與訓練還是只有某一部分呢?

我自己在做實驗的時候,曾經將 Backbone 輸出的 feature 經過 detach( 將 gradient 截斷 ) 後再往後傳,最後的訓練成果蠻糟糕的,而將 detach 取消掉後就恢復正常了

由此推測 Backbone 所需的 Loss 除了原先的 2D joint loss 以外,也需要整個模型的 3D Loss 另一個角度看,原先 Backbone 所產出的 feature 並不足以讓後續的 GCN 預測出好的 Verts 位置, 必須要透過 3D Loss 來逐步改善 Backbone 所產出的 feature

brian208579 commented 1 year ago

@brian208579 您好! 抱歉近期都在忙著做畢業論文相關的研究與實驗...所以 backbone 部分就沒有再去推進度了

關於下面給作者的問題,有個應該可以幫忙回答,有誤再麻煩作者更正了

pre-train 後在 fine-tune 時是全部的 weights 都參與訓練還是只有某一部分呢?

我自己在做實驗的時候,曾經將 Backbone 輸出的 feature 經過 detach( 將 gradient 截斷 ) 後再往後傳,最後的訓練成果蠻糟糕的,而將 detach 取消掉後就恢復正常了

由此推測 Backbone 所需的 Loss 除了原先的 2D joint loss 以外,也需要整個模型的 3D Loss 另一個角度看,原先 Backbone 所產出的 feature 並不足以讓後續的 GCN 預測出好的 Verts 位置, 必須要透過 3D Loss 來逐步改善 Backbone 所產出的 feature

非常感謝您的回覆!你提供的資訊對我有非常大的幫助,我會再加以嘗試著墨,在這邊預祝您論文與口試都順利!

Shirley-olivia commented 5 months ago

@clashroyaleisgood sorry to bother you, could you tell me how many epoches did you use when you train on the resnet50? I also tried on resnet50, but the outcome is worse.

clashroyaleisgood commented 5 months ago

@clashroyaleisgood sorry to bother you, could you tell me how many epoches did you use when you train on the resnet50? I also tried on resnet50, but the outcome is worse.

Hi @Shirley-olivia, I don’t remember clearly, but it should be the same as monrecon. Also, did you remember to pre-train ResNet50 backbone? I trained my backbone in 80 epochs, and the learning rate is 10^-3 at 0\~20 epoch, 10^-4 at 20\~40, 10^-5 at 40\~60, 10^6 at 60\~80 (which is in my notes, I totally forget about it😅)

Maybe you can ask author @SeanChenxy for correct answer.

Shirley-olivia commented 5 months ago

@clashroyaleisgood sorry to bother you, could you tell me how many epoches did you use when you train on the resnet50? I also tried on resnet50, but the outcome is worse.

Hi @Shirley-olivia, I don’t remember clearly, but it should be the same as monrecon. Also, did you remember to pre-train ResNet50 backbone? I trained my backbone in 80 epochs, and the learning rate is 10^-3 at 0~20 epoch, 10^-4 at 20~40, 10^-5 at 40~60, 10^6 at 60~80 (which is in my notes, I totally forget about it😅)

Maybe you can ask author @SeanChenxy for correct answer.

Thanks a lot! I did not pretrain ResNet50 backbone, and that may be the reason for my bad outcome.And I notice that the author pretrain the model based on the synthesized data, which include 2D pose position and heatmap based on L1 loss. Did you pretrain like this or could you share the way you pretrain resnet50?