Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned up notebook formatting #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions 1_explore.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
"outputs": [],
"source": [
"# For running inference on the TF-Hub module.\n",
"import tensorflow as tf\n",
"import os\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from PIL import Image\n",
"from PIL import ImageColor\n",
"from PIL import ImageDraw\n",
"from PIL import ImageFont\n",
"import tensorflow as tf\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import os\n",
"\n",
"os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
"\n",
Expand Down Expand Up @@ -358,7 +359,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
11 changes: 4 additions & 7 deletions 2_predict.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
},
"outputs": [],
"source": [
"import sys\n",
"!pip install -r requirements.txt"
]
},
Expand All @@ -73,9 +72,11 @@
"metadata": {},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"import base64\n",
"import os\n",
"import base64\n",
"\n",
"import tensorflow as tf\n",
"\n",
"\n",
"os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
"\n",
Expand Down Expand Up @@ -144,8 +145,6 @@
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"#image file location.\n",
"my_image = 'twodogs.jpg'\n",
"\n",
Expand Down Expand Up @@ -245,7 +244,6 @@
" font,\n",
" display_str_list=[display_str])\n",
" return image_pil\n",
" image_pil.show()\n",
"\n",
"\n",
"draw_boxes(my_image, result['detections'])"
Expand All @@ -270,7 +268,6 @@
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from prediction import predict\n",
"\n",
"#image file location.\n",
Expand Down
97 changes: 4 additions & 93 deletions 3_run_flask.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,13 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: Flask in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (2.0.2)\n",
"Requirement already satisfied: gunicorn in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (20.1.0)\n",
"Requirement already satisfied: tensorflow in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (2.7.0)\n",
"Requirement already satisfied: matplotlib in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (3.4.1)\n",
"Requirement already satisfied: six in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 7)) (1.15.0)\n",
"Requirement already satisfied: numpy in /opt/app-root/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (1.19.2)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 2)) (2.0.1)\n",
"Requirement already satisfied: click>=7.1.2 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 2)) (8.0.1)\n",
"Requirement already satisfied: Werkzeug>=2.0 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 2)) (2.0.1)\n",
"Requirement already satisfied: Jinja2>=3.0 in /opt/app-root/lib/python3.8/site-packages (from Flask->-r requirements.txt (line 2)) (3.0.3)\n",
"Requirement already satisfied: setuptools>=3.0 in /opt/app-root/lib/python3.8/site-packages (from gunicorn->-r requirements.txt (line 3)) (59.5.0)\n",
"Requirement already satisfied: flatbuffers<3.0,>=1.12 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (1.12)\n",
"Requirement already satisfied: absl-py>=0.4.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (0.14.0)\n",
"Requirement already satisfied: grpcio<2.0,>=1.24.3 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (1.32.0)\n",
"Requirement already satisfied: wheel<1.0,>=0.32.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (0.37.0)\n",
"Requirement already satisfied: tensorflow-estimator<2.8,~=2.7.0rc0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (2.7.0)\n",
"Requirement already satisfied: termcolor>=1.1.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (1.1.0)\n",
"Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.21.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (0.23.1)\n",
"Requirement already satisfied: h5py>=2.9.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (2.10.0)\n",
"Requirement already satisfied: libclang>=9.0.1 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (12.0.0)\n",
"Requirement already satisfied: protobuf>=3.9.2 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (3.18.0)\n",
"Requirement already satisfied: google-pasta>=0.1.1 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (0.2.0)\n",
"Requirement already satisfied: wrapt>=1.11.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (1.12.1)\n",
"Requirement already satisfied: keras-preprocessing>=1.1.1 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (1.1.2)\n",
"Requirement already satisfied: keras<2.8,>=2.7.0rc0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (2.7.0)\n",
"Requirement already satisfied: typing-extensions>=3.6.6 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (3.7.4.3)\n",
"Requirement already satisfied: opt-einsum>=2.3.2 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (3.3.0)\n",
"Requirement already satisfied: astunparse>=1.6.0 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (1.6.3)\n",
"Requirement already satisfied: gast<0.5.0,>=0.2.1 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (0.3.3)\n",
"Requirement already satisfied: tensorboard~=2.6 in /opt/app-root/lib/python3.8/site-packages (from tensorflow->-r requirements.txt (line 5)) (2.7.0)\n",
"Requirement already satisfied: cycler>=0.10 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (0.10.0)\n",
"Requirement already satisfied: pyparsing>=2.2.1 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (2.4.7)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (1.3.2)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (2.8.2)\n",
"Requirement already satisfied: pillow>=6.2.0 in /opt/app-root/lib/python3.8/site-packages (from matplotlib->-r requirements.txt (line 6)) (8.3.2)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /opt/app-root/lib/python3.8/site-packages (from Jinja2>=3.0->Flask->-r requirements.txt (line 2)) (2.0.1)\n",
"Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /opt/app-root/lib/python3.8/site-packages (from tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (0.4.6)\n",
"Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /opt/app-root/lib/python3.8/site-packages (from tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (1.8.0)\n",
"Requirement already satisfied: google-auth<3,>=1.6.3 in /opt/app-root/lib/python3.8/site-packages (from tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (1.35.0)\n",
"Requirement already satisfied: markdown>=2.6.8 in /opt/app-root/lib/python3.8/site-packages (from tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (3.3.4)\n",
"Requirement already satisfied: requests<3,>=2.21.0 in /opt/app-root/lib/python3.8/site-packages (from tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (2.26.0)\n",
"Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /opt/app-root/lib/python3.8/site-packages (from tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (0.6.1)\n",
"Requirement already satisfied: cachetools<5.0,>=2.0.0 in /opt/app-root/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (4.2.2)\n",
"Requirement already satisfied: pyasn1-modules>=0.2.1 in /opt/app-root/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (0.2.8)\n",
"Requirement already satisfied: rsa<5,>=3.1.4 in /opt/app-root/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (4.7.2)\n",
"Requirement already satisfied: requests-oauthlib>=0.7.0 in /opt/app-root/lib/python3.8/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (1.3.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /opt/app-root/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (2021.5.30)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/app-root/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (1.26.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in /opt/app-root/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (3.2)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/app-root/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (2.0.6)\n",
"Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /opt/app-root/lib/python3.8/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (0.4.8)\n",
"Requirement already satisfied: oauthlib>=3.0.0 in /opt/app-root/lib/python3.8/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.6->tensorflow->-r requirements.txt (line 5)) (3.1.1)\n"
]
}
],
"outputs": [],
"source": [
"import sys\n",
"!pip install -r requirements.txt\n"
"!pip install -r requirements.txt"
]
},
{
Expand All @@ -99,36 +39,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" * Serving Flask app 'wsgi.py' (lazy loading)\n",
" * Environment: development\n",
" * Debug mode: on\n",
"2021-12-24 00:12:27.523210: 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; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64\n",
"2021-12-24 00:12:27.523251: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)\n",
"2021-12-24 00:12:27.523434: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (jupyterhub-nb-cfchase): /proc/driver/nvidia/version does not exist\n",
"2021-12-24 00:12:27.523691: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
" * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n",
" * Restarting with watchdog (inotify)\n",
" * Debugger is active!\n",
" * Debugger PIN: 106-278-921\n",
"2021-12-24 00:12:50.514141: 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; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64\n",
"2021-12-24 00:12:50.514182: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)\n",
"2021-12-24 00:12:50.514409: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (jupyterhub-nb-cfchase): /proc/driver/nvidia/version does not exist\n",
"2021-12-24 00:12:50.514676: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"127.0.0.1 - - [24/Dec/2021 00:13:24] \"GET /status HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [24/Dec/2021 00:13:25] \"POST /predictions HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [24/Dec/2021 00:13:25] \"POST /predictions HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [24/Dec/2021 00:13:52] \"POST /predictions HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [24/Dec/2021 00:14:02] \"POST /predictions HTTP/1.1\" 200 -\n"
]
}
],
"outputs": [],
"source": [
"!FLASK_ENV=development FLASK_APP=wsgi.py flask run"
]
Expand Down
Loading