Skip to content

Commit

Permalink
commit inicial
Browse files Browse the repository at this point in the history
  • Loading branch information
mfalcon committed Nov 2, 2017
1 parent bcf0ff4 commit 05471f8
Show file tree
Hide file tree
Showing 4 changed files with 518 additions and 0 deletions.
7 changes: 7 additions & 0 deletions raspberry/getpics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

while true
do
/home/pi/webcam.sh
sleep 5
done
5 changes: 5 additions & 0 deletions raspberry/webcam.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

DATE=$(date +”%Y-%m-%d_%H%M%S”)

fswebcam -r 640×480 –no-banner /home/pi/webcam/$DATE.jpg
275 changes: 275 additions & 0 deletions taxiornot.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Taxiornot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic setup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Importamos la clase vgg16 y luego la instanciamos"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Using TensorFlow backend.\n"
]
}
],
"source": [
"from vgg16 import Vgg16"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"vgg = Vgg16()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"batch_size=4"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"path = \"data/tachornot/\""
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found 236 images belonging to 2 classes.\n",
"Found 62 images belonging to 2 classes.\n"
]
}
],
"source": [
"batches = vgg.get_batches(path+'train', batch_size=batch_size)\n",
"val_batches = vgg.get_batches(path+'valid', batch_size=batch_size)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Calling *finetune()* modifies the model such that it will be trained based on the data in the batches provided - in this case, to predict either 'dog' or 'cat'."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"vgg.finetune(batches)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, we *fit()* the parameters of the model using the training data, reporting the accuracy on the validation set after every epoch. (An *epoch* is one full pass through the training data.)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/10\n",
"236/236 [==============================] - 4s - loss: 0.9080 - acc: 0.7500 - val_loss: 0.2648 - val_acc: 0.8710\n",
"Epoch 2/10\n",
"236/236 [==============================] - 3s - loss: 0.4089 - acc: 0.8475 - val_loss: 0.1603 - val_acc: 0.9516\n",
"Epoch 3/10\n",
"236/236 [==============================] - 3s - loss: 0.2968 - acc: 0.9068 - val_loss: 0.2070 - val_acc: 0.9355\n",
"Epoch 4/10\n",
"236/236 [==============================] - 3s - loss: 0.3114 - acc: 0.8983 - val_loss: 0.2002 - val_acc: 0.9516\n",
"Epoch 5/10\n",
"236/236 [==============================] - 3s - loss: 0.1200 - acc: 0.9449 - val_loss: 0.0704 - val_acc: 0.9839\n",
"Epoch 6/10\n",
"236/236 [==============================] - 3s - loss: 0.2147 - acc: 0.9237 - val_loss: 0.0279 - val_acc: 1.0000\n",
"Epoch 7/10\n",
"236/236 [==============================] - 3s - loss: 0.1917 - acc: 0.9364 - val_loss: 0.0688 - val_acc: 0.9516\n",
"Epoch 8/10\n",
"236/236 [==============================] - 3s - loss: 0.1763 - acc: 0.9449 - val_loss: 0.0359 - val_acc: 0.9839\n",
"Epoch 9/10\n",
"236/236 [==============================] - 3s - loss: 0.2478 - acc: 0.9153 - val_loss: 0.0245 - val_acc: 1.0000\n",
"Epoch 10/10\n",
"236/236 [==============================] - 3s - loss: 0.1889 - acc: 0.9364 - val_loss: 0.0390 - val_acc: 0.9839\n"
]
}
],
"source": [
"vgg.fit(batches, val_batches, nb_epoch=10)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"imgs,labels = next(val_batches)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'plots' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-ecc52a7a9690>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplots\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimgs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtitles\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlabels\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'plots' is not defined"
]
}
],
"source": [
"plots(imgs, titles=labels)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
},
"nav_menu": {},
"nbpresent": {
"slides": {
"28b43202-5690-4169-9aca-6b9dabfeb3ec": {
"id": "28b43202-5690-4169-9aca-6b9dabfeb3ec",
"prev": null,
"regions": {
"3bba644a-cf4d-4a49-9fbd-e2554428cf9f": {
"attrs": {
"height": 0.8,
"width": 0.8,
"x": 0.1,
"y": 0.1
},
"content": {
"cell": "f3d3a388-7e2a-4151-9b50-c20498fceacc",
"part": "whole"
},
"id": "3bba644a-cf4d-4a49-9fbd-e2554428cf9f"
}
}
},
"8104def2-4b68-44a0-8f1b-b03bf3b2a079": {
"id": "8104def2-4b68-44a0-8f1b-b03bf3b2a079",
"prev": "28b43202-5690-4169-9aca-6b9dabfeb3ec",
"regions": {
"7dded777-1ddf-4100-99ae-25cf1c15b575": {
"attrs": {
"height": 0.8,
"width": 0.8,
"x": 0.1,
"y": 0.1
},
"content": {
"cell": "fe47bd48-3414-4657-92e7-8b8d6cb0df00",
"part": "whole"
},
"id": "7dded777-1ddf-4100-99ae-25cf1c15b575"
}
}
}
},
"themes": {}
},
"toc": {
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 6,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": false
},
"widgets": {
"state": {},
"version": "1.1.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading

0 comments on commit 05471f8

Please sign in to comment.