《Learning from Synthetic Data for Crowd Counting in the Wild》阅读与调试

1.方法简介

基于GTA5渲染人员密集的场景,从游戏数据中获取标注组成GTA5 Crowd Counting (GCC) Dataset。数据集使用方式有两种:(1)算法再GCC 中先训练再在真实数据集中微调;(2)基于域适应的方法

2.数据采集

2.1 主要步骤

1.场景选择。选择100个典型场所,每个场所四个摄像头,总共400种场景。
2.人物模型。265个人物模型。
3.场景合成。GTA5限制每个画面最多256个人。同一场景下多个人物非重叠画面合成。
在这里插入图片描述

2.2 流程

(a)选择场景和摄像头位置
(b)划出roi区域(指要在场景中哪里放置人物)
(c)设置天气和时间
(d)放置行人
(1)在roi区域中放置人物模型获取他的头部位置
(2)从stencil 获取 人的mask
(3)合并多个同场景的图像
(4)删除遮挡的头

2.3 采集结果

总共15212张图像,分辨率为1080 × \times × 1920 ,7625843个人物标注。
在这里插入图片描述
场景分布
在这里插入图片描述
时间段和天气分布

3. GCC上监督训练

两种实验(1)所有算法都在GCC上训练测试(2)在GCC上训练完成后然后在真实数据中微调。

4. 域适应方法利用GCC

这样去除人工标注的工作,将GCC Dataset 转换为接近真实的数据。domain gap。基于GAN 提出SSIM Embedding (SE) Cycle GAN。浅绿色是cycle gan 结构,橘色是密度估计模型。
在这里插入图片描述

