Random crop and bounding boxes in tensorflow
You can get the shape, but only at runtime - when you call sess.run and actually pass in the data - that's when the shape is actually defined.
So do the random crop manually in tesorflow, basically, you want to reimplement tf.random_crop so you can handle the manipulations to the bounding boxes.
First, to get the shape, x = your_tensor.shape[0] will give you the first dimension. It will appear as None until you actually call sess.run, then it will resolve to the appropriate value. Now you can compute some random crop parameters using tf.random_uniform or whatever method you like. Lastly you perform the crop with tf.slice.
If you want to choose whether to perform the crop or not you can use tf.cond.
Between those components, you should be able to implement what you want using only tensorflow constructs. Try it out and if you get stuck along the way post the code and error you run into.
I want to add a data augmentation on the WiderFace dataset and I would like to know, how is it possible to random crop an image and only keep the bouding box of faces with the center inside the crop using tensorflow ?
I have already try to implement a solution but I use TFRecords and the TfExampleDecoder and the shape of the input image is set to [None, None, 3] during the process, so no way to get the shape of the image and do it by myself.