## Easy-TensorFlow

The goal of this repository is to provide comprehensive tutorials for TensorFlow while maintaining the simplicity of the code.

Each tutorial includes a **detailed explanation** (written in .ipynb) format, as well as the **source code** (in .py format).

### Table of Contents

### Motivation

There is a necessity to address the motivations for this project. TensorFlow is one of the deep learning frameworks available with the largest community. This repository is dedicated to suggesting a simple path to learn TensorFlow.

#### Why use TensorFlow?

We can summarize the **pros** as below:

- It’s developed and maintained by Google. As such, a continued support and development is ensured
- Very large and active community
- Low-level and high-level interfaces to network training
- Tensorboard is the powerful visualization suite which is developed to track both the network topology and performance, making debugging even simpler.
- Written in Python (even though some parts crucial for performance is implemented in C++) which is a very attractive language to read and develop in
- Multiple GPUs support. So you can freely run the code on different machines without having to stop or restart the program
- Faster model compilation than Theano-based options
- Faster compile times than Theano
- Is about more than deep learning. TensorFlow actually has tools to support reinforcement learning and other algorithms.

In addition to the aforementioned points, the large community of TensorFlow enrich the developers with the answer to almost all the questions one may encounter. Furthermore, since most of the developers are using TensorFlow for code development, having a hands-on on TensorFlow is a necessity these days.

#### Why this repository?

In most of the available projects on the web, one of the below issues exists:

- There is no or very limited explanation of what is happening in the code.
- Different parts are not connected in a meaningful way.
- The code implementation is too vague or complicated.
- The focus is on either advanced or elementary level of Tensorflow implementation.

In this project, we tried to connect parts from easy to advanced with detailed tutorials while keeping the code implementation as simple as possible.

### TensorFlow Installation and Setup the Environment

The aim here is to explain how to install TensorFlow library "step by step" and on different operating systems. TensorFlow is a python library. Similar to many others, we tried installing many side packages and libraries and experienced lots of problems and errors.

In order to install TensorFlow please refer to the following link:

### TensorFlow Tutorials

The tutorials in this repository are partitioned into relevant categories.

# | topic | |
---|---|---|

0 | Installation | Code |

1 | Basics | Code |

2 | Logistic_Regression | Code |

3 | Feed_Forward_Neural_Network | Code |

4 | Tensorboard | Code |

5 | AutoEncoder | Code |

6 | Convolutional_Neural_Network | Code |

### Some Useful Tutorials

### Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. *For typos, please do not create a pull request. Instead, declare them in issues or email the repository owner*.

Please note we have a code of conduct, please follow it in all your interactions with the project.

#### Pull Request Process

Please consider the following criterions in order to help us in a better way:

- The pull request is mainly expected to be a code script suggestion or improvement.
- A pull request related to non-code-script sections is expected to make a significant difference in the documentation. Otherwise, it is expected to be announced in the issues section.
- Ensure any install or build dependencies are removed before the end of the layer when doing a build and creating a pull request.
- Add comments with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
- You may merge the Pull Request in once you have the sign-off of at least one other developer, or if you do not have permission to do that, you may request the owner to merge it for you if you believe all checks are passed.

#### Final Note

We are looking forward to your kind feedback. Please help us to improve this open source project and make our work better. For contribution, please create a pull request and we will investigate it promptly. Once again, we appreciate your kind feedback and elaborate code inspections.

## TensorFlow Examples

This tutorial was designed for easily diving into TensorFlow, through examples. For readability, it includes both notebooks and source codes with explanation, for both TF v1 & v2.

It is suitable for beginners who want to find clear and concise examples about TensorFlow. Besides the traditional 'raw' TensorFlow implementations, you can also find the latest TensorFlow API practices (such as , , , ...).

**Update (05/16/2020):** Moving all default examples to TF2. For TF v1 examples: check here.

### Tutorial index

#### 0 - Prerequisite

#### 1 - Introduction

**Hello World**(notebook). Very simple example to learn how to print "hello world" using TensorFlow 2.0+.**Basic Operations**(notebook). A simple example that cover TensorFlow 2.0+ basic operations.