S:合成的数据域,包含图像和标签 I S , L s {I_S,L_s} IS,Ls
R:真实的数据域,仅包含图像
有两个风格转换器, G S → R , G S ← R G_{S\rightarrow R},G_{S\leftarrow R} GSR,GSR,两种风格互相变换后 i S → G S → R ( i S ) → G R → S ( G S → R ( i S ) ) ≈ i S \mathrm{i}_{\mathcal{S}} \rightarrow G_{\mathcal{S} \rightarrow \mathcal{R}}\left(\mathrm{i}_{\mathcal{S}}\right) \rightarrow G_{\mathcal{R} \rightarrow \mathcal{S}}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}\left(\mathrm{i}_{\mathcal{S}}\right)\right) \approx \mathrm{i}_{\mathcal{S}} iSGSR(iS)GRS(GSR(iS))iS的一致性损失为:
L cycle  ( G S → R , G R → S , S , R ) = E i S ∼ I S [ ∥ G R → S ( G S → R ( i S ) ) − i S ∥ 1 ] + E i R ∼ I R [ ∥ G S → R ( G R → S ( i R ) ) − i R ∥ 1 \begin{aligned} \mathcal{L}_{\text {cycle }}(& \left.G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, \mathcal{S}, \mathcal{R}\right) \\ &=\mathbb{E}_{i_{S} \sim I_{\mathcal{S}}}\left[\left\|G_{\mathcal{R} \rightarrow \mathcal{S}}\left(G_{\mathcal{S} \rightarrow R}\left(i_{\mathcal{S}}\right)\right)-i_{\mathcal{S}}\right\|_{1}\right] \\ &+\mathbb{E}_{i_{\mathcal{R}} \sim I_{\mathcal{R}}}\left[\left\|G_{\mathcal{S} \rightarrow \mathcal{R}}\left(G_{\mathcal{R} \rightarrow S}\left(i_{\mathcal{R}}\right)\right)-i_{\mathcal{R}}\right\|_{1}\right.\end{aligned} Lcycle (GSR,GRS,S,R)=EiSIS[GRS(GSR(iS))iS1]+EiRIR[GSR(GRS(iR))iR1
一对生成器和差别器的对抗损失为:
L GAN  ( G S → R , D R , S , R ) = E i R ∼ I R [ log ⁡ ( D R ( i R ) ] + E i S ∼ I S [ log ⁡ ( 1 − D R ( G S → R ( i S ) ) ] \begin{aligned} \mathcal{L}_{\text {GAN }}(& \left.G_{\mathcal{S} \rightarrow \mathcal{R}}, D_{\mathcal{R}}, \mathcal{S}, \mathcal{R}\right) \\ &=\mathbb{E}_{i_{\mathcal{R} \sim I_{\mathcal{R}}}}\left[\log \left(D_{\mathcal{R}}\left(i_{\mathcal{R}}\right)\right]\right.\\ &+\mathbb{E}_{i_{\mathcal{S}} \sim I_{\mathcal{S}}}\left[\log \left(1-D_{\mathcal{R}}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}\left(i_{\mathcal{S}}\right)\right)\right]\right.\end{aligned} LGAN (GSR,DR,S,R)=EiRIR[log(DR(iR)]+EiSIS[log(1DR(GSR(iS))]
整个cycle gan的损失为:
L CycleGAN  ( G S → R , G R → S , D R , D S , S , R ) = L G A N ( G S → R , D R , S , R ) + L G A N ( G R → S , D S , S , R ) + λ L cycle  ( G S → R , G R → S , S , R ) \begin{aligned} \mathcal{L}_{\text {CycleGAN }}(& \left.G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, D_{\mathcal{R}}, D_{\mathcal{S}}, \mathcal{S}, \mathcal{R}\right) \\ &=\mathcal{L}_{G A N}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, D_{\mathcal{R}}, \mathcal{S}, \mathcal{R}\right) \\ &+\mathcal{L}_{G A N}\left(G_{\mathcal{R} \rightarrow \mathcal{S}}, D_{\mathcal{S}}, \mathcal{S}, \mathcal{R}\right) \\ &+\lambda \mathcal{L}_{\text {cycle }}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, \mathcal{S}, \mathcal{R}\right) \end{aligned} LCycleGAN (GSR,GRS,DR,DS,S,R)=LGAN(GSR,DR,S,R)+LGAN(GRS,DS,S,R)+λLcycle (GSR,GRS,S,R)
作者额外引入ssim 损失
L SEcycle  ( G S → R , G R → S , S , R ) \mathcal{L}_{\text {SEcycle }}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, \mathcal{S}, \mathcal{R}\right) LSEcycle (GSR,GRS,S,R)
= E i S ∼ I S [ 1 − S S I M ( i S , G R → S ( G S → R ( i S ) ) ) ] =\mathbb{E}_{i_{\mathcal{S}} \sim I_{\mathcal{S}}}\left[1-S S I M\left(i_{\mathcal{S}}, G_{\mathcal{R} \rightarrow \mathcal{S}}\left(G_{\mathcal{S} \rightarrow R}\left(i_{\mathcal{S}}\right)\right)\right)\right] =EiSIS[1SSIM(iS,GRS(GSR(iS)))]
+ E i R ∼ I R [ 1 − S SIM ⁡ ( i R , G S → R ( G R → S ( i R ) ) ) ] +\mathbb{E}_{i_{\mathcal{R}} \sim I_{\mathcal{R}}}\left[1-S \operatorname{SIM}\left(i_{\mathcal{R}}, G_{\mathcal{S} \rightarrow \mathcal{R}}\left(G_{\mathcal{R} \rightarrow S}\left(i_{\mathcal{R}}\right)\right)\right)\right] +EiRIR[1SSIM(iR,GSR(GRS(iR)))]

L ours  ( G S → R , G R → S , D R , D S , S , R ) \mathcal{L}_{\text {ours }}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, D_{\mathcal{R}}, D_{\mathcal{S}}, \mathcal{S}, \mathcal{R}\right) Lours (GSR,GRS,DR,DS,S,R)
= L G A N ( G S → R , D R , S , R ) =\mathcal{L}_{G A N}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, D_{\mathcal{R}}, \mathcal{S}, \mathcal{R}\right) =LGAN(GSR,DR,S,R)
+ L G A N ( G R → S , D S , S , R ) +\mathcal{L}_{G A N}\left(G_{\mathcal{R} \rightarrow \mathcal{S}}, D_{\mathcal{S}}, \mathcal{S}, \mathcal{R}\right) +LGAN(GRS,DS,S,R)
+ λ L cycle  ( G S → R , G R → S , S , R ) +\lambda \mathcal{L}_{\text {cycle }}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, \mathcal{S}, \mathcal{R}\right) +λLcycle (GSR,GRS,S,R)
+ μ L S E  cycle  ( G S → R , G R → S , S , R ) +\mu \mathcal{L}_{S E \text { cycle }}\left(G_{\mathcal{S} \rightarrow \mathcal{R}}, G_{\mathcal{R} \rightarrow \mathcal{S}}, \mathcal{S}, \mathcal{R}\right) +μLSE cycle (GSR,GRS,S,R)
ssim 评估两张图片结构相似性,越相似越接近1。
Gan网络训练完成后将数据集进行转换。

5. GCC工具调试
项目编译

可以直接下载已编译好的文件,从第4步开始。
1.下载,用VS打开GCC-Collector/GCC-Collector.sln文件。
2.使用Nuget 安装minhook、eigen。工具->Nuget包管理器->程序包管理器控制台。命令

Install-Package minhook eigen

3.解决方案配置为"release",“x64”,ctrl + shift + B生成项目,如果没有错误 /GCC-CL/GCC-Collector/x64/Release下会生成文件GCC-Collector.asi 。但是报错,如图5.2。解决办法是右键项目-属性-常规-目标平台版本-选择一个已安装的sdk。
在这里插入图片描述
图5.1
在这里插入图片描述
图5.2
报错:LINK : fatal error LNK1158: 无法运行“rc.exe” 。缺少rc.exe程序
参考:https://blog.csdn.net/qq_29969029/article/details/105879495
安装
4. 下载GTA V,ScriptHookV,将ScriptHookV.dll, dinput8.dll , SceneDirectorAnim.txt 和生成的 GCC-Collector.asi,unlimitedLife.asi, noVehicle.asi文件放至游戏根目录(GTA.exe文件所在目录)。
5. 使用mod:No Chromatic aberration & Lens distortion。需要先安装 openIV,使用说明,打开openIV设置游戏目录,设置后结果如图5.3。解压后将xml文件放至Grand Theft Auto V \ mods \ update 目录
在这里插入图片描述
图5.3
6.游戏根目录中创建data文件夹,运行游戏。参考readme-how to work 部分。

7.设置好地点后每个会生成4个目录对应四个摄像头,如图5.4。运行Python文件生成数据集,样例如图5.5。
在这里插入图片描述
图5.4

在这里插入图片描述
图5.5
整体操作流程需要手工选择地点和拍摄角度(熟悉游戏可以直接配置文件),gcc-collector生成原始数据时每次只能生成一个目录(一个地点的一个角度)下的数据,然后游戏就自动退出了,暂不清楚是否为其它原因。另外,会产生明显没用的图像,如图5.6中的天空图像。
在这里插入图片描述
图5.6

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值