[example] fix plt commands in detection
authorEvan Shelhamer <shelhamer@imaginarynumber.net>
Wed, 13 Aug 2014 16:22:42 +0000 (09:22 -0700)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Wed, 13 Aug 2014 17:34:23 +0000 (10:34 -0700)
examples/detection.ipynb

index 3b0a5b2..1f6af25 100644 (file)
      "cell_type": "code",
      "collapsed": false,
      "input": [
+      "import numpy as np\n",
       "import pandas as pd\n",
+      "import matplotlib.pyplot as plt\n",
+      "%matplotlib inline\n",
       "\n",
       "df = pd.read_hdf('_temp/det_output.h5', 'df')\n",
       "print(df.shape)\n",
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "gray()\n",
-      "matshow(predictions_df.values)\n",
-      "xlabel('Classes')\n",
-      "ylabel('Windows')"
+      "plt.gray()\n",
+      "plt.matshow(predictions_df.values)\n",
+      "plt.xlabel('Classes')\n",
+      "plt.ylabel('Windows')"
      ],
      "language": "python",
      "metadata": {},
       "print(f.order(ascending=False)[:5])\n",
       "\n",
       "# Show top detection in red, second-best top detection in blue.\n",
-      "im = imread('images/fish-bike.jpg')\n",
-      "imshow(im)\n",
+      "im = plt.imread('images/fish-bike.jpg')\n",
+      "plt.imshow(im)\n",
       "currentAxis = plt.gca()\n",
       "\n",
       "det = df.iloc[i]\n",
       "coords = (det['xmin'], det['ymin']), det['xmax'] - det['xmin'], det['ymax'] - det['ymin']\n",
-      "currentAxis.add_patch(Rectangle(*coords, fill=False, edgecolor='r', linewidth=5))\n",
+      "currentAxis.add_patch(plt.Rectangle(*coords, fill=False, edgecolor='r', linewidth=5))\n",
       "\n",
       "det = df.iloc[j]\n",
       "coords = (det['xmin'], det['ymin']), det['xmax'] - det['xmin'], det['ymax'] - det['ymin']\n",
-      "currentAxis.add_patch(Rectangle(*coords, fill=False, edgecolor='b', linewidth=5))"
+      "currentAxis.add_patch(plt.Rectangle(*coords, fill=False, edgecolor='b', linewidth=5))"
      ],
      "language": "python",
      "metadata": {},
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "imshow(im)\n",
+      "plt.imshow(im)\n",
       "currentAxis = plt.gca()\n",
       "colors = ['r', 'b', 'y']\n",
       "for c, det in zip(colors, nms_dets[:3]):\n",
       "    currentAxis.add_patch(\n",
-      "        Rectangle((det[0], det[1]), det[2]-det[0], det[3]-det[1],\n",
+      "        plt.Rectangle((det[0], det[1]), det[2]-det[0], det[3]-det[1],\n",
       "        fill=False, edgecolor=c, linewidth=5)\n",
       "    )\n",
       "print 'scores:', nms_dets[:3, 4]"