#### 2 - Basic Models

**Linear Regression**(notebook). Implement a Linear Regression with TensorFlow 2.0+.**Logistic Regression**(notebook). Implement a Logistic Regression with TensorFlow 2.0+.**Word2Vec (Word Embedding)**(notebook). Build a Word Embedding Model (Word2Vec) from Wikipedia data, with TensorFlow 2.0+.**GBDT (Gradient Boosted Decision Trees)**(notebooks). Implement a Gradient Boosted Decision Trees with TensorFlow 2.0+ to predict house value using Boston Housing dataset.

#### 3 - Neural Networks

##### Supervised

**Simple Neural Network**(notebook). Use TensorFlow 2.0 'layers' and 'model' API to build a simple neural network to classify MNIST digits dataset.**Simple Neural Network (low-level)**(notebook). Raw implementation of a simple neural network to classify MNIST digits dataset.**Convolutional Neural Network**(notebook). Use TensorFlow 2.0+ 'layers' and 'model' API to build a convolutional neural network to classify MNIST digits dataset.**Convolutional Neural Network (low-level)**(notebook). Raw implementation of a convolutional neural network to classify MNIST digits dataset.**Recurrent Neural Network (LSTM)**(notebook). Build a recurrent neural network (LSTM) to classify MNIST digits dataset, using TensorFlow 2.0 'layers' and 'model' API.**Bi-directional Recurrent Neural Network (LSTM)**(notebook). Build a bi-directional recurrent neural network (LSTM) to classify MNIST digits dataset, using TensorFlow 2.0+ 'layers' and 'model' API.**Dynamic Recurrent Neural Network (LSTM)**(notebook). Build a recurrent neural network (LSTM) that performs dynamic calculation to classify sequences of variable length, using TensorFlow 2.0+ 'layers' and 'model' API.

##### Unsupervised

**Auto-Encoder**(notebook). Build an auto-encoder to encode an image to a lower dimension and re-construct it.**DCGAN (Deep Convolutional Generative Adversarial Networks)**(notebook). Build a Deep Convolutional Generative Adversarial Network (DCGAN) to generate images from noise.

#### 4 - Utilities

**Save and Restore a model**(notebook). Save and Restore a model with TensorFlow 2.0+.**Build Custom Layers & Modules**(notebook). Learn how to build your own layers / modules and integrate them into TensorFlow 2.0+ Models.**Tensorboard**(notebook). Track and visualize neural network computation graph, metrics, weights and more using TensorFlow 2.0+ tensorboard.

#### 5 - Data Management

**Load and Parse data**(notebook). Build efficient data pipeline with TensorFlow 2.0 (Numpy arrays, Images, CSV files, custom data, ...).**Build and Load TFRecords**(notebook). Convert data into TFRecords format, and load them with TensorFlow 2.0+.**Image Transformation (i.e. Image Augmentation)**(notebook). Apply various image augmentation techniques with TensorFlow 2.0+, to generate distorted images for training.

#### 6 - Hardware

**Multi-GPU Training**(notebook). Train a convolutional neural network with multiple GPUs on CIFAR-10 dataset.

### TensorFlow v1

The tutorial index for TF v1 is available here: TensorFlow v1.15 Examples. Or see below for a list of the examples.

### Dataset

Some examples require MNIST dataset for training and testing. Don't worry, this dataset will automatically be downloaded when running examples. MNIST is a database of handwritten digits, for a quick description of that dataset, you can check this notebook.

Official Website: http://yann.lecun.com/exdb/mnist/.

### Installation

To download all the examples, simply clone this repository:

To run them, you also need the latest version of TensorFlow. To install it:

or (with GPU support):

For more details about TensorFlow installation, you can check TensorFlow Installation Guide

### TensorFlow v1 Examples - Index

The tutorial index for TF v1 is available here: TensorFlow v1.15 Examples.

#### 0 - Prerequisite

#### 1 - Introduction

