greamown / pytorch-resnet18-service-using-websocket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pytorch-resnet18-service-using-websocket

We are using PyTorch ResNet18, converted to ONNX, to perform inference on images. The communication method being used is the WebSocket function.

Getting Started

Windows

Pre-requirements

nvidia-driver

WSL

DOCKER DESKTOP

NGINX Because WLS and the local Windows service have different IP addresses, you need to install nginx to proxy the IP.

Ubuntu

Pre-requirements

Install nvidia-driver, nvidia-docker and docker before installing the docker container.

Building image

sudo chmod u+x ./docker/*.sh
sudo ./docker/build.sh

Run docker container

sudo chmod u+x ./docker/*.sh
sudo ./docker/run.sh

Run webAPI service

gunicorn -b 0.0.0.0:5000 --workers 1 --threads 100 webapi:app
  • If you want to change port numbers, you shold change 0.0.0.0:5000.

Testing

python3 client/client_ws_100pics.py -p <folder/files>
python3 client/client_ws_batch_pickle.py -p <folder/files> --batch 8
  • p: The path of inference images. you can input the folder path or the image path.
  • If an error occurs with the WebSocket's create_connection function, you should do the following:
    pip uninstall websocket
    pip uninstall websocket-client
    pip install websocket
    pip install websocket-client

Reference

About

License:MIT License


Languages

Language:Vim Script 80.0%Language:Python 15.6%Language:Shell 1.7%Language:Perl 1.6%Language:HTML 0.8%Language:Dockerfile 0.4%