All Projects → yuanyuanli85 → Keras Multiple Process Prediction

yuanyuanli85 / Keras Multiple Process Prediction

A Simply Example to show how to use Keras model in multiple processes to do the prediction

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Keras Multiple Process Prediction

Bmw Yolov4 Inference Api Gpu
This is a repository for an nocode object detection inference API using the Yolov3 and Yolov4 Darknet framework.
Stars: ✭ 237 (+121.5%)
Mutual labels:  gpu, deeplearning
Clearml Agent
ClearML Agent - ML-Ops made easy. ML-Ops scheduler & orchestration solution
Stars: ✭ 117 (+9.35%)
Mutual labels:  gpu, deeplearning
Kotlindl
High-level Deep Learning Framework written in Kotlin and inspired by Keras
Stars: ✭ 354 (+230.84%)
Mutual labels:  gpu, deeplearning
Deeplearning4j
Suite of tools for deploying and training deep learning models using the JVM. Highlights include model import for keras, tensorflow, and onnx/pytorch, a modular and tiny c++ library for running math code and a java based math library on top of the core c++ library. Also includes samediff: a pytorch/tensorflow like library for running deep learni…
Stars: ✭ 12,277 (+11373.83%)
Mutual labels:  gpu, deeplearning
Deep Learning In Cloud
List of Deep Learning Cloud Providers
Stars: ✭ 298 (+178.5%)
Mutual labels:  gpu, deeplearning
Curl
CURL: Contrastive Unsupervised Representation Learning for Sample-Efficient Reinforcement Learning
Stars: ✭ 346 (+223.36%)
Mutual labels:  gpu, deeplearning
Gbrain
GPU Javascript Library for Machine Learning
Stars: ✭ 48 (-55.14%)
Mutual labels:  gpu, deeplearning
Mad Twinnet
The code for the MaD TwinNet. Demo page:
Stars: ✭ 99 (-7.48%)
Mutual labels:  deeplearning
Pytorch gbw lm
PyTorch Language Model for 1-Billion Word (LM1B / GBW) Dataset
Stars: ✭ 101 (-5.61%)
Mutual labels:  gpu
Emu
The write-once-run-anywhere GPGPU library for Rust
Stars: ✭ 1,350 (+1161.68%)
Mutual labels:  gpu
Har Keras Cnn
Human Activity Recognition (HAR) with 1D Convolutional Neural Network in Python and Keras
Stars: ✭ 97 (-9.35%)
Mutual labels:  deeplearning
Deepnet
Deep.Net machine learning framework for F#
Stars: ✭ 99 (-7.48%)
Mutual labels:  gpu
Tensorflow Gpu Macosx
Unoffcial NVIDIA CUDA GPU support version of Google Tensorflow for MAC OSX
Stars: ✭ 103 (-3.74%)
Mutual labels:  gpu
Kmeans pytorch
kmeans using PyTorch
Stars: ✭ 98 (-8.41%)
Mutual labels:  gpu
R3net
Code for the IJCAI 2018 paper "R^3Net: Recurrent Residual Refinement Network for Saliency Detection"
Stars: ✭ 105 (-1.87%)
Mutual labels:  deeplearning
Nyuziprocessor
GPGPU microprocessor architecture
Stars: ✭ 1,351 (+1162.62%)
Mutual labels:  gpu
Deeplearning ocr
Deep Learning on 身份证识别
Stars: ✭ 106 (-0.93%)
Mutual labels:  deeplearning
Nvidia p106
NVIDIA P106 GPUs
Stars: ✭ 106 (-0.93%)
Mutual labels:  gpu
Sert
Semantic Entity Retrieval Toolkit
Stars: ✭ 100 (-6.54%)
Mutual labels:  deeplearning
Androidtensorflowmachinelearningexample
Android TensorFlow MachineLearning Example (Building TensorFlow for Android)
Stars: ✭ 1,369 (+1179.44%)
Mutual labels:  deeplearning

Simple Example to run Keras models in multiple processes

This git repo contains an example to illustrate how to run Keras models prediction in multiple processes with multiple gpus. Each process owns one gpu. I wanted to run prediction by using multiple gpus, but did not find a clear solution after searching online. So, I created this example to show how to do that. Hope this git repo can help others who met the same problem.

This software works as a producer-consumer model. The scheduler scans the image path and put all of them into a Queue; while each worker as a separate process process the images in the Queue. If all of images are proceeded, the worker process will terminate.

Pay attention to the implementation Vgg16Worker::Run()

def run(self):
    #set environment
    os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
    os.environ["CUDA_VISIBLE_DEVICES"] = str(self._gpuid)
    #load models
    import vgg16
    #download the vgg16 weights from
    xnet = vgg16.Vgg16('vgg16_weights_tf_dim_ordering_tf_kernels.h5')

    print 'vggnet init done', self._gpuid

    while True:
        xfile = self._queue.get()
        if xfile == None:
            self._queue.put(None)
            break
        label = self.predict(xnet, xfile)
        print 'woker', self._gpuid, ' xfile ', xfile, " predicted as label", label

How to run the sample

Dependency:

  • Keras 2.0
  • Tensorflow
  • OpenCV

Download VGG16 Keras Model from: https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg16_weights_tf_dim_ordering_tf_kernels.h5

Command: usage: main.py [-h] [--imgpath IMGPATH] [--gpuids GPUIDS]

optional arguments: -h, --help show this help message and exit --imgpath IMGPATH path to your images to be proceed --gpuids GPUIDS gpu ids to run

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].