From: Evan Shelhamer Date: Wed, 13 Aug 2014 16:22:42 +0000 (-0700) Subject: [example] fix plt commands in detection X-Git-Tag: submit/tizen/20180823.020014~641 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=20adacb5d164fed0f463e538e1591141359aedf1;p=platform%2Fupstream%2Fcaffeonacl.git [example] fix plt commands in detection --- diff --git a/examples/detection.ipynb b/examples/detection.ipynb index 3b0a5b2..1f6af25 100644 --- a/examples/detection.ipynb +++ b/examples/detection.ipynb @@ -414,7 +414,10 @@ "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", @@ -525,10 +528,10 @@ "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": {}, @@ -626,17 +629,17 @@ "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": {}, @@ -776,12 +779,12 @@ "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]"