Skip to content

XCloud: Design and Implementation of AI Cloud Platform with RESTful API Service

License

Notifications You must be signed in to change notification settings

stevenliu1375/XCloud

 
 

Repository files navigation

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. The platform is developed and maintained by @LucasX based on Django and PyTorch.

Features

  • Computer Vision
    • Face Analysis
      • Face Comparison
      • Facial Beauty Prediction (ShuffleNet V2 as backbone)
      • 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
  • NLP
    • Text Similarity Comparison
    • Sentiment Classification for douban.com
    • News Classification
  • Data Mining
    • Zhihu Live Quality Evaluation
  • 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

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: python3 manage.py runserver 0.0.0.0:8001
  6. open your browser and visit welcome page: http://www.lucasx.top: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 97.63 FPS on two 2080TI GPUs, 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

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
  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. modify XCloud_nginx.conf if needed, then copy XCloud_nginx.conf to /etc/nginx/conf.d directory
  6. restart Nginx: sudo /etc/init.d/nginx restart

More

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

index

Stress Testing

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

Contributor

Note

  • XCloud is free for researchers. For commercial use, please email me AT xulu0620@gmail.com for more details.
  • 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.

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

@misc{xu2019xcloud,
  author =       {Lu Xu and Yating Wang},
  title =        {XCloud: Design and Implementation of AI Cloud Platform with RESTful API Service},
  howpublished = {\url{https://github.com/lucasxlu/XCloud.git}},
  year =         {2019}
}

License

MIT

About

XCloud: Design and Implementation of AI Cloud Platform with RESTful API Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.4%
  • Python 12.8%
  • HTML 3.4%
  • CSS 3.3%
  • Other 0.1%