https://github.com/robmarkcole/pytorch-serve-from-colab
Serve up pytorch models running on the free GPU of Colab
https://github.com/robmarkcole/pytorch-serve-from-colab
colab-notebook colaboratory flask pytorch
Last synced: about 1 month ago
JSON representation
Serve up pytorch models running on the free GPU of Colab
- Host: GitHub
- URL: https://github.com/robmarkcole/pytorch-serve-from-colab
- Owner: robmarkcole
- License: mit
- Created: 2019-08-23T12:30:44.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T20:11:55.000Z (about 3 years ago)
- Last Synced: 2025-03-25T00:07:47.236Z (about 1 year ago)
- Topics: colab-notebook, colaboratory, flask, pytorch
- Language: Jupyter Notebook
- Size: 58.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## pytorch-serve-from-colab
[](https://colab.research.google.com/github/robmarkcole/pytorch-serve-from-colab/blob/master/pytorch-serve-colab.ipynb)
* Serve up a pytorch model via flask and access on a publix URL [via ngrok](https://github.com/gstaff/flask-ngrok)
* Use as a research tool for batch processing or just as an on demand services, all GPU accelerated :) Be sure to read the [Colab FAQ](https://research.google.com/colaboratory/faq.html)
## Run on colab
Open the notebook on [colab](https://colab.research.google.com) by clicking on the `Open In Colab` button above and follow the instructions to mount your Google drive. Then you can make a request from anywhere on the internet (substituting the ngrok url below for your own) e.g:
```
curl -X POST -F file=@hummingbird.jpg http://6801b5e1.ngrok.io/predict
```
## Run app locally
Run the flask app, this requires sudo on my machine:
```
sudo python3 app.py
```
Check that the app is accessible on the ngrok url. Then make a prediction:
```
curl -X POST -F file=@hummingbird.jpg http://localhost:5000/predict
{
"class_id": "n01833805",
"class_name": "hummingbird"
}
```