**Hello World**(notebook) (code). Very simple example to learn how to print "hello world" using TensorFlow.**Basic Operations**(notebook) (code). A simple example that cover TensorFlow basic operations.**TensorFlow Eager API basics**(notebook) (code). Get started with TensorFlow's Eager API.

#### 2 - Basic Models

**Linear Regression**(notebook) (code). Implement a Linear Regression with TensorFlow.**Linear Regression (eager api)**(notebook) (code). Implement a Linear Regression using TensorFlow's Eager API.**Logistic Regression**(notebook) (code). Implement a Logistic Regression with TensorFlow.**Logistic Regression (eager api)**(notebook) (code). Implement a Logistic Regression using TensorFlow's Eager API.**Nearest Neighbor**(notebook) (code). Implement Nearest Neighbor algorithm with TensorFlow.**K-Means**(notebook) (code). Build a K-Means classifier with TensorFlow.**Random Forest**(notebook) (code). Build a Random Forest classifier with TensorFlow.**Gradient Boosted Decision Tree (GBDT)**(notebook) (code). Build a Gradient Boosted Decision Tree (GBDT) with TensorFlow.**Word2Vec (Word Embedding)**(notebook) (code). Build a Word Embedding Model (Word2Vec) from Wikipedia data, with TensorFlow.

#### 3 - Neural Networks

##### Supervised

**Simple Neural Network**(notebook) (code). Build a simple neural network (a.k.a Multi-layer Perceptron) to classify MNIST digits dataset. Raw TensorFlow implementation.**Simple Neural Network (tf.layers/estimator api)**(notebook) (code). Use TensorFlow 'layers' and 'estimator' API to build a simple neural network (a.k.a Multi-layer Perceptron) to classify MNIST digits dataset.**Simple Neural Network (eager api)**(notebook) (code). Use TensorFlow Eager API to build a simple neural network (a.k.a Multi-layer Perceptron) to classify MNIST digits dataset.**Convolutional Neural Network**(notebook) (code). Build a convolutional neural network to classify MNIST digits dataset. Raw TensorFlow implementation.**Convolutional Neural Network (tf.layers/estimator api)**(notebook) (code). Use TensorFlow 'layers' and 'estimator' API to build a convolutional neural network to classify MNIST digits dataset.**Recurrent Neural Network (LSTM)**(notebook) (code). Build a recurrent neural network (LSTM) to classify MNIST digits dataset.**Bi-directional Recurrent Neural Network (LSTM)**(notebook) (code). Build a bi-directional recurrent neural network (LSTM) to classify MNIST digits dataset.**Dynamic Recurrent Neural Network (LSTM)**(notebook) (code). Build a recurrent neural network (LSTM) that performs dynamic calculation to classify sequences of different length.

##### Unsupervised

**Auto-Encoder**(notebook) (code). Build an auto-encoder to encode an image to a lower dimension and re-construct it.**Variational Auto-Encoder**(notebook) (code). Build a variational auto-encoder (VAE), to encode and generate images from noise.**GAN (Generative Adversarial Networks)**(notebook) (code). Build a Generative Adversarial Network (GAN) to generate images from noise.**DCGAN (Deep Convolutional Generative Adversarial Networks)**(notebook) (code). Build a Deep Convolutional Generative Adversarial Network (DCGAN) to generate images from noise.

#### 4 - Utilities

**Save and Restore a model**(notebook) (code). Save and Restore a model with TensorFlow.**Tensorboard - Graph and loss visualization**(notebook) (code). Use Tensorboard to visualize the computation Graph and plot the loss.**Tensorboard - Advanced visualization**(notebook) (code). Going deeper into Tensorboard; visualize the variables, gradients, and more...

#### 5 - Data Management

**Build an image dataset**(notebook) (code). Build your own images dataset with TensorFlow data queues, from image folders or a dataset file.**TensorFlow Dataset API**(notebook) (code). Introducing TensorFlow Dataset API for optimizing the input data pipeline.**Load and Parse data**(notebook). Build efficient data pipeline (Numpy arrays, Images, CSV files, custom data, ...).**Build and Load TFRecords**(notebook). Convert data into TFRecords format, and load them.**Image Transformation (i.e. Image Augmentation)**(notebook). Apply various image augmentation techniques, to generate distorted images for training.

