TVP

# AI 玩跳一跳的正确姿势，Auto-Jump 算法详解

zhuanlan.zhihu.com/p/32636329

def multi_scale_search(pivot,screen,range=0.3,num=10):

H,W=screen.shape[:2]

h,w=pivot.shape[:2]

found=None

forscaleinnp.linspace(1-range,1+range,num)[::-1]:

resized=cv2.resize(screen,(int(W *scale),int(H *scale)))

r=W/float(resized.shape[1])

ifresized.shape[]

break

res=cv2.matchTemplate(resized,pivot,cv2.TM_CCOEFF_NORMED)

loc=np.where(res>=res.max())

pos_h,pos_w=list(zip(*loc))[]

iffoundisNoneorres.max()>found[-1]:

found=(pos_h,pos_w,r,res.max())

iffoundisNone:return(,,,,)

pos_h,pos_w,r,score=found

start_h,start_w=int(pos_h *r),int(pos_w *r)

end_h,end_w=int((pos_h+h)*r),int((pos_w+w)*r)

return[start_h,start_w,end_h,end_w,score]

CNN Coarse-to-Fine 模型

Coarse 模型数据预处理

Fine 模型数据预处理

Coarse 模型

def forward(self,img,is_training,keep_prob,name='coarse'):

withtf.name_scope(name):

withtf.variable_scope(name):

out=self.conv2d('conv1',img,[3,3,self.input_channle,16],2)

out=self.make_conv_bn_relu('conv2',out,[3,3,16,32],1,is_training)

out=self.make_conv_bn_relu('conv3',out,[5,5,32,64],1,is_training)

out=self.make_conv_bn_relu('conv4',out,[7,7,64,128],1,is_training)

out=self.make_conv_bn_relu('conv5',out,[9,9,128,256],1,is_training)

out=tf.reshape(out,[-1,256*20*23])

out=self.make_fc('fc1',out,[256*20*23,256],keep_prob)

out=self.make_fc('fc2',out,[256,2],keep_prob)

returnout

Fine 模型

fine模型结构与coarse模型类似，参数量稍大，fine模型作为对coarse模型的refine操作，

def forward(self,img,is_training,keep_prob,name='fine'):

withtf.name_scope(name):

withtf.variable_scope(name):

out=self.conv2d('conv1',img,[3,3,self.input_channle,16],2)

out=self.make_conv_bn_relu('conv2',out,[3,3,16,64],1,is_training)

out=self.make_conv_bn_relu('conv3',out,[5,5,64,128],1,is_training)

out=self.make_conv_bn_relu('conv4',out,[7,7,128,256],1,is_training)

out=self.make_conv_bn_relu('conv5',out,[9,9,256,512],1,is_training)

out=tf.reshape(out,[-1,512*10*10])

out=self.make_fc('fc1',out,[512*10*10,512],keep_prob)

out=self.make_fc('fc2',out,[512,2],keep_prob)

returnout

Cascade

Git仓库地址：

https://github.com/Prinsphield/Wechat_AutoJump

https://github.com/Richard-An/Wechat_AutoJump

• 发表于:
• 原文链接http://kuaibao.qq.com/s/20180118B0VDKQ00?refer=cp_1026
• 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号（企鹅号）传播渠道之一，根据《腾讯内容开放平台服务协议》转载发布内容。
• 如有侵权，请联系 cloudcommunity@tencent.com 删除。

2023-01-27

2023-01-27

2023-01-27

2023-01-27

2023-01-27

2023-01-27

2023-01-27

10元无门槛代金券