All Projects → lucasxlu → XCloud

lucasxlu / XCloud

Licence: MIT license
Official Code for Paper <XCloud: Design and Implementation of AI Cloud Platform with RESTful API Service> (arXiv1912.10344)

Programming Languages

javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to XCloud

ImageRetrieval
Content Based Image Retrieval Techniques (e.g. knn, svm using MatLab GUI)
Stars: ✭ 51 (-12.07%)
Mutual labels:  image-recognition, image-retrieval, content-based-image-retrieval
coursera-ai-for-medicine-specialization
Programming assignments, labs and quizzes from all courses in the Coursera AI for Medicine Specialization offered by deeplearning.ai
Stars: ✭ 80 (+37.93%)
Mutual labels:  image-recognition, image-segmentation
Reproducibilty-Challenge-ECANET
Unofficial Implementation of ECANets (CVPR 2020) for the Reproducibility Challenge 2020.
Stars: ✭ 27 (-53.45%)
Mutual labels:  image-recognition, image-segmentation
Max Image Segmenter Web App
Deploy a Deep Learning Powered "Magic Cropping Tool" using Pre-Trained Open Source Models
Stars: ✭ 29 (-50%)
Mutual labels:  image-recognition, image-segmentation
ICCV2021-Paper-Code-Interpretation
ICCV2021/2019/2017 论文/代码/解读/直播合集,极市团队整理
Stars: ✭ 2,022 (+3386.21%)
Mutual labels:  image-recognition, image-segmentation
End To End For Chinese Plate Recognition
基于u-net,cv2以及cnn的中文车牌定位,矫正和端到端识别软件,其中unet和cv2用于车牌定位和矫正,cnn进行车牌识别,unet和cnn都是基于tensorflow的keras实现
Stars: ✭ 197 (+239.66%)
Mutual labels:  image-recognition, image-segmentation
Artificio
Deep Learning Computer Vision Algorithms for Real-World Use
Stars: ✭ 326 (+462.07%)
Mutual labels:  image-recognition, image-retrieval
Gwu data mining
Materials for GWU DNSC 6279 and DNSC 6290.
Stars: ✭ 217 (+274.14%)
Mutual labels:  data-mining, image-recognition
Gorse
An open source recommender system service written in Go
Stars: ✭ 1,148 (+1879.31%)
Mutual labels:  data-mining, restful-api
Solt
Streaming over lightweight data transformations
Stars: ✭ 249 (+329.31%)
Mutual labels:  image-recognition, image-segmentation
sharpmask
TensorFlow implementation of DeepMask and SharpMask
Stars: ✭ 31 (-46.55%)
Mutual labels:  image-recognition, image-segmentation
survey-computer-vision-2021
2021年计算机视觉技术综述分类汇总
Stars: ✭ 54 (-6.9%)
Mutual labels:  image-recognition, image-segmentation
tensorflow-image-classifier
Easily train an image classifier and then use it to label/tag other images
Stars: ✭ 29 (-50%)
Mutual labels:  image-recognition
tf-idf-python
Term frequency–inverse document frequency for Chinese novel/documents implemented in python.
Stars: ✭ 98 (+68.97%)
Mutual labels:  data-mining
xcloud-keyboard-mouse
Chrome extension for controlling Xbox Cloud Gaming (Project xCloud) using a keyboard and mouse
Stars: ✭ 78 (+34.48%)
Mutual labels:  xcloud
Spatially-Varying-Blur-Detection-python
python implementation of the paper "Spatially-Varying Blur Detection Based on Multiscale Fused and Sorted Transform Coefficients of Gradient Magnitudes" - cvpr 2017
Stars: ✭ 43 (-25.86%)
Mutual labels:  image-quality-assessment
http4s-good-practices
Collection of what I consider good practices in Http4s (WIP)
Stars: ✭ 74 (+27.59%)
Mutual labels:  restful-api
FEATHER
The reference implementation of FEATHER from the CIKM '20 paper "Characteristic Functions on Graphs: Birds of a Feather, from Statistical Descriptors to Parametric Models".
Stars: ✭ 34 (-41.38%)
Mutual labels:  data-mining
nestjs-rest-sample
NestJS RESTful APIs Sample
Stars: ✭ 204 (+251.72%)
Mutual labels:  restful-api
2018-JData-Unicom-RiskUser
2018-JData-联通-基于移动网络通讯行为的风险用户识别:Baseline 0.77
Stars: ✭ 20 (-65.52%)
Mutual labels:  data-mining

XCloud