#### 6 - Multi GPU

**Basic Operations on multi-GPU**(notebook) (code). A simple example to introduce multi-GPU in TensorFlow.**Train a Neural Network on multi-GPU**(notebook) (code). A clear and simple TensorFlow implementation to train a convolutional neural network on multiple GPUs.

### More Examples

The following examples are coming from TFLearn, a library that provides a simplified interface for TensorFlow. You can have a look, there are many examples and pre-built operations and layers.

### Tutorials

- TFLearn Quickstart. Learn the basics of TFLearn through a concrete machine learning task. Build and train a deep neural network classifier.

### Examples

## Welcome to the Model Garden for TensorFlow

The TensorFlow Model Garden is a repository with a number of different implementations of state-of-the-art (SOTA) models and modeling solutions for TensorFlow users. We aim to demonstrate the best practices for modeling so that TensorFlow users can take full advantage of TensorFlow for their research and product development.

To improve the transparency and reproducibility of our models, training logs on TensorBoard.dev are also provided for models to the extent possible though not all models are suitable.

Directory | Description |
---|---|

official | • A collection of example implementations for SOTA models using the latest TensorFlow 2's high-level APIs • Officially maintained, supported, and kept up to date with the latest TensorFlow 2 APIs by TensorFlow • Reasonably optimized for fast performance while still being easy to read |

research | • A collection of research model implementations in TensorFlow 1 or 2 by researchers • Maintained and supported by researchers |

community | • A curated list of the GitHub repositories with machine learning models and implementations powered by TensorFlow 2 |

orbit | • A flexible and lightweight library that users can easily use or fork when writing customized training loop code in TensorFlow 2.x. It seamlessly integrates with and supports running on different device types (CPU, GPU, and TPU). |

### Announcements

### Contributions

If you want to contribute, please review the contribution guidelines.

### License

Apache License 2.0

### Citing TensorFlow Model Garden

If you use TensorFlow Model Garden in your research, please cite this repository.

## Example github tensorflow

## Awesome TensorFlow

A curated list of awesome TensorFlow experiments, libraries, and projects. Inspired by awesome-machine-learning.

### What is TensorFlow?

TensorFlow is an open source software library for numerical computation using data flow graphs. In other words, the best way to build deep learning models.

More info here.

### Table of Contents

### Tutorials

### Models/Projects

