Thisrepositorycontainsanimplementationof[Yahoo'sOpenNSFWClassifier](https://github.com/yahoo/open_nsfw) rewritten in tensorflow.
Theoriginalcaffeweightshavebeenextractedusing[CaffetoTensorFlow](https://github.com/ethereon/caffe-tensorflow). You can find them at `data/open_nsfw-weights.npy`.
*`tensorflow`isanimageloaderwhichusestensorflowexclusively(nodependencieson`PIL`,`skimage`,etc.).Triestoreplicatetheimageloadingmechanismusedbytheoriginalcaffeimplementation,differsabitthoughduetodifferentjpegandresizingimplementations.See[thisissue](https://github.com/mdietrichstein/tensorflow-open_nsfw/issues/2#issuecomment-346125345) for details.
TakesaninputimageandgeneratesajsonfilesuitableforpredictionrequeststoaOpenNSFWModeldeployedwith[GoogleCloudMLEngine](https://cloud.google.com/ml-engine/docs/concepts/prediction-overview) (`gcloud ml-engine predict`) or [tensorflow-serving](https://www.tensorflow.org/serving/).
__export_savedmodel.py__
Exportsthemodelusingthetensorflowservingexportapi(`SavedModel`).Theexportcanbeusedtodeploythemodelon[GoogleCloudMLEngine](https://cloud.google.com/ml-engine/docs/concepts/prediction-overview), [Tensorflow Serving]() or on mobile (haven't tried that one yet).
__export_tflite.py__
Exportsthemodelin[TFLiteformat](https://www.tensorflow.org/lite/). Use this one if you want to run inference on mobile or IoT devices. Please not that the `base64_jpeg` input type does not work with TFLite since the standard runtime is missing a number of required tensorflow operations.