How to load keras model onto Raspberry Pi - tensorflow

I cannot find how to use keras model that I've trained on my PC to load onto my Raspberry Pi 3.
How can I move it from the PC to the Raspberry Pi?

Tensorflow support Raspberry Pi officially since v1.9.
Just:
sudo apt install libatlas-base-dev
pip3 install tensorflow
Then you may upload your python code along with .h5 model to the device to run.

Related

Tensorflow Loss function is NAN when using GPU

I am trying to train custom object detection model using pre-trained model from Tensorflow1 Model ZOO.
I am using model ssd_mobilenet_v2_coco_2018_03_29
I created suitable environment for training following this tutorial :https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/tensorflow-1.14/training.html
The thing is, when I tried to train the model using tensorflow-gpu==1.14.0 I always got the error saying Model diverged with loss = NaN.
Then I tried to uninstall tensorflow-gpu==1.14.0 and install tensorflow==1.14.0 (so it did not use my GPU) and all of sudden it started to work !
I have no idea how is that possible...
Command I am using -
python model_main.py --alsologtostderr --model_dir=models\ssd_mobilenet_v2_coco_2018_03_29\export --pipeline_config_path=models\ssd_mobilenet_v2_coco_2018_03_29\pipeline.config --num_train_steps=2000
Python version is 3.7
OS is Windows 10
My Graphics Card is Nvidia GeForce RTX3050, I used CUDA v10.0 and cuDNN v7.4.1
Any ideas ?
This is because RTX30's don't support cuda 10. If you need tf v1 (1.15) you can install nvidia's tensorflow (1.15) that can run on cuda 11.
pip install nvidia-pyindex
pip install nvidia-tensorflow[horovod]
Note: Only supports Python 3.6 or 3.8 [Not 3.7]
https://developer.nvidia.com/blog/accelerating-tensorflow-on-a100-gpus/

can i install both tensorflow and tensorflow lite?

Can I install both Tensor-Flow and Tensor-Flow lite ? I using Raspberry Pi 4, Python3, cp37, version is armv7l. Tensor-Flow version = 2.1
I have a folder for Tensor-Flow but when I run the program, the speed is very slow, detection sometime incorrect. My Raspberry Pi do not have any GPU, Is it possible to install TensorFlow Lite? Will it corrupted of the software?

Using Object Detection API on local GPU but not last version (v2.5.0)

I am trying to use my local GPU to train an EfficientDetD0 model. I already have a good pipeline (that works on Google Colab for example), I modified it a bit to use it locally, but one problem happens every time I launch the training.
I use conda to install tensorflow-gpu with cuda and cudnn but it makes TensorFlow v2.4.1 environments and when I launch the training the Object Detection API automatically install TensorFlow V2.5.0. So my env is not using the gpu for the training because cuda and cudnn are waiting for TensorFlow to be v2.4.1 and not v2.5.0.
Is there a way to get the Object Detection API in v2.4.1 and not v2.5.0 ?
I tried many things but it doesn't work (training is failing or going for CPU training).
Here is the code that install dependencies and overwrite TensorFlow version to TensorFlow v2.5.0:
os.system("cp object_detection/packages/tf2/setup.py .")
os.system("python -m pip install .")
SYSTEM:
gpu : Nvidia RTX 3070
os : Ubuntu 20.04 LTS
tensorflow: 2.4.1
P.S.: I go with conda install -c conda-forge tensorflow-gpu for installing TensorFlow, cuda and cudnn in my training env because manually there was a dependency problem, so I took the easy way.
EDIT : solution found explained in comments.
Follow these steps to install specific version of tensorflow gpu
1. Set Up Anaconda Environments
conda create -n tf_gpu cudatoolkit=11.0
2. Activate the new Environment
source activate tf_gpu
3. Install tensorflow-gpu 2.4.1
pip install tensorflow==2.4.1
Try to run object_detection without "installing" it. Dont run setup.py. Just setup the neccesery paths and packages manually.
Or edit the setup.py to skip installing the specific verison of TF. I quess that this version is a requirement of some of the packages installed in setup.py.
I use the object_detection without running the setup.py or doing any "installation" without any problems.

Package 'ffmpeg' has no installation candidate while installing tensorflow

I`m a german studant. For the school I have to make a physics or chemistry project, I decided to install tensorflow on a raspberry pi to train a object detection modal.
But there is an error I don´t understand.
'Package 'ffmpeg' has no insstallation candidate.'
I tried to install ffmpeg from source but this didn´t help
I use a raspberry pi 4 4gb ram.
With Raspbain 10 (buster)
Try installling libav-tools package, apt-get install libav-tools and avconv command instead of ffmpeg. libav is a fork of ffmpeg
Appropriate sources
Ubuntu source
pi forum

Can I implement deep learning models in my laptop with intel hd graphics

I am currently doing a project on deep learning for my masters degree. I wanted to install keras library, so when I started installing Theano and tensorflow i saw that i have to install CUDA. But my laptop comes with intel hd graphics. So my question is will it work if i install them anyway.
Thanks
Edit:
As of now, you can directly use OpenCL based clDNN (https://github.com/01org/clDNN) instead of using OpenVX, in order to perform Deep Learning inference on Intel Graphics. You will have to do the training on a powerful GPU like Nvidia or AMD and use the pre-trained model and use it in clDNN.
You can start using Intel's Computer Vision SDK (https://software.intel.com/en-us/computer-vision-sdk) in order to write Deep Learning Applications using OpenCV or OpenVX.
OpenVX (https://www.khronos.org/openvx/) programming model allows you to write simple Neural Network pipelines using the following SPEC (https://www.khronos.org/registry/OpenVX/extensions/neural_network/html/)
Alternatively you can use Model Optimizer that converts Caffe/TensorFlow model into OpenVX, and you can accelerate the OpenVX Neural Network graph on Intel Integrated HD Graphics.
Hope it helps.
You can install and use keras without cuda, but you can't get gpu accelerating with intel hd graphics.
If you use Theano as keras' backend, first install Theano:
# for python2
pip install theano
# for python3
pip3 install theano
Then set ~/.theanorc file like this:
[global]
floatX = float32
device = cpu
allow_gc = True
[blas]
ldflags = -lopenblas
If you use TensorFlow as keras' backend, just install the CPU version of TensorFlow.
# for python2.7
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0-cp27-none-linux_x86_64.whl
# for python3.4
pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0-cp34-cp34m-linux_x86_64.whl
# for python3.5
pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0-cp35-cp35m-linux_x86_64.whl
Then install keras:
# for python2
pip install keras
# for python3
pip3 install keras
Their is a PlaidML with that you train deep learning model on Intel and AMD gpu.