- Tensorflow-Project-Template - A simple and well-designed template for your tensorflow project.
- Domain Transfer Network - Implementation of Unsupervised Cross-Domain Image Generation
- Show, Attend and Tell - Attention Based Image Caption Generator
- Neural Style Implementation of Neural Style
- SRGAN - Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network
- Pretty Tensor - Pretty Tensor provides a high level builder API
- Neural Style - An implementation of neural style
- AlexNet3D - An implementations of AlexNet3D. Simple AlexNet model but with 3D convolutional layers (conv3d).
- TensorFlow White Paper Notes - Annotated notes and summaries of the TensorFlow white paper, along with SVG figures and links to documentation
- NeuralArt - Implementation of A Neural Algorithm of Artistic Style
- Generative Handwriting Demo using TensorFlow - An attempt to implement the random handwriting generation portion of Alex Graves' paper
- Neural Turing Machine in TensorFlow - implementation of Neural Turing Machine
- GoogleNet Convolutional Neural Network Groups Movie Scenes By Setting - Search, filter, and describe videos based on objects, places, and other things that appear in them
- Neural machine translation between the writings of Shakespeare and modern English using TensorFlow - This performs a monolingual translation, going from modern English to Shakespeare and vice-versa.
- Chatbot - Implementation of "A neural conversational model"
- Seq2seq-Chatbot - Chatbot in 200 lines of code
- DCGAN - Deep Convolutional Generative Adversarial Networks
- GAN-CLS -Generative Adversarial Text to Image Synthesis
- im2im - Unsupervised Image to Image Translation with Generative Adversarial Networks
- Improved CycleGAN - Unpaired Image to Image Translation
- DAGAN - Fast Compressed Sensing MRI Reconstruction
- Colornet - Neural Network to colorize grayscale images - Neural Network to colorize grayscale images
- Neural Caption Generator - Implementation of "Show and Tell"
- Neural Caption Generator with Attention - Implementation of "Show, Attend and Tell"
- Weakly_detector - Implementation of "Learning Deep Features for Discriminative Localization"
- Dynamic Capacity Networks - Implementation of "Dynamic Capacity Networks"
- HMM in TensorFlow - Implementation of viterbi and forward/backward algorithms for HMM
- DeepOSM - Train TensorFlow neural nets with OpenStreetMap features and satellite imagery.
- DQN-tensorflow - TensorFlow implementation of DeepMind's 'Human-Level Control through Deep Reinforcement Learning' with OpenAI Gym by Devsisters.com
- Policy Gradient - For Playing Atari Ping Pong
- Deep Q-Network - For Playing Frozen Lake Game
- AC - Actor Critic for Playing Discrete Action space Game (Cartpole)
- A3C - Asynchronous Advantage Actor Critic (A3C) for Continuous Action Space (Bipedal Walker)
- DAGGER - For Playing Gym Torcs
- TRPO - For Continuous and Discrete Action Space by
- Highway Network - TensorFlow implementation of "Training Very Deep Networks" with a blog post
- Hierarchical Attention Networks - TensorFlow implementation of "Hierarchical Attention Networks for Document Classification"
- Sentence Classification with CNN - TensorFlow implementation of "Convolutional Neural Networks for Sentence Classification" with a blog post
- End-To-End Memory Networks - Implementation of End-To-End Memory Networks
- Character-Aware Neural Language Models - TensorFlow implementation of Character-Aware Neural Language Models
- YOLO TensorFlow ++ - TensorFlow implementation of 'YOLO: Real-Time Object Detection', with training and an actual support for real-time running on mobile devices.
- Wavenet - This is a TensorFlow implementation of the WaveNet generative neural network architecture for audio generation.
- Mnemonic Descent Method - Tensorflow implementation of "Mnemonic Descent Method: A recurrent process applied for end-to-end face alignment"
- CNN visualization using Tensorflow - Tensorflow implementation of "Visualizing and Understanding Convolutional Networks"
- VGAN Tensorflow - Tensorflow implementation for MIT "Generating Videos with Scene Dynamics" by Vondrick et al.
- 3D Convolutional Neural Networks in TensorFlow - Implementation of "3D Convolutional Neural Networks for Speaker Verification application" in TensorFlow by Torfi et al.
- U-Net - For Brain Tumor Segmentation
- Spatial Transformer Networks - Learn the Transformation Function
- Lip Reading - Cross Audio-Visual Recognition using 3D Architectures in TensorFlow - TensorFlow Implementation of "Cross Audio-Visual Recognition in the Wild Using Deep Learning" by Torfi et al.
- Attentive Object Tracking - Implementation of "Hierarchical Attentive Recurrent Tracking"
- Holographic Embeddings for Graph Completion and Link Prediction - Implementation of Holographic Embeddings of Knowledge Graphs
- Unsupervised Object Counting - Implementation of "Attend, Infer, Repeat"
- Tensorflow FastText - A simple embedding based text classifier inspired by Facebook's fastText.
- MusicGenreClassification - Classify music genre from a 10 second sound stream using a Neural Network.
- Kubeflow - Framework for easily using Tensorflow with Kubernetes.
- TensorNets - 40+ Popular Computer Vision Models With Pre-trained Weights.
- Ladder Network - Implementation of Ladder Network for Semi-Supervised Learning in Keras and Tensorflow
- TF-Unet - General purpose U-Network implemented in Keras for image segmentation
- Sarus TF2 Models - A long list of recent generative models implemented in clean, easy to reuse, Tensorflow 2 code (Plain Autoencoder, VAE, VQ-VAE, PixelCNN, Gated PixelCNN, PixelCNN++, PixelSNAIL, Conditional Neural Processes).
- Model Maker - A transfer learning library that simplifies the process of training, evaluation and deployment for TensorFlow Lite models (support: Image Classification, Object Detection, Text Classification, BERT Question Answer, Audio Classification, Recommendation etc.; API reference).