XCloud (EXtensive Cloud)

Introduction

XCloud is an open-source AI platform which provides common AI services (computer vision, NLP, data mining and etc.) with RESTful APIs. It allows you to serve your machine learning models with few lines of code. The platform is developed and maintained by @LucasX based on Django and PyTorch.

The codes of building RESTful APIs are listed in cv/nlp/dm/data module, research branch holds the training/testing scripts and several research idea prototype implementations.

arch

Features

  • Computer Vision
    • Face Analysis
      • Face Comparison
      • Facial Beauty Prediction
      • Gender Recognition
      • Race Recognition
      • Age Estimation
      • Facial Expression Recognition
      • Face Retrieval
    • Image Recognition
      • Scene Recognition
      • Food Recognition
      • Flower Recognition
      • Plant Disease Recognition
      • Pet Insects Detection & Recognition
      • Pornography Image Recognition
      • Skin Disease Recognition
    • Image Processing
      • Image Deblurring
      • Image Dehazing
  • NLP
    • Text Similarity Comparison
    • Sentiment Classification for douban.com
    • News Classification
  • Data Mining
  • Data Services
    • Zhihu Live & Comments
    • Major Hospital Information
    • Primary and Secondary School on Baidu Baike
    • Weather History
  • Research
    • Age Estimation
    • Medical Image Analysis (Skin Lesion Analysis)
    • Crowd Counting
    • Intelligent Agriculture
    • Content-based Image Retrieval
    • Image Segmentation
    • Image Dehazing
    • Image Quality Assessment
    • Data Augmentation
    • Knowledge Distillation

Deployment

Basic Environment Preparation

  1. create a virtual enviroment named pyWeb follow this tutorial
  2. install Django and PyTorch
  3. install all dependent libraries: pip3 install -r requirements.txt
  4. activate Python Web environment: source ~/pyWeb/bin/activate pyWeb
  5. start django server:
    • test with Django built-in server: python3 manage.py runserver 0.0.0.0:8001

    • start with gunicorn: CUDA_VISIBLE_DEVICES=0,1,2,3 nohup gunicorn BCloud.wsgi -b YOUR_MACHINE_IP:8008 --timeout=500

  6. open your browser and visit welcome page: YOUR_MACHINE_IP:8001/index

TensorRT Preparation

In order to construct a more efficient inference engine, it is highly recommended to use TensorRT. With the help of TensorRT, we are able to achieve 147.23 FPS (DenseNet169 as backbone) on 2080TI GPU without performance drop, which is significantly faster than its counterpart PyTorch model (29.45 FPS).

The installation is listed as follows:

  1. download installation package from NVIDIA official websites. I use .tar.gz in this project
  2. add nvcc to you PATH: export PATH=/usr/local/cuda/bin/nvcc:$PATH
  3. install pyCUDA: pip3 install 'pycuda>=2017.1.1'
  4. unzip .tar.gz file, and modify your environment by adding: export LD_LIBRARY_PATH=/data/lucasxu/Software/TensorRT-5.1.5.0/lib:$LD_LIBRARY_PATH
  5. install TensorRT Python wheel: pip3 install ~/Software/TensorRT-5.1.5.0/python/tensorrt-5.1.5.0-cp37-none-linux_x86_64.whl
  6. install torch2trt
  7. then you can use model_converter.py to convert a PyTorch model to TensorRT model

ONNX & ONNX-Runtime Preparation

ONNX Runtime is a performance-focused engine for ONNX models, which inferences efficiently across multiple platforms and hardware (Windows, Linux, and Mac and on both CPUs and GPUs). We also provide a easy-to-use script model_converter.py to allow you to easily convert a PyTorch model to ONNX model with ONNX-Runtime inference engine.

Before use model_converter.py, make sure you have installed PyTorch, ONNX, and ONNX-Runtime. If not, just try:

pip3 install onnx onnxruntime-gpu
Inference Engine FPS
PyTorch 29.45
TensorRT 147.23
ONNX (CPU) 6.93
ONNX (GPU) 68.42

Upgrade Django Built-in Server

As suggested in Django doc, DO NOT USE THIS SERVER IN A PRODUCTION SETTING, it may bring you potential security risk and performance problems. Henceforth, you'd better upgrade Django built-in server to a stronger one, such as Nginx.

With Gunicorn (pure Python)

  1. install Gunicorn: pip3 install gunicorn
  2. run your server (with multi threads support): gunicorn XCloud.wsgi -b YOUR_MACHINE_IP:8001 --threads THREADS_NUM --timeout=200
  3. open your browser and visit welcome page: http://YOUR_MACHINE_IP:8001/index

