Giter Club home page Giter Club logo

drifti-rd's People

Contributors

gudleik avatar joshclement0 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

drifti-rd's Issues

Separate production and retraining dependencies

Seems as require.txt is used for installing python dependencies both for production and retraining?
By excluding dev/retraining dependencies from the docker image, the build speed and size should be reduced as well.
Not sure whats considered as best practice in python, but maybe either

Move production dependencies from require.txt into the Dockerfile, like RUN pip install Pillow flask waitress, so pip install -r require.txt is only used for retraining

or

Have two files, require.dev.txt and require.prod.txt ?

Provided examples in README doesn't work

Followed the steps from the README to build, run and test:

$ docker build -t pronto-image-classifer . --platform linux/amd64
$ docker run --name tf1 --platform linux/amd64 --publish 5000:5000 --rm pronto-image-classifer

Testing single image:

$ curl -G -d img=https://prod-5929f14.s3.eu-north-1.amazonaws.com/accounts/136/files/ck5du6wwc006c07qx9j596su9 localhost:5000/api/predict

invalid parameters:https://prod-5929f14.s3.eu-north-1.amazonaws.com/accounts/136/files/ck5du6wwc006c07qx9j596su9 EX:[Errno 2] No such file or directory: 'fls/qx9j596su9.png'

Testing multiple images:

$ curl -i -X POST -H "Content-Type: application/json" -d "{\"imgs\":[\"https://prod-c467854.s3.eu-north-1.amazonaws.com/accounts/128/files/3oXVxlCDCDjxnh9sPYA7g\",\"https://prod-5929f14.s3.eu-north-1.amazonaws.com/accounts/136/files/ck57u3urw001d07hd6lbe2ciz\"]}" localhost:5000/api/predict
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 250
Server: Werkzeug/2.0.1 Python/3.8.11
Date: Fri, 30 Jul 2021 09:31:12 GMT

invalid parameters: {'imgs': ['https://prod-c467854.s3.eu-north-1.amazonaws.com/accounts/128/files/3oXVxlCDCDjxnh9sPYA7g', 'https://prod-5929f14.s3.eu-north-1.amazonaws.com/accounts/136/files/ck57u3urw001d07hd6lbe2ciz']} EX:name 'time' is not defined

Errors when starting docker image

When starting the docker image it shows the following errors:

2021-07-30 09:26:12.918956: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-07-30 09:26:12.919029: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-07-30 09:26:13.977899: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2021-07-30 09:26:13.977960: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2021-07-30 09:26:13.977989: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (12939fcc69dd): /proc/driver/nvidia/version does not exist
2021-07-30 09:26:13.978238: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/mobilenet_v2/mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_224_no_top.h5

Improve docker build

Currently, running docker build will run pip install every time.
pip install should only be performed when require.txt has changed, maybe something like this:

COPY require.txt .
RUN pip install -r require.txt
COPY . .

Speed improvements

Currently the Api is rather slow. Predicting the sample image on my Macbook takes about a second (my internet speed is 500mbps). And in production this would take a lot more time as our production nodes are pretty slow.

Are there any ways to improve this?
If not, it will limit how we can use the service. For example, it will be impossible to provide "live" feedback to the user (ie user uploads images and is presented the tags in the same modal). So we most likely will have to run it in the background.

Improve concurrency

I started the server using the command specified in the Readme, and tried running multiple concurrent requests using a node script. Sometimes this resulted in 400 Bad Request, even with only 4 simultaneously requests.

The script I used for testing:

const fetch = require('node-fetch')
const url = 'http://localhost:5000/api/predict?img=https%3A%2F%2Fprod-5929f14.s3.eu-north-1.amazonaws.com%2Faccounts%2F136%2Ffiles%2Fck5du6wwc006c07qx9j596su9'

async function callApi() {
  const res = await fetch(url)
  if (!res.ok) throw new Error(res.statusText)
  return res.json()
}

async function main(concurrency) {
  const result = await Promise.all(Array.from(Array(concurrency)).map(callApi))
  console.log(result)
}

main(Number(process.argv[2] || 5)).catch(console.error)

Concurrency should be handled better. I'm not familiar with neither python or the libraries used (flask/waitress), so I don't really have any good ideas on how to improve this.

Retraining the model

Readme says to use create_model.py to retrain the model, but not how ;)
Tried running python3 create_model.py without luck. Got error ModuleNotFoundError: No module named 'pandas'.

Document the steps required to retrain the model, including

  • how to install required dependencies
  • how to run the script
  • what to do after, is it enough to just rebuild the docker image?

Warnings about not using in production

When spinning up the docker image, it spits out some warnings about not using in production

 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off

Expected behaviour: should be production ready

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.