get bounding box coordinated from object detection api after eval - tensorflow

I used Object Detection API from Tensorflow to train my model. The eval script also worked fine.
However, I want to get the coordinates of the bounding box in eval images. Is that possible to do so in eval script? How can I do it?
I used this script.

A few examples (how many is set by num_visualizations in the config file) are shown on TensorBoard.
If you want more than that, I suggest to export the model and use inference.
See the TF OD tutorial notebook for how to use an exported model for inference and visualizing results.

You can refer to the following link.
Although this does not have any relation with the eval.py script, it gets the job done. If you specify a directory consisting of the test images, you can get the bounding box coordinates of all the detected objects using the model you have trained.

Related

Tensorflow2 Object Detection API: PR-Curve

I have trained a model using the Tensorflow 2 Object Detection API on a custom dataset with the model_main_tf2.py script, exported it with export_inference_graph.py and evaluated it with model_main_tf2.py by setting the checkpoint_dir flag.
I would like to see the PR-curve for my exported model. However, I can't seem to find a way to do this. I found an answer here but I don't understand how this would be integrated in the TF Object Detection API.
Edit: I've run tensorboard and it shows me the standard coco-metrics (mAP, mAP#.5IOU, mAP#.75IOU.... etc). However, clicking "PR-curve" in the top right corner makes the board empty, as in seen in the picture below.

Tensorflow Object Detection API model for use in TensorFlow.js

I am trying to use an object detection model, that was created using the TF Object Detection API, in TensorFlow.js.
I converted the model using:
tensorflowjs_converter --input_format=tf_saved_model inference_graph/saved_model inference_graph/web_model
It gets converted without any problems and loads in my javascript code.
Now I am a bit unsure about what my next steps should be.
I have to translate the Python into JavaScript, but certain areas I am unsure about.
With the object detection API in python, there are many steps; (1)preprocessing the image, such as convert to RGB, numpy array reshape, expand dimensions (I have an idea of how I would approach it) and (2) the run inference for single image function, I am not sure how I would go about it in tensorflow.js.
I tried to find some general information about deploying an object detection model in tensorflow.js, but I could not find much, except with pre-trained models.
Any information about this topic would be great!
Thanks!
as mentioned by #edkeveked you will need to perform similar input processing and output processing in JavaScript as is being done in Python. i can't say exactly what you will need to do since i am not familiar with the model. however, you can find an example using a specific object detection model here:
https://github.com/vabarbosa/tfjs-model-playground/blob/master/object-detector/demo/object-detector.js
see also
https://medium.com/codait/bring-machine-learning-to-the-browser-with-tensorflow-js-part-iii-62d2b09b10a3
You would need to replicate the same process in javascript before giving it to the model. In js, the image use by default the RGB channel, so there is no need to make that conversion again.

I want to use a graph with Tensorboard that was created using the GraphDef and associated routines

I want to use Tensorboard with a non tensorflow app. I can see how to make the graph using GraphDef and associated classes but not sure how to write it out so that Tensorboard will read it. This means that I have the graph in a serialized form and it's not the python graph class from tensorflow.
For seeing graph in tensorboard, you need weight, tensor name and structure of the graph.
I dont understand your question totally, but if you are able to create graph.pb file then , it will be simple to see that thing in tensorboard you have to run this file here.
actually here we are creating dummy graph structure using
graph_def = graph_pb2.GraphDef()
and then giving our .pb file to set all these weight and name
graph_def.ParseFromString('pb file directory to read'.read())
import_graph_def(graph_def)
let me know more detail so that i can help you better way.

How do I get detected boxes on evaluation set for tensorflow's object detection API?

I was working with the recently released Tensorflow's API for object detection, with Faster RCNN on Resnet 101 on my own dataset. It seems to train and evaluate on Validation data, but I was hoping if there was a way I could get/store bounding boxes for all images in the Eval set, in a file, or maybe, get the location in the source code where I can get the predicted bounding boxes with image names.
If you just want to obtain the detected bounding boxes given a set of images, the Jupyter notebook contains a good example of how to do this.

Object detection using CNTK

I am very new to CNTK.
I wanted to train a set of images (to detect objects like alcohol glasses/bottles) using CNTK - ResNet/Fast-R CNN.
I am trying to follow below documentation from GitHub; However, it does not appear to be a straight forward procedure. https://github.com/Microsoft/CNTK/wiki/Object-Detection-using-Fast-R-CNN
I cannot find proper documentation to generate ROI's for the images with different sizes and shapes. And how to create object labels based on the trained models? Can someone point out to a proper documentation or training link using which I can work on the cntk model? Please see the attached image in which I was able to load a sample image with default ROI's in the script. How do I properly set the size and label the object in the image ? Thanks in advance!
sample image loaded for training
Not sure what you mean by proper documentation. This is an implementation of the paper (https://arxiv.org/pdf/1504.08083.pdf). Looks like you are trying to generate ROI's. Can you look through the helper functions as documented at the site to parse what you might need:
To run the toy example, make sure that in PARAMETERS.py the datasetName is set to "grocery".
Run A1_GenerateInputROIs.py to generate the input ROIs for training and testing.
Run A2_RunCntk_py3.py to train a Fast R-CNN model using the CNTK Python API and compute test results.
The algo will work on several candidate regions and then generate outputs: one for the classes of objects and another one that generates the bounding boxes for the objects belonging to those classes. Please refer to the code for getting the details of the implementation.
Can someone point out to a proper documentation or training link using which I can work on the cntk model?
You can take a look at my repository on GitHub.
It will guide you through all the steps required to train your own model for object detection and classification with CNTK.
But in short the proper steps should look something like this:
Setup environment
Prepare data
Tag images (ground truth)
Download pretrained model and create mappings for your custom dataset
Run training
Evaluate the model on test set