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

person serach #16

Open
zqx951102 opened this issue Aug 9, 2023 · 22 comments
Open

person serach #16

zqx951102 opened this issue Aug 9, 2023 · 22 comments

Comments

@zqx951102
Copy link

No description provided.

@zqx951102
Copy link
Author

resume --ckpt path/to/SOLIDER/log/lup/swin_tiny/checkpoint_tea.pth
i cannt find this .pth ? i only find this : swin_tiny.pth.

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 10, 2023

Before training person search, you should convert model first, as described in SOLIDER-PersonSearch, after which, you will have the checkpoint_tea.pth

@zqx951102
Copy link
Author

我在SLODER主页面 models那个地方 下载了 swin_tiny.pth
然后放在了 personsearch 下的log文件下
在去转换这个pth文件 :
python convert_model.py ./log/swin_tiny.pth ./log/checkpoint_tea.pth
报错:
raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: ./log/swin_tiny.pth is a zip archive (did you mean to use torch.jit.load()?)

而:
python convert_model.py path/to/SOLIDER/log/lup/swin_tiny/checkpoint.pth path/to/SOLIDER/log/lup/swin_tiny/checkpoint_tea.pth
还是没明白 这个path/to/SOLIDER/log/lup/swin_tiny/checkpoint.pth 在哪?
麻烦你啦!

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 10, 2023

1、报错目前看来是pytorch版本的问题,可以参考下SOLIDER-PersonSearch的安装环境。
2、“path/to/SOLIDER/log/lup/swin_tiny/checkpoint_tea.pth”,这个是convert_model.py的output,成功运行文件转换后,会在这个位置产出checkpoint_tea.pth。

@zqx951102
Copy link
Author

非常感谢 !确实是你说的那样 需要按照[SOLIDER-PersonSearch]的安装环境来配置!!
解决办法:
先去下载SLODER主页面 models那个地方 下载了 swin_tiny.pth
然后按照 python3.7 torch1.7.1 去配置 也可以参考solider-personsearch 的requirement.txt一键安装环境。pip install -r requirements.txt
接下来 把swin_tiny.pth 放到一个自己建立的目录下 :运行。 这样就解压出来了!
python convert_model.py ./log/swin_tiny.pth ./log/checkpoint_tea.pth
最后修改run.sh 里面的路径:
CUDA_VISIBLE_DEVICES=1 python train.py --cfg configs/prw.yaml --resume --ckpt ./log/checkpoint_tea.pth OUTPUT_DIR './results/prw/swin_tiny' SOLVER.BASE_LR 0.0003 EVAL_PERIOD 5 MODEL.BONE 'swin_tiny' INPUT.BATCH_SIZE_TRAIN 3 MODEL.SEMANTIC_WEIGHT 0.6
如果爆内存 就修改 INPUT.BATCH_SIZE_TRAIN 3 更小!

@zqx951102
Copy link
Author

你好:
麻烦你看一下 我上面那个评论的方法对不对? 目前按照这个解压出来的 tea.pth 然后去运行:run.sh
CUDA_VISIBLE_DEVICES=1 python train.py --cfg configs/prw.yaml --resume --ckpt ./log/checkpoint_tea.pth OUTPUT_DIR './results/prw/swin_tiny' SOLVER.BASE_LR 0.0003 EVAL_PERIOD 5 MODEL.BONE 'swin_tiny' INPUT.BATCH_SIZE_TRAIN 3 MODEL.SEMANTIC_WEIGHT 0.6
其中我更改了 --resume --ckpt ./log/checkpoint_tea.pth 也就是位置 其他的没动,但训练的结果却不是很好:
Epoch: [17] Total time: 0:29:05 (0.9180 s / it)
100% 6112/6112 [10:39<00:00, 9.56it/s]
100% 2057/2057 [03:43<00:00, 9.19it/s]
100% 2057/2057 [02:09<00:00, 15.92it/s]
all detection:
recall = 91.09%
ap = 83.23%
search ranking:
mAP = 34.41%
top- 1 = 76.67%
top- 5 = 88.38%
top-10 = 91.64%
PRW数据集 第17轮时候,mAP才 34 这是CBGM定义为false时候的结果. 不太明白那个地方没弄好吗? 感谢你解答!!

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 11, 2023

可以先看下初始化模型是否载入成功。

@zqx951102
Copy link
Author

imagecheckpoint_tea.pth 这个是权重文件吧。初始化模型是哪个?
image
在这个页面里面吗?

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 11, 2023

权重文件就是初始化模型,可以查看下是否成功载入。

@zqx951102
Copy link
Author

还是没明白什么意思 !
我不确定我之前的步骤是不是正确的!
我先把swin_tiny.pth 转换成 checkpoint_tea.pth。然后运行:
CUDA_VISIBLE_DEVICES=1 python train.py --cfg configs/prw.yaml --resume --ckpt ./log/checkpoint_tea.pth OUTPUT_DIR './results/prw/swin_tiny' SOLVER.BASE_LR
可以看见我是在log文件下导入 checkpoint_tea.pth
最终训练的结果很不好 还有就是:可以查看下是否成功载入 如何查看?

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 14, 2023

