Build a TensorFlow Image Classifier in 5 Min

Siraj Raval · 875K views · 2016 · 5:47

Open on YouTube

Machine learning & deep learningComputer vision, speech & NLPtutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a quick transfer-learning walkthrough when answering image classification questions, and askers cite it as the tutorial they followed when their own setup breaks.

Recommended by 4 people across 4 different months, 2016 to 2018.

What it is

A short screencast by Siraj Raval showing how to retrain Google's Inception model with TensorFlow to build an image classifier, using a Darth Vader detector as the example. It walks through setting up the TensorFlow Docker image, retraining the final layer, and writing a Python script to classify new images.

What people said

Recommends Zhenyu Wu · 2016-07 · Stack Overflow · on “Image recognition using TensorFlow”

I would recommend using Google's trained Inception model to do image recognition. Please refer to the example "How to Retrain Inception's Final Layer for New Categories" on tensorflow website. It is at [LINK] . Using trained model is easy and can achieve reasonable accuracy. You just simply feed the model with your own data set. The last classication layer of Google's inception will be modified and we only train the last layer. For several thousand images with in several categories, it only take several hours to finish training. Please note: in order to use the example, you have to build tensorflow from source. I am using the transfer learning feature and achieving very good results. To illu

Recommends Michael Mintz · 2016-10 · Stack Overflow · on “Tensorflow bulk image classification”

I had the same issue, so I built the TensorPy GitHub repo [LINK] to easily handle image classifications of either individual or multiple images directly from web pages. How it works: For multiple images, first it scrapes all the image links directly from a web page given. Then it downloads those images to a temporary folder and converts those images to JPEG format. Finally, it uses TensorFlow to classify all those images and print out the result, which you can then easily output to a txt file by adding " > output.txt" to the end of your command line run statement. See the video tutorial link in the repo, and swap out the individual image file from the example for a web page. Since you probab

Recommends Arijeet Patidar · 2017-03 · Stack Overflow · on “Detect if image has a watermark?”

You can do it via image classification. Basically, train a CNN(Convolutional neural Network) model by feeding in some images with watermark and some without watermark in it and then use this model to judge the probability of watermark in any new image. You can apply transfer learning on some existing pre-trained models(as of today inception v3 is the best out there) which can be retrained for your specific classification purpose. For example this link shows how to do it to identify whether an image is that of a sunflower or a daisy or a rose. [LINK] Here is a quick 5 minute tutorial about building a tensorflow image classifier: [this video]

Recommends Josh Payne · 2018-07 · Stack Overflow · on “training image datasets for object detection”

You may need to curate your own dataset using frames from a traffic camera and manually tagging images with cars where the passengers' seatbelts are or are not buckled, as this is a very specialized task. From there, you can do data augmentation (perhaps using the Keras ImageDataGenerator class). If a human can identify a seatbelt in an image that is blurred or noisy, a model can learn from it. From there, you can use transfer learning from a pre-trained CNN model like Inception ( this [this video] is a helpful tutorial for how to do that), or train your own binary classifier with your tagged images, where your inputs are frames of traffic camera video. I'd suggest that after learning the basics

Cites Neil Deshmukh · 2016-10 · Stack Overflow · on “How to change model in Tensorflow camera example?”

In the tensorflow camera example, tensorflow has provided a graph file called tensorflow_inception_graph.pb but I tried to replace it with my own .pb graph file that I trained using tensorflow using this tutorial: [this video] I also replaced the txt file, but there was still a problem. When I copied it in, no text/numbers showed up when I ran it, but it ran perfectly ok. Do you guys know how I can fix it?

Cites Vincent · 2016-11 · Stack Overflow · on “Properly automate a docker script in Python”

Based on this tutorial [this video] to build a TF image classifier, I have a bash shell in which I run a Docker image with the following command: docker run --name fooldocker -it -v $HOME/tf_files:/tf_files/ gcr.io/tensorflow/tensorflow:latest-devel And then in this docker image I run my Python script: python /tf_files/label_image.py /tf_files/myimages exit It works. But now, I need to automate these commands in a Python script . I tried : p = Popen(['docker', 'run', '--rm', '--name', 'fooldocker','-it', '-v', '$HOME/tf_files:/tf_files/', 'gcr.io/tensorflow/tensorflow:latest-devel'], stdout=PIPE) p = Popen(['docker', 'exec', 'fooldocker', 'python', '/tf_files/label_NES.py', '/tf_files/NES/WIP'])

Cites Hernan Razo · 2017-11 · Stack Overflow · on “Where to write python script for image classifiers”

I am trying to learn how to retrain an image classifier using transfer learning. I am following the steps shown in this tutorial. [this video] I successfully retrained the model but I come across problems in the last step where he writes python script for classifying the newly trained model. In the video, he starts writing the code at 4:18 but does not specify where. I try writing it in the docker container but it gives me the no module named platform error and the NameError: name 'sys' is not defined error. I try writing it locally in my machine and get errors as well since I do not have the dependencies installed locally. I am not sure where to write the python code for the final step in the tu

Cites cdahms · 2018-02 · Stack Overflow · on “How to convert NumPy array image to TensorFlow image?”

After using TensorFlow's retrain.py [LINK] I've successfully generated the "retrained_labels.txt" and "retrained_graph.pb" files. For anybody not familiar with this process, I'm essentially following this tutorial: [LINK] which is effectively the same steps as this popular video: [this video] After the retraining process, I'm attempting to write a Python script that opens all the images in a test images directory, and successively shows each image in an OpenCV window and also runs TensorFlow to classify the image. Problem is, I can't seem to work out how to open the image as a NumPy array (this is the format that the Python OpenCV wrapper uses) and then convert it into a format I can pass into Te

Cites xucharles97 · 2018-08 · Stack Overflow · on “Need Help Installing TensorFlow Docker Image”

I'm trying to create a Tensorflow Image Classifier using this video [this video] and I am stuck on the second step of the tutorial. I tried running the command docker run -it gcr.io/tensorflow/tensorflow:latest-devel but when I do it, my terminal returns with the following error message: Unable to find image 'gcr.io/tensorflow/tensorflow:latest-devel' locally docker: Error response from daemon: manifest for gcr.io/tensorflow/tensorflow:latest-devel not found. See 'docker run --help'. Does anyone know how I can resolve this issue?

Cites Divik Shrivastava · 2018-10 · Stack Overflow · on “DecodeJpeg / Content: 0 'refers to a tensor that does not exist”

After retraining my model on tensorflow by following method in the tutorial video by Siraj Raval [this video] I encountered the below error when i finally tested my test image but it generated two errors as seen in screenshot [LINK] There are two errors ,a Type and a Key error and both of their root cause is probably DecodeJpeg/Contents: 0 If anyone can explain me the errors and give its resolution then it will be really helpful.