Skip to content
Permalink
Browse files

Removed matplotlib from examples...

  • Loading branch information...
danlester committed Jul 29, 2019
1 parent 66b1a7b commit 9cd46fc1f3e2e635319412894d91db40c4b8d80a
Showing with 17 additions and 24 deletions.
  1. +17 −23 Example/Examples.ipynb
  2. +0 −1 jupyter-innotater/requirements.txt
@@ -52,18 +52,11 @@
"outputs": [],
"source": [
"# Write our newly-input bounding box data to disk - will be lost otherwise\n",
"# If pandas not installed, please just ignore this cell\n",
"import pandas as pd\n",
"df = pd.DataFrame(targets, columns=['x','y','w','h'])\n",
"df.insert(0,'filename', foodfns)\n",
"df.to_csv('./bounding_boxes.csv')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.to_csv('./bounding_boxes.csv')\n",
"df"
]
},
@@ -80,10 +73,15 @@
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"try:\n",
" import cv2\n",
" foods = [cv2.imread('./foods/'+f) for f in foodfns]\n",
"\n",
"except ModuleNotFoundError:\n",
" print(\"OpenCV2 is not installed, so just using filenames like before - Innotater will understand\")\n",
" foods = ['./foods/'+f for f in foodfns]\n",
"\n",
"classes = ['vegetable', 'biscuit', 'fruit']\n",
"foods = [plt.imread('./foods/'+f) for f in foodfns]\n",
"targets = [0] * len(foodfns)"
]
},
@@ -94,7 +92,7 @@
"outputs": [],
"source": [
"w2 = Innotater(\n",
" ImageInnotation(foods, name='Food', colorspace='RGB'), \n",
" ImageInnotation(foods, name='Food'), \n",
" MultiClassInnotation(targets, name='FoodType', classes=classes, desc='Food Type')\n",
")\n",
"display(w2)"
@@ -116,7 +114,7 @@
"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"
"onehot_targets = np.squeeze(np.eye(len(classes))[np.array(targets).reshape(-1)]); onehot_targets"
]
},
{
@@ -152,10 +150,9 @@
"outputs": [],
"source": [
"isfruit_targets = (np.array(targets) == 2).astype('int')\n",
"w3 = Innotater( ImageInnotation(foodfns, path='./foods', width=300),\n",
"Innotater( ImageInnotation(foodfns, path='./foods', width=300),\n",
" BinaryClassInnotation(isfruit_targets, name='Is Fruit')\n",
" )\n",
"display(w3)"
" )"
]
},
{
@@ -192,14 +189,12 @@
"\n",
"suspected_fruits = isfruits == 1 # Or you can specify an array/list of int indices\n",
"\n",
"w6 = Innotater(\n",
"Innotater(\n",
" ImageInnotation(foodfns, name='Food', path='./foods'), \n",
" [ BinaryClassInnotation(isfruits, name='Is Fruit'),\n",
" BoundingBoxInnotation(bboxes, name='bbs', source='Food', desc='Food Type') ],\n",
" indexes = suspected_fruits\n",
")\n",
"\n",
"display(w6)"
")"
]
},
{
@@ -229,9 +224,8 @@
"rfoods = lfoods.copy()\n",
"rfoods.reverse()\n",
"\n",
"w5 = Innotater([ImageInnotation(lfoods, name='Food 1'), ImageInnotation(rfoods, name='Food 2')], \n",
" [BinaryClassInnotation(targets, name='Are Equal')])\n",
"display(w5)"
"Innotater([ImageInnotation(lfoods, name='Food 1'), ImageInnotation(rfoods, name='Food 2')], \n",
" [BinaryClassInnotation(targets, name='Are Equal')])"
]
},
{
@@ -3,4 +3,3 @@ widgetsnbextension>=3.1.0
notebook>=5.3.0
numpy>=1.4.0
pypng>=0.0.19
matplotlib>=3.0.0

0 comments on commit 9cd46fc

Please sign in to comment.
You can’t perform that action at this time.