可以看下你训练时的日志,载入参数时日志会输出下面这个信息(https://github.com/tinyvision/SOLIDER-PersonSearch/blob/3204adb01bd97f416ca133f0726018240bc71b47/utils/utils.py#L425 ),可以用来观察初始化模型是否成功载入。另外,用seqnet时训练的batchsize会对效果产生,建议使用更大的batchsize。

@zqx951102
Copy link
Author

image PRW第一轮训练 结果才0.08 这一看估计就是不对劲呀 目前不知道如何解决.. CUDA_VISIBLE_DEVICES=1 python train.py --cfg configs/prw.yaml --resume --ckpt ./log/checkpoint_tea.pth OUTPUT_DIR './results/prw/swin_tiny' SOLVER.BASE_LR 0.0003 EVAL_PERIOD 5 MODEL.BONE 'swin_tiny' INPUT.BATCH_SIZE_TRAIN 3 MODEL.SEMANTIC_WEIGHT 0.6 CUDA_VISIBLE_DEVICES=1 python train.py --cfg configs/prw.yaml --resume --ckpt /home/zqx_tesla/home/zqx_tesla/PersonReID/PersonReID2/SOLIDER-PersonSearch-master/log/checkpoint_tea.pth 我把 run.sh 里面命令写成这样 不知道是哪出错了 ,如果是没有加载上与训练的模型? --resume --ckpt ./log/checkpoint_tea.pth 这个命令不就是加载模型吗? 还请大佬指点! 或者抽空这个地方的 复现步骤写的详细一点. 感谢!

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 15, 2023

你这里跑了两条命令,而且两条命令还不一样,你这个结果是哪个的呢?

@zqx951102
Copy link
Author

第一个第二个命令是一样的结果的 无非第二命令没加这么多参数 第二个我就是想看看 这个pth文件加载后是什么效果 所以现在也搞不懂是哪有问题了...代码能运行和训练 就是结果 很低 训练到最后 结果mAP才20多

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 15, 2023

两个命令的lr、batchsize、semantic weight甚至是初始化模型都是不一样的,你可以先debug下为啥完全不同的参数你这边结果都一样,看看参数载入是否有问题。

@zqx951102
Copy link
Author

感谢!这两天尝试了一下 应该是载入参数的问题 同样条件下 有可能就没有成功载入 这个看运气: 挑了一次的结果,总算有结果能出来了:(随机的 加载参数 )
PRW:
image
CUHK:
image
目前存在新的问题就是:
去验证时候 :
CUDA_VISIBLE_DEVICES=1 python train.py --cfg results/prw/swin_tiny/config.yaml --eval --ckpt results/prw/swin_tiny/epoch_21.pth
输入后 出来这样的 错误
image
也就是不动弹了 没法进行验证 保存的pth结果. 只能在训练的页面进行查看.

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 21, 2023

我建议还是先debug下问题,为啥载入参数会随机。不然没法说后面的问题啥什么造成的。按理说这个应该是能稳定复现的。

@zqx951102
Copy link
Author

好的 🙏感谢 确实有道理 我先去研究一下!

@zqx951102
Copy link
Author

image 训练时候:CUDA_VISIBLE_DEVICES=0 python train.py --cfg configs/prw.yaml --resume --ckpt /home/zqx_tesla/home/zqx_tesla/PersonReID/PersonReID2/SOLIDER-PersonSearch-master/log/checkpoint_tea.pth OUTPUT_DIR './results/prw/swin_tiny' SOLVER.BASE_LR 0.0003 EVAL_PERIOD 5 MODEL.BONE 'swin_tiny' INPUT.BATCH_SIZE_TRAIN 3 MODEL.SEMANTIC_WEIGHT 0.6 可以看到 参数载入 205loaded 8 missed

然后评估时候的命令:CUDA_VISIBLE_DEVICES=0 python train.py --cfg ./results/prw/swin_tiny/config.yaml --eval --ckpt ./results/prw/swin_tiny/epoch_22.pth EVAL_USE_CBGM True
image
0 loaede。 所以我就怀疑是不是 没有加载预训练的权重? 然后我就修改了 评估的命令:
CUDA_VISIBLE_DEVICES=0 python train.py --cfg results/prw/swin_tiny/config.yaml --eval --ckpt results/prw/swin_tiny/epoch_22.pth --resume --ckpt /home/zqx_tesla/home/zqx_tesla/PersonReID/PersonReID2/SOLIDER-PersonSearch-master/log/checkpoint_tea.pth
也就是把预训练的。pth文件给加上 结果:
image
变成205loaded 8missed 和训练时候的打印一样 但这个评估性能还是不对 全是0。
现在纠结的地方在于 ,为什么模型训练时候 train文件里面也有评估的过程 ,然后权重pth文件也保存了下来 ,但自己去评估这个结果时候 一直报错。没法验证。

@zqx951102
Copy link
Author

所以我想问问 你在评估时候 用的是那条命令? 因为我是按照seqnet的评估命令来输入的。不知道是不是还需要加别的指令?

@cwhgn
Copy link
Collaborator

cwhgn commented Aug 22, 2023

SOLIDER这里只是适配了seqnet的训练过程,训练时会做eval,可以查看训练结果。没有专门单独适配eval,如果需要的话可能需要自己做些修改适配。

@lly456
Copy link

lly456 commented Oct 18, 2023

有训练好的用于demo.py的权重吗?

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

3 participants