# BMW-YOLOv3-Inference-API-CPU **Repository Path**: chenhai_hai_2020/BMW-YOLOv3-Inference-API-CPU ## Basic Information - **Project Name**: BMW-YOLOv3-Inference-API-CPU - **Description**: This is a repository for an object detection inference API using the Yolov3 Opencv. - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-19 - **Last Updated**: 2024-06-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # YOLO v3 CPU Inference API for Windows and Linux This is a repository for an object detection inference API using the Yolov3 Opencv. The inference REST API works on CPU and doesn't require any GPU usage. It's supported on both Windows and Linux Operating systems. Models trained using our training Yolov3 repository can be deployed in this API. Several object detection models can be loaded and used at the same time. ![predict image](./docs/4.gif) ## Prerequisites - OS: - Ubuntu 16.04/18.04 - Windows 10 pro/enterprise - Docker ### Check for prerequisites To check if you have docker-ce installed: ```sh docker --version ``` ### Install prerequisites #### Ubuntu Use the following command to install docker on Ubuntu: ```sh chmod +x install_prerequisites.sh && source install_prerequisites.sh ``` #### Windows 10 To [install Docker on Windows](https://docs.docker.com/docker-for-windows/install/), please follow the link. **P.S: For Windows users, open the Docker Desktop menu by clicking the Docker Icon in the Notifications area. Select Settings, and then Advanced tab to adjust the resources available to Docker Engine.** ## Build The Docker Image In order to build the project run the following command from the project's root directory: ```sh sudo docker build -t yolov3_inference_api_cpu -f ./docker/dockerfile . ``` ### Behind a proxy ```sh sudo docker build --build-arg http_proxy='' --build-arg https_proxy='' -t yolov3_inference_api_cpu -f ./docker/dockerfile . ``` ## Run The Docker Container To run the API, go to the project's root directory and run the following: #### Using Linux based docker: ```sh sudo docker run -itv $(pwd)/models:/models -p :7770 yolov3_inference_api_cpu ``` #### Using Windows based docker: ```sh docker run -itv ${PWD}/models:/models -p :7770 yolov3_inference_api_cpu ``` The can be any unique port of your choice. The API file will be run automatically, and the service will listen to http requests on the chosen port. ## API Endpoints To see all available endpoints, open your favorite browser and navigate to: ``` http://:/docs ``` The 'predict_batch' endpoint is not shown on swagger. **P.S: If you are using custom endpoints like /load, /detect, and /get_labels, you should always use the /load endpoint first and then use /detect or /get_labels** ### Endpoints summary #### /load (GET) Loads all available models and returns every model with it's hashed value. Loaded models are stored and aren't loaded again ![load model](./docs/1.gif) #### /detect (POST) Performs inference on specified model, image, and returns bounding-boxes ![detect image](./docs/3.gif) #### /get_labels (POST) Returns all of the specified model labels with their hashed values ![get model labels](./docs/2.gif) #### /models/{model_name}/predict_image (POST) Performs inference on specified model, image, draws bounding boxes on the image, and returns the actual image as response ![predict image](./docs/4.gif) #### /models (GET) Lists all available models #### /models/{model_name}/load (GET) Loads the specified model. Loaded models are stored and aren't loaded again #### /models/{model_name}/predict (POST) Performs inference on specified model, image, and returns bounding boxes. #### /models/{model_name}/labels (GET) Returns all of the specified model labels #### /models/{model_name}/config (GET) Returns the specified model's configuration #### /models/{model_name}/predict_batch (POST) Performs inference on specified model and a list of images, and returns bounding boxes ## Model structure The folder "models" contains subfolders of all the models to be loaded. Inside each subfolder there should be a: - Cfg file (ends with .cfg): contains the configuration of the model - Weights file (ends with .weights) - Names file (ends with .names) : contains the names of the classes - Config.json (This is a json file containing information about the model) ```json { "inference_engine_name": "yolov3_opencv_cpu_detection", "confidence": 60, "nms_threshold": 0.6, "image": { "width": 416, "height": 416, "scale": 0.00392, "swapRB": true, "crop": false, "mean": { "R": 0, "G": 0, "B": 0 } }, "framework": "yolo", "type": "detection", "network": "network_name" } ``` P.S - confidence value should be between 0 and 100 - nms_threshold value should be between 0 and 1 - You can change confidence and nms_threshold values while running the API - The API will return bounding boxes with a confidence higher than the "confidence" value. A high "confidence" can show you only accurate predictions ## Benchmarking
Windows Ubuntu
Network\Hardware Intel Xeon CPU 2.3 GHz Intel Xeon CPU 2.3 GHz Intel Core i9-7900 3.3 GHZ GeForce GTX 1080
pascalvoc_dataset 0.885 seconds/image 0.793 seconds/image 0.295 seconds/image 0.0592 seconds/image
## Acknowledgment [inmind.ai](https://inmind.ai) [robotron.de](https://robotron.de) Antoine Charbel, inmind.ai , Beirut, Lebanon Daniel Anani, inmind.ai, Beirut, Lebanon