With uWSGI (pure C)

  1. install uWSGI: pip3 install uwsgi. Try conda install -c conda-forge uwsgi if you prefer Anaconda
  2. start your uWSGI server: uwsgi --http :8001 --chdir /data/lucasxu/Projects/XCloud -w XCloud.wsgi
  3. you can specify more configuration in uwsgi.ini, and start uWSGI by: uwsgi --ini uwsgi.ini
  4. open your browser and visit welcome page: http://YOUR_MACHINE_IP:8001/index

With Nginx

Note: this tutorial gives more details about Nginx and Django

  1. install Nginx: sudo apt-get install nginx
  2. install uwsgi: sudo pip3 install uwsgi
  3. start Nginx: sudo /etc/init.d/nginx start. Type ps -ef |grep -i nginx to see whether Nginx has started successfully
  4. open your browser and visit YOUR_IP_ADDRESS:80, if you see nginx welcome page, then you have installed Nginx successfully
  5. restart Nginx: sudo /etc/init.d/nginx restart
  6. config your Nginx: sudo vim /etc/nginx/nginx.conf as follows:
    user  nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    
    events {
        use   epoll;
        worker_connections  1024;
    }
    
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        keepalive_timeout  65;
    
        gzip  on;
    
        include /etc/nginx/conf.d/*.conf;
        upstream backend {
            server YOUR_MACHINE_IP:8001;
            server YOUR_MACHINE_IP:8002;
            server YOUR_MACHINE_IP:8003;
            server YOUR_MACHINE_IP:8004;
        }
    
        server {
            listen 8008;
            server_name YOUR_MACHINE_IP;
            access_log  /var/log/nginx/access.log  main;
            charset  utf-8;
            gzip on;
            gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php application/json text/json image/jpeg image/gif image/png application/octet-stream;
    
            # set project uwsgi path
            location /cv/ {
                include uwsgi_params;  # import an Nginx module to communicate with uWSGI
                uwsgi_connect_timeout 30;
                uwsgi_pass unix:/opt/project_teacher/script/uwsgi.sock;  # set uwsgi's sock file, so all dynamical requests will be sent to uwsgi_pass
                proxy_connect_timeout 300;
                proxy_buffering off;
    
                proxy_pass http://backend;
            }
    
            location /static/ {
                alias  /data/lucasxu/Projects/XCloud/cv/static/;
                index  index.html index.htm;
            }
        }
    }
    

Note: suppose you start 4 deep learning services with ports from 8001 to 8004, on CUDA_VISIBLE_DEVICES from 0 to 3, respectively. The above configuration indicates that all concurrent requests will be proxied to YOUR_MACHINE_IP:8008/cv/. So it's easy to solve concurrent requests from clients.

  1. restart Nginx: sudo /etc/init.d/nginx restart, then enjoy it!

More

In the near future, I will explore more methods in Machine Leanring in Production fields, and share related articles on ML_IN_PRODUCTION.md or my blog.

index

Stress Testing

For stress testing, please refer to API_STRESS_TESTING_WITH_JMETER.md for more details!

API Usage

We support 3 types of request type in API, namely, web form uploaded file, base64 image and image URL (such as Swift).

  • Bash
curl -F "[email protected]" YOUR_MACHINE_IP:8001/cv/xxxrec
curl -d "image=https://xxx.com/file/test.jpg" YOUR_MACHINE_IP:8001/cv/xxxrec
  • Python
import base64
import requests

req_url = 'YOUR_MACHINE_IP:8001/cv/xxxrec'
with open("/path/to/test.jpg", mode='rb') as f:
    image = base64.b64encode(f.read())
    resp = requests.post(req_url, data={
        'image': image,
    })

    print(resp.json())

Contributor

Note

  • XCloud is freely accessible for everyone, you can email me AT [email protected] to inquire tech support.
  • Please ensure that your machine has a strong GPU equipment.
  • For XCloud in Java, please refer to CVLH for more details!
  • Technical details can be read from our Technical Report.

Organizations using XCloud Codebase or Data for Projects and Research

TODO List

Citation

If you use our codebase or models in your research, please cite this project. We have released a Technical Report about this project.

@article{xu2019xcloud,
  title={XCloud: Design and Implementation of AI Cloud Platform with RESTful API Service},
  author={Xu, Lu and Wang, Yating},
  journal={arXiv preprint arXiv:1912.10344},
  year={2019}
}

License

MIT

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].