From 9e5da8050b786a1756dd2777dddb3e9e6cbbee16 Mon Sep 17 00:00:00 2001 From: Dan Lester Date: Mon, 29 Jul 2019 11:53:14 +0100 Subject: [PATCH] git hooks again --- Example/Examples.ipynb | 390 +++------------------------------ docs/chapters/installation.rst | 3 +- 2 files changed, 35 insertions(+), 358 deletions(-) diff --git a/Example/Examples.ipynb b/Example/Examples.ipynb index a8f83ea..ee35b19 100644 --- a/Example/Examples.ipynb +++ b/Example/Examples.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -19,24 +19,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "19f760d2e5204316bbc542c36c7e78a1", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(ImagePad(value=b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x0…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "foodfns = sorted(os.listdir('./foods/'))\n", "targets = np.zeros((len(foodfns), 4), dtype='int') # (x,y,w,h) for each data row\n", @@ -53,34 +38,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[203, 103, 76, 70],\n", - " [113, 126, 185, 140],\n", - " [159, 57, 91, 87],\n", - " [178, 104, 94, 79],\n", - " [165, 36, 142, 151],\n", - " [129, 126, 92, 88],\n", - " [ 77, 88, 143, 142],\n", - " [221, 31, 106, 128]])" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "targets" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -93,123 +60,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
filenamexywh
0avocado.jpg2031037670
1banana.jpg113126185140
2garlic.jpg159579187
3gingerbiscuit.jpg1781049479
4grapefruit.jpg16536142151
5lime.jpg1291269288
6onion.jpg7788143142
7sweetpotato.jpg22131106128
\n", - "
" - ], - "text/plain": [ - " filename x y w h\n", - "0 avocado.jpg 203 103 76 70\n", - "1 banana.jpg 113 126 185 140\n", - "2 garlic.jpg 159 57 91 87\n", - "3 gingerbiscuit.jpg 178 104 94 79\n", - "4 grapefruit.jpg 165 36 142 151\n", - "5 lime.jpg 129 126 92 88\n", - "6 onion.jpg 77 88 143 142\n", - "7 sweetpotato.jpg 221 31 106 128" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df" ] @@ -223,7 +76,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -235,24 +88,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "00e556124bd54ceb9c582d5ec4ae5aa9", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(ImagePad(value=b'\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "w2 = Innotater(\n", " ImageInnotation(foods, name='Food'), \n", @@ -263,47 +101,18 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[0, 2, 0, 1, 2, 2, 0, 0]" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "targets" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[1., 0., 0.],\n", - " [0., 0., 1.],\n", - " [1., 0., 0.],\n", - " [0., 1., 0.],\n", - " [0., 0., 1.],\n", - " [0., 0., 1.],\n", - " [1., 0., 0.],\n", - " [1., 0., 0.]])" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Convert targets from a 1-dim array to one-hot representation - Innotater works with that just as well\n", "onehot_targets = np.squeeze(np.eye(np.array(targets).max()+1)[np.array(targets).reshape(-1)]); onehot_targets" @@ -311,24 +120,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "bfdb3d0cf35e424a83e6c13c447aa9ee", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(ImagePad(value=b'\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "Innotater(\n", " ImageInnotation(foods, name='Food'), \n", @@ -352,24 +146,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "db99d34a965a47cfaa9feafd31f24a98", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(ImagePad(value=b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x0…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "isfruit_targets = (np.array(targets) == 2).astype('int')\n", "w3 = Innotater( ImageInnotation(foodfns, path='./foods', width=300),\n", @@ -380,20 +159,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([1, 1, 0, 0, 1, 1, 0, 0])" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "isfruit_targets" ] @@ -414,24 +182,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "758e92ce1c724f6f850f208b818c82a5", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(ImagePad(value=b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x0…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "bboxes = np.zeros((len(foodfns),4), dtype='int')\n", "isfruits = np.expand_dims(isfruit_targets, axis=-1)\n", @@ -450,27 +203,9 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 1, 198, 102, 76, 61],\n", - " [ 1, 109, 124, 188, 134],\n", - " [ 0, 0, 0, 0, 0],\n", - " [ 0, 0, 0, 0, 0],\n", - " [ 1, 161, 41, 154, 157],\n", - " [ 1, 124, 127, 127, 86],\n", - " [ 0, 0, 0, 0, 0],\n", - " [ 0, 0, 0, 0, 0]])" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "result = np.concatenate([isfruits,bboxes], axis=-1); result" ] @@ -484,24 +219,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "0e4750c4c53749809274e09832a8ac70", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(ImagePad(value=b'\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "targets = np.array([[1,0]] * 5) # One-hot format, defaulting to 0 class\n", "lfoods = foods[:5]\n", @@ -515,24 +235,9 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[1, 0],\n", - " [1, 0],\n", - " [0, 1],\n", - " [1, 0],\n", - " [1, 0]])" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "targets" ] @@ -547,24 +252,9 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "5ebcd594ebd34361b6a8952eb85c04d6", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Innotater(children=(HBox(children=(VBox(children=(Textarea(value='I really liked this movie', disabled=True),)…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "reviews = ['I really liked this movie', 'It was OK', 'Do not watch!', 'Was worth trying it']\n", "sentiments = [1] * len(reviews)\n", @@ -575,23 +265,9 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('I really liked this movie', '0 - Positive'),\n", - " ('It was OK', '1 - Neutral'),\n", - " ('Do not watch!', '2 - Negative'),\n", - " ('Was worth trying it', '0 - Positive')]" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "list(zip(reviews, [sentiment_classes[s] for s in sentiments]))" ] diff --git a/docs/chapters/installation.rst b/docs/chapters/installation.rst index 9a19cef..99529f5 100644 --- a/docs/chapters/installation.rst +++ b/docs/chapters/installation.rst @@ -27,7 +27,8 @@ Development install jupyter nbextension enable --py --sys-prefix jupyter_innotater # Optional - ln -s ./githooks/pre-commit .git/hooks + cd .. + ln -s ./githooks/pre-commit .git/hooks/pre-commit # Maybe also: pip install ipywidgets