### Powered by TensorFlow

- YOLO TensorFlow - Implementation of 'YOLO : Real-Time Object Detection'
- android-yolo - Real-time object detection on Android using the YOLO network, powered by TensorFlow.
- Magenta - Research project to advance the state of the art in machine intelligence for music and art generation

### Libraries

- TensorFlow Estimators - high-level TensorFlow API that greatly simplifies machine learning programming (originally tensorflow/skflow)
- R Interface to TensorFlow - R interface to TensorFlow APIs, including Estimators, Keras, Datasets, etc.
- Lattice - Implementation of Monotonic Calibrated Interpolated Look-Up Tables in TensorFlow
- tensorflow.rb - TensorFlow native interface for ruby using SWIG
- tflearn - Deep learning library featuring a higher-level API
- TensorLayer - Deep learning and reinforcement learning library for researchers and engineers
- TensorFlow-Slim - High-level library for defining models
- TensorFrames - TensorFlow binding for Apache Spark
- TensorForce - TensorForce: A TensorFlow library for applied reinforcement learning
- TensorFlowOnSpark - initiative from Yahoo! to enable distributed TensorFlow with Apache Spark.
- caffe-tensorflow - Convert Caffe models to TensorFlow format
- keras - Minimal, modular deep learning library for TensorFlow and Theano
- SyntaxNet: Neural Models of Syntax - A TensorFlow implementation of the models described in Globally Normalized Transition-Based Neural Networks, Andor et al. (2016)
- keras-js - Run Keras models (tensorflow backend) in the browser, with GPU support
- NNFlow - Simple framework allowing to read-in ROOT NTuples by converting them to a Numpy array and then use them in Google Tensorflow.
- Sonnet - Sonnet is DeepMind's library built on top of TensorFlow for building complex neural networks.
- tensorpack - Neural Network Toolbox on TensorFlow focusing on training speed and on large datasets.
- tf-encrypted - Layer on top of TensorFlow for doing machine learning on encrypted data
- pytorch2keras - Convert PyTorch models to Keras (with TensorFlow backend) format
- gluon2keras - Convert Gluon models to Keras (with TensorFlow backend) format
- TensorIO - Lightweight, cross-platform library for deploying TensorFlow Lite models to mobile devices.
- StellarGraph - Machine Learning on Graphs, a Python library for machine learning on graph-structured (network-structured) data.
- DeepBay - High-Level Keras Complement for implement common architectures stacks, served as easy to use plug-n-play modules

### Tools/Utilities

- Guild AI - Task runner and package manager for TensorFlow
- ML Workspace - All-in-one web IDE for machine learning and data science. Combines Tensorflow, Jupyter, VS Code, Tensorboard, and many other tools/libraries into one Docker image.

### Videos

### Papers

### Official announcements

### Blog posts

### Community

### Books

- Machine Learning with TensorFlow by Nishant Shukla, computer vision researcher at UCLA and author of Haskell Data Analysis Cookbook. This book makes the math-heavy topic of ML approachable and practicle to a newcomer.
- First Contact with TensorFlow by Jordi Torres, professor at UPC Barcelona Tech and a research manager and senior advisor at Barcelona Supercomputing Center
- Deep Learning with Python - Develop Deep Learning Models on Theano and TensorFlow Using Keras by Jason Brownlee
- TensorFlow for Machine Intelligence - Complete guide to use TensorFlow from the basics of graph computing, to deep learning models to using it in production environments - Bleeding Edge Press
- Getting Started with TensorFlow - Get up and running with the latest numerical computing library by Google and dive deeper into your data, by Giancarlo Zaccone
- Hands-On Machine Learning with Scikit-Learn and TensorFlow – by Aurélien Geron, former lead of the YouTube video classification team. Covers ML fundamentals, training and deploying deep nets across multiple servers and GPUs using TensorFlow, the latest CNN, RNN and Autoencoder architectures, and Reinforcement Learning (Deep Q).
- Building Machine Learning Projects with Tensorflow – by Rodolfo Bonnin. This book covers various projects in TensorFlow that expose what can be done with TensorFlow in different scenarios. The book provides projects on training models, machine learning, deep learning, and working with various neural networks. Each project is an engaging and insightful exercise that will teach you how to use TensorFlow and show you how layers of data can be explored by working with Tensors.
- Deep Learning using TensorLayer - by Hao Dong et al. This book covers both deep learning and the implmentation by using TensorFlow and TensorLayer.

