Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tux-o-matic/banana
Keras/TensorFlow demo
https://github.com/tux-o-matic/banana
keras object-detection opencv tensorflow
Last synced: about 1 month ago
JSON representation
Keras/TensorFlow demo
- Host: GitHub
- URL: https://github.com/tux-o-matic/banana
- Owner: tux-o-matic
- License: gpl-3.0
- Created: 2018-07-05T20:55:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-08T07:17:03.000Z (6 months ago)
- Last Synced: 2024-11-06T07:29:29.924Z (3 months ago)
- Topics: keras, object-detection, opencv, tensorflow
- Language: Python
- Homepage:
- Size: 2.25 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setup
For training this CNN with over 200 steps and more than 10 epochs, a GPU is a must. CPU based training will take several hours but for portability reasons, the `requirements.txt` file installs `tensorflow-cpu` by default on systems other than macOS.All tests were done with Metal on Apple Silicon and CUDA 9.0 on Linux x86_64.
## Metal
pip will auto detect macOS and install the improved TensorFlow implementations from Apple to use Metal on Apple Silicon and x86_64 Mac with discrete AMD GPU. Integrated Intel GPU support Metal shaders but those TF backend didn't boost TF performance (Apple therefor gave up supporting Intel iGPU for the Metal backend) so those Mac should fallback to `tensorflow-cpu` or try the Intel distribution with further SSE/AVX optimization `intel-tensorflow`.### vecLib
NumPy performance on Apple Silicon can be further improved by using [Apple's vecLib](https://developer.apple.com/documentation/accelerate/veclib) instead of the default OpenBLAS otherwise used by the arm64 NumPy wheel. A `site.cfg` file is present in the repository to pass hints when building NumPy.
Within your virtualenv:
```shell
pip install Cython
pip install -U --no-binary :all: --no-use-pep517 numpy
```To verify, within an interactive Python interpreter in your virtualenv:
```shell
>>> import numpy
>>> numpy.show_config()
```
You should see the vecLib headers listed.Based on [this post](https://developer.apple.com/forums/thread/695963).
## Nvidia drivers
You'll need the closed source Nvidia drivers, one supporting the correct CUDA version.
Blacklist the Nouveau open source driver it's loaded at boot.
### CUDA
Some environments, such as Python 3 from SCL require to export the CUDA path:
```shell
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/
```
### CUDAnn
Requires a developer account on Nvidia's website to download. Extract the content of the tarball.
```shell
sudo cp cuda/include/cudnn.h /usr/include
sudo cp cuda/lib64/* /usr/lib64/
```
### TensorFlow
Rename the entry requirements.txt from
```ini
tensorflow-cpu=XXX
```
to
```ini
tensorflow==XXX
```## Results
So far training gave an accuracy of 78%.
The more RAM and bandwith your GPU has, the larger batch it can handle. So the `batch_size` value should be tuned accordingly.## Known Issues
Apple's Metal backend for Tensorflow has been broken for a few release after TensorFlow 2.9 and `tensorflow-metal` 0.5. So even though it might lack some MPS optimizations, those older versions can actually run.Apple's Metal optimized TensorFlow can have "likely leaking IOGPUResource" [errors](https://developer.apple.com/forums/thread/706920?login=true&page=1#741165022) after running for a few epochs.
If your CPU doesn't support the AVX1 instruction set (Intel chip shipped before 2012), you'll need to use an older version of TensorFlow such as 1.5.0 (see keras-tf1 branch).