What is the difference between TensorFlow's contrib.slim.nets and models/slim/nets? - tensorflow

In Github repository, we have tensorflow/models having slim and we also have slim in tensorflow.contrib.slim
They both have similar names, functionality and structure. They provide similar nets. For example, inception_v1
any reference for this brain split?
why they did not just git sub
module? any discussion link?
which is the most usable/stable/maintained?
which is the real net used to train pre-trained data? this one or this one
which one of those two is the real slim shady?

https://github.com/tensorflow/models/blob/master/research/slim/slim_walkthrough.ipynb under the section titled Installation and setup :
Since the stable release of TF 1.0, the latest version of slim has been available as tf.contrib.slim, although, to use TF-Slim for image classification (as we do in this notebook), you also have to install the TF-Slim image models library from here.

Related

How to use a custom model with Tensorflow Hub?

My goal is to test out Google's BERT algorithm in Google Colab.
I'd like to use a pre-trained custom model for Finnish (https://github.com/TurkuNLP/FinBERT). The model can not be found on TFHub library. I have not found a way to load model with Tensorflow Hub.
Is there a neat way to load and use a custom model with Tensorflow Hub?
Fundamentally: yes. Everyone can create the kind of models that TF Hub hosts, and I hope authors of interesting models do consider that.
For TF1 and the hub.Module format tailored to it, see
https://www.tensorflow.org/hub/tf1_hub_module#creating_a_new_module
For TF2 and its revised SavedModel format, see
https://www.tensorflow.org/hub/tf2_saved_model#creating_savedmodels_for_tf_hub
That said, a sophisticated model like BERT requires a bit of attention to export it with all bells and whistles, so it helps to have some tooling to build on. The BERT reference implementation for TF2 at https://github.com/tensorflow/models/tree/master/official/nlp/bert comes with an open-sourced export_tfhub.py script, and anyone can use that to export custom BERT instances created from that code base.
However, I understand from https://github.com/TurkuNLP/FinBERT/blob/master/nlpl_tutorial/training_bert.md#general-info that you are using Nvidia's fork of the original TF1 implementation of BERT. There are Hub modules created from the original research code, but the tooling to that end has not been open-sourced, and Nvidia doesn't seem to have added their own either.
If that's not changing, you'll probably have to resort to doing things the pedestrian way and get acquainted with their codebase and load their checkpoints into it.

Is there a worked example for neural network pruning for the Faster-RCNN architecture from TensorFlow's object detection api?

I am trying to find a worked example of neural network pruning for the Faster-RCNN architecture.
My core stack is Tensorflow 1.12, its object_detection API (link) on Python3.5.2 in Ubuntu 16.04 LTS. I came across some Neural Network Pruning repos (e.g. link, implementing NVIDIA's pruning paper with Taylor expansion link - looking the most promising however (a) implemented in Pytorch and (b) on classification networks rather than detectors).
I am also aware of the existence of a pruning functionality within TensorFlow under this package (link), but could only run an example found in the comments of the following StackOverflow question (link) to train and prune (not thoroughly tested) a simple Neural Network for hand written digits classification using MNIST dataset.
I am looking for a worked example and not reporting any bugs or issues in code.
Can someone point to me a worked example of pruning Faster-RCNN -or other detectors- found on the TensorFlow's object detection API (link), preferably using TensorFlow's pruning package (link)?
Pruning is orthogonal to the meta-architecture used for object detection. When we talk about the TensorFlow Object Detection API, it heavily relies on builders that read the config and create corresponding nets, classes etc. I believe you want to prune the feature extractor as the most heavy part. If so, you need to first prune some feature extractor from slim (let's say, Inception-V2), give it a name, add its pruned version to models, adjust proto config and many more. Shortly speaking, you need to introduce a new type of feature extractor. But I am not aware of any existing examples on that.

Where to find tensorflow pretrained models (list or download link)

I am starting to work with Intel movidius neural compute stick.
To start working, in my case, it is necessary to download pretrained models.
In the tutorials they refer to http://download.tensorflow.org/models/.
However, there is not a list that shows all the models available for download.
If the latest version of a net, lets say inception_v4, is not known, I cannot download the corresponding .tar.gz file.
Does anyone know a method to have an updated list of the .tar.gz files of the pretrained models available for download?
Thanks
The following two links may help
detection_model_zoo
TensorFlow-Slim image classification model library
keras.applications makes it easy to load models and their pretrained weights if you can use Keras
Considering that most of the posted linked outdated, I suggest looking into the TensorFlow hub (https://www.tensorflow.org/hub) for more recent pre-trained models.

how to serve pytorch or sklearn models using tensorflow serving

I have found tutorials and posts which only says to serve tensorflow models using tensor serving.
In model.conf file, there is a parameter model_platform in which tensorflow or any other platform can be mentioned. But how, do we export other platform models in tensorflow way so that it can be loaded by tensorflow serving.
I'm not sure if you can. The tensorflow platform is designed to be flexible, but if you really want to use it, you'd probably need to implement a C++ library to load your saved model (in protobuf) and give a serveable to tensorflow serving platform. Here's a similar question.
I haven't seen such an implementation, and the efforts I've seen usually go towards two other directions:
Pure python code serving a model over HTTP or GRPC for instance. Such as what's being developed in Pipeline.AI
Dump the model in PMML format, and serve it with a java code.
Not answering the question, but since no better answers exist yet: As an addition to the alternative directions by adrin, these might be helpful:
Clipper (Apache License 2.0) is able to serve PyTorch and scikit-learn models, among others
Further reading:
https://www.andrey-melentyev.com/model-interoperability.html
https://medium.com/#vikati/the-rise-of-the-model-servers-9395522b6c58
Now you can serve your scikit-learn model with Tensorflow Extended (TFX):
https://www.tensorflow.org/tfx/guide/non_tf

Looking for resnet implementation in tensorflow

Are there any resnet implementations in tensorflow? I came across a few (e.g. https://github.com/ry/tensorflow-resnet, https://github.com/xuyuwei/resnet-tf) but these implementations have some bugs (e.g. see the Issues section on the respective github page). I am looking to train imagenet using resnet and looking for tensorflow implementations.
There are some (50/101/152) in tensorflow:models/slim.
The example notebook shows how to get a pre-trained inception running, res-net is probably no different.
I implemented a cifar10 version of ResNet with tensorflow. The validation errors of ResNet-32, ResNet-56 and ResNet-110 are 6.7%, 6.5% and 6.2% respectively. (You can modify the number of layers easily as hyper-parameters.)
I tried to be friendly with new ResNet fan and wrote everything straightforward. You can run the cifar10_train.py file directly without any downloads.
https://github.com/wenxinxu/resnet_in_tensorflow
I implemented Resnet by use of ronnie.ai and keras. Both of tool are great.
While ronnie is more easy from scratch.