### Contributions

Your contributions are always welcome!

If you want to contribute to this list (please do), send me a pull request or contact me @jtoy Also, if you notice that any of the above listed repositories should be deprecated, due to any of the following reasons:

- Repository's owner explicitly say that "this library is not maintained".
- Not committed for long time (2~3 years).

More info on the guidelines

### Credits

## TensorFlow Lite Python classification example with Pi Camera

This example uses TensorFlow Lite with Python on a Raspberry Pi to perform real-time image classification using images streamed from the Pi Camera.

Although the TensorFlow model and nearly all the code in here can work with other hardware, the code in uses the API to capture images from the Pi Camera. So you can modify those parts of the code if you want to use a different camera input.

### Set up your hardware

Before you begin, you need to set up your Raspberry Pi with Raspberry Pi OS (preferably updated to Buster).

You also need to connect and configure the Pi Camera.

And to see the results from the camera, you need a monitor connected to the Raspberry Pi. It's okay if you're using SSH to access the Pi shell (you don't need to use a keyboard connected to the Pi)—you only need a monitor attached to the Pi to see the camera stream.

### Install the TensorFlow Lite runtime

In this project, all you need from the TensorFlow Lite API is the class. So instead of installing the large package, we're using the much smaller package.

To install this on your Raspberry Pi, follow the instructions in the Python quickstart. Return here after you perform the command.

### Download the example files

First, clone this Git repo onto your Raspberry Pi like this:

Then use our script to install a couple Python packages, and download the MobileNet model and labels file:

### Run the example

You should see the camera feed appear on the monitor attached to your Raspberry Pi. Put some objects in front of the camera, like a coffee mug or keyboard, and you'll see the predictions printed. It also prints the amount of time it took to perform each inference in milliseconds.

For more information about executing inferences with TensorFlow Lite, read TensorFlow Lite inference.

### Speed up the inferencing time (optional)

If you want to significantly speed up the inference time, you can attach an ML accelerator such as the Coral USB Accelerator—a USB accessory that adds the Edge TPU ML accelerator to any Linux-based system.

If you have a Coral USB Accelerator, follow these additional steps to delegate model execution to the Edge TPU processor:

First, be sure you have completed the USB Accelerator setup instructions.

Now open the file and add the following import at the top:

And then find the line that initializes the , which looks like this:

And change it to specify the Edge TPU delegate:

The file is provided by the Edge TPU library you installed during the USB Accelerator setup in step 1.

Finally, you need a version of the model that's compiled for the Edge TPU.

Normally, you need to use use the Edge TPU Compiler to compile your file. But the compiler tool isn't compatible with Raspberry Pi, so we included a pre-compiled version of the model in the script above.

So you already have the compiled model you need: .

Now you're ready to execute the TensorFlow Lite model on the Edge TPU. Just run again, but be sure you specify the model that's compiled for the Edge TPU (it uses the same labels file as before):

You should see significantly faster inference speeds.

For more information about creating and running TensorFlow Lite models with Coral devices, read TensorFlow models on the Edge TPU.

### Now discussing:

- Funny card for boyfriend
- Wendy williams shop
- X box remote control
- Alphabet scroll wall hanging
- Turmeric ink
- Netgear ac1200 xfinity
- Ndi cloud
- Siddharth gollapudi
- Plano tool organizer
- Fs19 logging tips
- F150 lockers

.

**368**369 370