experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 784 forks source link

3d version with voxels #418

Open rankofootball opened 5 years ago

rankofootball commented 5 years ago

Hi,

I am adapting yolo2 to deal with 3D images. One problem I encountered is that the tensor flow function space_to_depth does not exist for that many dimensions. Does anyone have experience with this? I am not so sure what the original tensorflow function does.

Here is what I tried:

def space_to_depth_x2(input): block_size = 2 block_size_3 = block_sizeblock_sizeblock_size

batch_size = tf.shape(input)[0]
s_height = 2*GRID_H 
s_width = 2*GRID_W
s_z = 2*GRID_Z
s_depth = tf.shape(input)[4]

d_depth = tf.math.scalar_mul(block_size_3,s_depth)
d_width = GRID_W 
d_height = GRID_H
d_z = GRID_Z  

y=tf.reshape(input,[batch_size, d_z, block_size,d_height, block_size, d_width, block_size*s_depth])
y=tf.transpose(y, [0,1,2,3,5,4,6])
y=tf.reshape(y,[batch_size, d_z, block_size,d_height, d_width, block_size*block_size*s_depth])
y=tf.transpose(y, [0,1,3,4,2,5])
y=tf.reshape(y,[batch_size, d_z, d_height, d_width, 512])

return y
marcospgp commented 5 years ago

Off topic: We live in a 3D world but our eyes work with 2D images :D