examples/facial-keypoints-detection-.../facial-keypoints-detection-...

494 lines
28 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"skip"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: tensorflow in /home/jovyan/.local/lib/python3.6/site-packages (2.5.2)\n",
"Requirement already satisfied: absl-py~=0.10 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.11.0)\n",
"Requirement already satisfied: flatbuffers~=1.12.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (1.12)\n",
"Requirement already satisfied: grpcio~=1.34.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (1.34.1)\n",
"Requirement already satisfied: numpy~=1.19.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.19.5)\n",
"Requirement already satisfied: h5py~=3.1.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (3.1.0)\n",
"Requirement already satisfied: termcolor~=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.1.0)\n",
"Requirement already satisfied: tensorboard~=2.5 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (2.6.0)\n",
"Requirement already satisfied: opt-einsum~=3.3.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (3.3.0)\n",
"Requirement already satisfied: protobuf>=3.9.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (3.19.3)\n",
"Requirement already satisfied: six~=1.15.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (1.15.0)\n",
"Requirement already satisfied: gast==0.4.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (0.4.0)\n",
"Requirement already satisfied: keras-nightly~=2.5.0.dev in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (2.5.0.dev2021032900)\n",
"Requirement already satisfied: wheel~=0.35 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (0.37.1)\n",
"Requirement already satisfied: google-pasta~=0.2 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (0.2.0)\n",
"Requirement already satisfied: typing-extensions~=3.7.4 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (3.7.4.3)\n",
"Requirement already satisfied: astunparse~=1.6.3 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (1.6.3)\n",
"Requirement already satisfied: tensorflow-estimator<2.6.0,>=2.5.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (2.5.0)\n",
"Requirement already satisfied: keras-preprocessing~=1.1.2 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (1.1.2)\n",
"Requirement already satisfied: wrapt~=1.12.1 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow) (1.12.1)\n",
"Requirement already satisfied: cached-property in /home/jovyan/.local/lib/python3.6/site-packages (from h5py~=3.1.0->tensorflow) (1.5.2)\n",
"Requirement already satisfied: markdown>=2.6.8 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard~=2.5->tensorflow) (3.3.7)\n",
"Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard~=2.5->tensorflow) (0.6.1)\n",
"Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard~=2.5->tensorflow) (1.8.1)\n",
"Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.5->tensorflow) (2.27.1)\n",
"Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard~=2.5->tensorflow) (0.4.6)\n",
"Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.5->tensorflow) (1.35.0)\n",
"Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.5->tensorflow) (59.6.0)\n",
"Requirement already satisfied: werkzeug>=0.11.15 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard~=2.5->tensorflow) (2.0.3)\n",
"Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (4.2.4)\n",
"Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (0.2.8)\n",
"Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (4.8)\n",
"Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.5->tensorflow) (1.3.0)\n",
"Requirement already satisfied: importlib-metadata>=4.4 in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard~=2.5->tensorflow) (4.8.3)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (3.3)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (1.26.8)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (2.0.10)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard~=2.5->tensorflow) (2021.10.8)\n",
"Requirement already satisfied: dataclasses in /usr/local/lib/python3.6/dist-packages (from werkzeug>=0.11.15->tensorboard~=2.5->tensorflow) (0.8)\n",
"Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard~=2.5->tensorflow) (3.6.0)\n",
"Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.6/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow) (0.4.8)\n",
"Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.5->tensorflow) (3.1.1)\n",
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: autokeras in /home/jovyan/.local/lib/python3.6/site-packages (1.0.16.post1)\n",
"Requirement already satisfied: tensorflow<2.6,>=2.3.0 in /home/jovyan/.local/lib/python3.6/site-packages (from autokeras) (2.5.2)\n",
"Requirement already satisfied: keras-tuner<1.1,>=1.0.2 in /home/jovyan/.local/lib/python3.6/site-packages (from autokeras) (1.0.4)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from autokeras) (1.1.5)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.6/dist-packages (from autokeras) (21.3)\n",
"Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from autokeras) (0.23.2)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from keras-tuner<1.1,>=1.0.2->autokeras) (2.27.1)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from keras-tuner<1.1,>=1.0.2->autokeras) (1.19.5)\n",
"Requirement already satisfied: ipython in /usr/local/lib/python3.6/dist-packages (from keras-tuner<1.1,>=1.0.2->autokeras) (7.16.2)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from keras-tuner<1.1,>=1.0.2->autokeras) (1.5.4)\n",
"Requirement already satisfied: tensorboard in /home/jovyan/.local/lib/python3.6/site-packages (from keras-tuner<1.1,>=1.0.2->autokeras) (2.6.0)\n",
"Requirement already satisfied: kt-legacy in /home/jovyan/.local/lib/python3.6/site-packages (from keras-tuner<1.1,>=1.0.2->autokeras) (1.0.4)\n",
"Requirement already satisfied: protobuf>=3.9.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow<2.6,>=2.3.0->autokeras) (3.19.3)\n",
"Requirement already satisfied: keras-nightly~=2.5.0.dev in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (2.5.0.dev2021032900)\n",
"Requirement already satisfied: tensorflow-estimator<2.6.0,>=2.5.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (2.5.0)\n",
"Requirement already satisfied: h5py~=3.1.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (3.1.0)\n",
"Requirement already satisfied: wrapt~=1.12.1 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.12.1)\n",
"Requirement already satisfied: six~=1.15.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.15.0)\n",
"Requirement already satisfied: flatbuffers~=1.12.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.12)\n",
"Requirement already satisfied: gast==0.4.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (0.4.0)\n",
"Requirement already satisfied: google-pasta~=0.2 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (0.2.0)\n",
"Requirement already satisfied: absl-py~=0.10 in /usr/local/lib/python3.6/dist-packages (from tensorflow<2.6,>=2.3.0->autokeras) (0.11.0)\n",
"Requirement already satisfied: keras-preprocessing~=1.1.2 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.1.2)\n",
"Requirement already satisfied: opt-einsum~=3.3.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (3.3.0)\n",
"Requirement already satisfied: grpcio~=1.34.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.34.1)\n",
"Requirement already satisfied: astunparse~=1.6.3 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.6.3)\n",
"Requirement already satisfied: termcolor~=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow<2.6,>=2.3.0->autokeras) (1.1.0)\n",
"Requirement already satisfied: wheel~=0.35 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (0.37.1)\n",
"Requirement already satisfied: typing-extensions~=3.7.4 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorflow<2.6,>=2.3.0->autokeras) (3.7.4.3)\n",
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.6/dist-packages (from packaging->autokeras) (3.0.6)\n",
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas->autokeras) (2021.3)\n",
"Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.6/dist-packages (from pandas->autokeras) (2.8.2)\n",
"Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->autokeras) (1.1.0)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->autokeras) (3.0.0)\n",
"Requirement already satisfied: cached-property in /home/jovyan/.local/lib/python3.6/site-packages (from h5py~=3.1.0->tensorflow<2.6,>=2.3.0->autokeras) (1.5.2)\n",
"Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (0.4.6)\n",
"Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (59.6.0)\n",
"Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (1.8.1)\n",
"Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (0.6.1)\n",
"Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (1.35.0)\n",
"Requirement already satisfied: werkzeug>=0.11.15 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (2.0.3)\n",
"Requirement already satisfied: markdown>=2.6.8 in /home/jovyan/.local/lib/python3.6/site-packages (from tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (3.3.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->keras-tuner<1.1,>=1.0.2->autokeras) (2021.10.8)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->keras-tuner<1.1,>=1.0.2->autokeras) (3.3)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->keras-tuner<1.1,>=1.0.2->autokeras) (1.26.8)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.6/dist-packages (from requests->keras-tuner<1.1,>=1.0.2->autokeras) (2.0.10)\n",
"Requirement already satisfied: pickleshare in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.7.5)\n",
"Requirement already satisfied: pygments in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (2.11.2)\n",
"Requirement already satisfied: jedi<=0.17.2,>=0.10 in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.17.2)\n",
"Requirement already satisfied: decorator in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (4.4.2)\n",
"Requirement already satisfied: backcall in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.2.0)\n",
"Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (4.3.3)\n",
"Requirement already satisfied: pexpect in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (4.8.0)\n",
"Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from ipython->keras-tuner<1.1,>=1.0.2->autokeras) (3.0.24)\n",
"Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (0.2.8)\n",
"Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (4.8)\n",
"Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (4.2.4)\n",
"Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (1.3.0)\n",
"Requirement already satisfied: parso<0.8.0,>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from jedi<=0.17.2,>=0.10->ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.7.1)\n",
"Requirement already satisfied: importlib-metadata>=4.4 in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (4.8.3)\n",
"Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.2.5)\n",
"Requirement already satisfied: ipython-genutils in /usr/local/lib/python3.6/dist-packages (from traitlets>=4.2->ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.2.0)\n",
"Requirement already satisfied: dataclasses in /usr/local/lib/python3.6/dist-packages (from werkzeug>=0.11.15->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (0.8)\n",
"Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.6/dist-packages (from pexpect->ipython->keras-tuner<1.1,>=1.0.2->autokeras) (0.7.0)\n",
"Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (3.6.0)\n",
"Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.6/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (0.4.8)\n",
"Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard->keras-tuner<1.1,>=1.0.2->autokeras) (3.1.1)\n",
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: kaggle in /home/jovyan/.local/lib/python3.6/site-packages (1.5.12)\n",
"Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from kaggle) (2021.10.8)\n",
"Requirement already satisfied: urllib3 in /usr/local/lib/python3.6/dist-packages (from kaggle) (1.26.8)\n",
"Requirement already satisfied: six>=1.10 in /home/jovyan/.local/lib/python3.6/site-packages (from kaggle) (1.15.0)\n",
"Requirement already satisfied: tqdm in /home/jovyan/.local/lib/python3.6/site-packages (from kaggle) (4.64.0)\n",
"Requirement already satisfied: python-dateutil in /usr/local/lib/python3.6/dist-packages (from kaggle) (2.8.2)\n",
"Requirement already satisfied: python-slugify in /home/jovyan/.local/lib/python3.6/site-packages (from kaggle) (6.1.2)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from kaggle) (2.27.1)\n",
"Requirement already satisfied: text-unidecode>=1.3 in /home/jovyan/.local/lib/python3.6/site-packages (from python-slugify->kaggle) (1.3)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle) (3.3)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle) (2.0.10)\n",
"Requirement already satisfied: importlib-resources in /usr/local/lib/python3.6/dist-packages (from tqdm->kaggle) (5.4.0)\n",
"Requirement already satisfied: zipp>=3.1.0 in /usr/local/lib/python3.6/dist-packages (from importlib-resources->tqdm->kaggle) (3.6.0)\n"
]
}
],
"source": [
"!pip install tensorflow\n",
"!pip install autokeras\n",
"!pip install kaggle"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"skip"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"downloading data fom Kaggle ... \n",
"Downloading training.zip to /home/jovyan/examples-1/facial-keypoints-detection-kaggle-competition/my_data\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 60.1M/60.1M [00:00<00:00, 167MB/s] \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Downloading test.zip to /home/jovyan/examples-1/facial-keypoints-detection-kaggle-competition/my_data\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 16.0M/16.0M [00:00<00:00, 129MB/s] "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"def download_kaggle_dataset(kaggle_user:str, kaggle_key:str, data_set:str, path:str):\n",
" import os\n",
" import glob\n",
" \n",
"# print(kaggle_user)\n",
"# print(kaggle_key)\n",
" os.environ['KAGGLE_USERNAME'] = kaggle_user \n",
" os.environ['KAGGLE_KEY'] = kaggle_key\n",
"\n",
" import kaggle\n",
" from kaggle.api.kaggle_api_extended import KaggleApi\n",
"# os.chdir(os.environ.get('HOME'))\n",
" os.chdir(os.getcwd())\n",
" os.system(\"mkdir \" + path)\n",
" os.chdir(path)\n",
" api = KaggleApi()\n",
" api.authenticate()\n",
" api.competition_download_file('facial-keypoints-detection','training.zip')\n",
" api.competition_download_file('facial-keypoints-detection','test.zip')\n",
"\n",
"\n",
"print('downloading data fom Kaggle ... ')\n",
"download_kaggle_dataset(\"username\", \"key\", \"facial-keypoints-detection\",\"my_data\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"imports"
]
},
"outputs": [],
"source": [
"import numpy as np\n",
"import os\n",
"from sklearn.utils import shuffle \n",
"import matplotlib.pyplot as plt \n",
"import tensorflow as tf \n",
"import pandas as pd\n",
"from tensorflow.keras.models import load_model\n",
"import os\n",
"import shutil\n",
"import argparse\n",
"import autokeras as ak\n",
"from tensorflow.keras.models import load_model\n",
"import autokeras as ak\n",
"import pandas as pd\n",
"import numpy as np\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"pipeline-parameters"
]
},
"outputs": [],
"source": [
"trials = 1\n",
"epochs = 1\n",
"patience = 1"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"tags": [
"block:train"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train Archive unzipped\n",
"Test Archive unzipped\n",
"INFO:tensorflow:Reloading Oracle from existing project ./image_regressor/oracle.json\n",
"INFO:tensorflow:Reloading Tuner from ./image_regressor/tuner0.json\n",
"INFO:tensorflow:Oracle triggered exit\n",
"67/67 [==============================] - 187s 3s/step - loss: 1707.4453 - mean_squared_error: 1707.4453\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jovyan/.local/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py:497: CustomMaskWarning: Custom mask layers require a config and must override get_config. When loading, the custom mask layer must be passed to the custom_objects argument.\n",
" category=CustomMaskWarning)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: ./image_regressor/best_model/assets\n"
]
},
{
"data": {
"text/plain": [
"<tensorflow.python.keras.callbacks.History at 0x7f2b38167128>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"\n",
"project=\"Facial-keypoints\"\n",
"run_id= \"1.8\"\n",
"resume_run = True\n",
"\n",
"MAX_TRIALS=int(trials)\n",
"EPOCHS=int(epochs)\n",
"PATIENCE=int(patience)\n",
"\n",
"### Data Extraction : extract data and save to attached extenal pvc at location /data ###\n",
"\n",
"base_dir='my_data/'\n",
"train_dir_zip=base_dir+'training.zip'\n",
"test_dir_zip=base_dir+'test.zip'\n",
"\n",
"from zipfile import ZipFile\n",
"with ZipFile(train_dir_zip,'r') as zipObj:\n",
" zipObj.extractall('data')\n",
" print(\"Train Archive unzipped\")\n",
"with ZipFile(test_dir_zip,'r') as zipObj:\n",
" zipObj.extractall('data')\n",
" print(\"Test Archive unzipped\")\n",
"\n",
"\n",
"## Data preprocess \n",
"\n",
"train_dir='data/training.csv'\n",
"test_dir='data/test.csv'\n",
"train=pd.read_csv(train_dir)\n",
"test=pd.read_csv(test_dir)\n",
"\n",
"train=train.dropna()\n",
"train=train.reset_index(drop=True)\n",
"\n",
"X_train=[]\n",
"Y_train=[]\n",
"\n",
"for img in train['Image']:\n",
" X_train.append(np.asarray(img.split(),dtype=float).reshape(96,96,1))\n",
"X_train=np.reshape(X_train,(-1,96,96,1))\n",
"X_train = np.asarray(X_train).astype('float32')\n",
" \n",
"for i in range(len((train))): \n",
" Y_train.append(np.asarray(train.iloc[i][0:30].to_numpy()))\n",
"Y_train = np.asarray(Y_train).astype('float32')\n",
"\n",
"## Data training\n",
"\n",
"reg = ak.ImageRegressor(max_trials=MAX_TRIALS)\n",
"reg.fit(X_train, Y_train, validation_split=0.15, epochs=EPOCHS)\n",
"\n",
"# Export trained model to externally attached pvc \n",
"my_model = reg.export_model()\n",
"my_model.save('data/model_autokeras', save_format=\"tf\")\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"tags": [
"block:eval",
"prev:train"
]
},
"outputs": [],
"source": [
"\n",
"### Load model \n",
"loaded_model = load_model(\"data/model_autokeras\", custom_objects=ak.CUSTOM_OBJECTS)\n",
"\n",
"### Pint model summary\n",
"print(loaded_model.summary())\n",
"\n",
"test_dir='data/test.csv'\n",
"test=pd.read_csv(test_dir)\n",
"\n",
"X_test=[]\n",
"for img in test['Image']:\n",
" X_test.append(np.asarray(img.split(),dtype=float).reshape(96,96,1))\n",
"X_test=np.reshape(X_test,(-1,96,96,1))\n",
"X_test = np.asarray(X_test).astype('float32')\n",
"\n",
"### predict \n",
"y_pred = loaded_model.predict(X_test)\n",
"\n",
"### Create submission file\n",
"y_pred= y_pred.reshape(-1,)\n",
"submission = pd.DataFrame({'Location': y_pred})\n",
"submission.to_csv('data/submission.csv', index=True , index_label='RowId')\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"kubeflow_notebook": {
"autosnapshot": false,
"experiment": {
"id": "c2268016-e4ff-4bea-8fc3-9b7ee1e56a25",
"name": "Kale-pipelines"
},
"experiment_name": "Kale-pipelines",
"katib_metadata": {
"algorithm": {
"algorithmName": "grid"
},
"maxFailedTrialCount": 3,
"maxTrialCount": 12,
"objective": {
"objectiveMetricName": "",
"type": "minimize"
},
"parallelTrialCount": 3,
"parameters": []
},
"katib_run": false,
"pipeline_description": "converted facial keypoint detection to pipeline",
"pipeline_name": "kale-pipeline",
"snapshot_volumes": true,
"steps_defaults": [
"label:access-ml-pipeline:true",
"label:access-rok:true"
],
"volume_access_mode": "rwm",
"volumes": [
{
"annotations": [],
"mount_point": "/home/jovyan",
"name": "facial-keypoint-detection-workspace-wqmtn",
"size": 5,
"size_type": "Gi",
"snapshot": false,
"type": "clone"
}
]
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}