To get started, move your mouse cursor over the [ ]
box to the left of the first code snippet, underneath the Downloading Model Data header. It will change to a "Play" icon. Click on this icon.
What should happen?
After typically 20 seconds or so, you'll see the notebook come to life. The previous output will vanish and you'll see it replaced with the result of running on your new runtime (see the section titledAside below for more about what a runtime is).
When you see Setup Successful!
, you know you've finished this step. You can open another copy of the notebook and compare it to our previous run, just to make sure it looks correct.
Aside: Behind the Scenes
Each time you open a Colab notebook, Google lets you temporarily use a computer in their datacenter to run your code. This computer is running a program called the runtime, which lets you play around with TensorFlow without having to worry about how fast your computer and without needing to buy an expensive graphics card.
When you close your Colab notebook, Google replaces your runtime with a brand new one, and releases your machine to someone else. This means that each time you come back, you'll need to set up the machine from scratch.
The first cell in the notebook does just this. It downloads the TensorFlow Model that will be used to recognize objects.
WARNING:tensorflow: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see: * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md * https://github.com/tensorflow/addons * https://github.com/tensorflow/io (for I/O related ops) If you depend on functionality not listed there, please file an issue. WARNING:tensorflow:From /content/models/research/slim/nets/mobilenet/mobilenet.py:397: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead. WARNING:tensorflow:From /content/models/research/slim/nets/mobilenet/mobilenet.py:364: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
Be sure to click Allow.
Finally, scroll down and you should see video from your camera appear on screen. Above the video, you'll see the output from the Object Detector.
Tips and Tricks
Play around with the detector to see how it performs best. Here are some hints from my experiments so far:
- Make sure the object takes up most of the frame. This demo reports only the most confident object it sees, even if it sees two or three others.
- Try with a uniform background for best results.
- The prediction text turns green when the model is more than 70% confident in what it sees. Sometimes, the model is much more confident--as high as 95%. Other times, it's less than 20% confident--it's probably not seeing what it says it is. You can change the 70% threshold to fit your proejct. Try adjusting the threshold and see what works for you (hint: look for "0.7" near the end of the code).
Page last edited March 08, 2024
Text editor powered by tinymce.