DeepLearnPhysics / larcv2

MIT License
13 stars 16 forks source link

Added Batch Filler for BBox2D objects #22

Closed twongjirad closed 6 years ago

twongjirad commented 6 years ago

Batch Filler for BBox2D objects.

I do not have push permission on larcv2 repo, but thought I'd share his if useful. If not, no pressure to merge.

One issue is that batch tensor size is not dynamic. So had to implement MaxNumBoxes parameter which has to be set high enough to not contain clip number of BBox2D objects per image.

Also, made the choice to only return BBox2D per View (per projectionid). User has to create multiple filler instances to get bboxes for each view.

Tested using larcvdataset module. Test script in develop branch of repo.

twongjirad commented 6 years ago

Does this match the vision for 2D BBox loading?

If no objections, I will merge.

drinkingkazu commented 6 years ago

Thanks @twongjirad and sorry for very late response! Setting the buffer size (max number of data elements) is how I did for PPN and I think it "works". If we come up with a better idea we can revisit altogether.

BTW how one would know which BBox2D is valid/invalid? Does the array start with valid BBox2D and eventually find some "invalid" ones?

twongjirad commented 6 years ago

That is a good point. Right now the invalid boxes just have the sentinal value, (0,0,0,0), which is not very reliable. Returning a (B,NMAXBB,1,1) matrix which designates valid boxes is probably a good idea.

coreyjadams commented 6 years ago

What do you think of generalizing this approach for region proposal with batch filler? It seems like the right way to do it, having a list of valid boxes by batch entry in addition to NMAXBB. But when extending to 3D, or non-rectangular region proposals, a lot of this infrastructure will be duplicated. A uniform philosophy might be nice across larcv2 batch filler.

coreyjadams commented 6 years ago

I suppose I should be more specific: I was proposing a template (english term, not C++ term) for region/object detection batch fillers, that gets inherited and specified for each particular use (BBox2D, BBox3D, PointPrediction, and other options)

drinkingkazu commented 6 years ago

Related to your question/suggestion, BatchFillerPPN can handle either 2D or 3D ATM, specified by a configuration parameter (right now it takes "xy", "yz", "zx", or "3d"). A similar approach can be taken for BBox. We can separate an "algorithm to fill BBox coordinates" from BatchFiller as well. That way, one can re-use the code to create batch data while the definition of BBox can be algorithm dependent (some people might want BBox per particle, some people might want BBox per interaction, etc.)