Skip to content

Instantly share code, notes, and snippets.

View tawnkramer's full-sized avatar

Tawn Kramer tawnkramer

  • San Diego, CA
View GitHub Profile
'''
from the CarND-Alexnet-Feature-Extraction project
https://github.com/udacity/CarND-Alexnet-Feature-Extraction
This is modified to set the number of classes dynamically from the loaded data.
'''
import pickle
import time
import tensorflow as tf
from sklearn.model_selection import train_test_split
'''
Author: Tawn Kramer
Date: June 22, 2017
Brief:
This will crop the set of images in a LISA sign data set, resize to a constant dimension,
and save out a pickle file. You can download the data here:
http://cvrr.ucsd.edu/LISA/lisa-traffic-sign-dataset.html
The output of this data set is a pickle file. Consideering the output is 15Mb while the input is 7GB,
@tawnkramer
tawnkramer / img_fifo.py
Last active September 12, 2017 16:14
A FIFO of N previous images into a single N channel image, after converting each to grayscale.
class ImgFIFO:
"""
Stack N previous images into a single N channel image, after converting each to grayscale.
The most recent image is the last channel, and pushes previous images towards the front.
"""
def __init__(self, num_channels=3):
self.img_arr = None
self.num_channels = num_channels
def run(self, img_arr):

on your pi

wget https://raw.githubusercontent.com/tawnkramer/donkey/dev-mainline/donkeycar/parts/controllers/joystick.py
cp joystick.py ~/d2/

now edit ~/d2/manage.py

near the top, add a

import os
import sys
import glob
import json
import shutil
def go(src_path, dest_path):
print('adding tub', src_path, 'to', dest_path)
src_files = glob.glob(os.path.join(src_path, '*.jpg'))
dest_files = glob.glob(os.path.join(dest_path, '*.jpg'))
def imu_rnn_lstm(seq_length, num_outputs, imu_vec_size=6):
from keras.layers import Input, Dense
from keras.models import Model
from keras.layers import Convolution2D, MaxPooling2D, Reshape, BatchNormalization
from keras.layers import Activation, Dropout, Flatten, Cropping2D, Lambda
from keras.layers.merge import concatenate
from keras.layers import LSTM
img_in = Input(batch_shape=(seq_length, 120,160,3), name='img_in')
imu_in = Input(batch_shape=(seq_length, imu_vec_size), name="imu_in")
@tawnkramer
tawnkramer / train.py
Last active November 28, 2017 19:50
Script to train a keras model. Uses the data written by the donkey v2.2 tub writer, but faster training with proper sampling of distribution over tubs. You can drop this in your ~/d2 dir. Basic usage should feel familiar: python train.py --model models/mypilot
#!/usr/bin/env python3
"""
Scripts to train a keras model using tensorflow.
Uses the data written by the donkey v2.2 tub writer,
but faster training with proper sampling of distribution over tubs.
Has settings for continuous training that will look for new files as it trains.
Modify send_model_to_pi is you wish continuous training to update your pi as it builds.
You can drop this in your ~/d2 dir.
Basic usage should feel familiar: python train.py --model models/mypilot
You might need to do a: pip install scikit-learn
'''
# Install and setup:
# sudo update && sudo apt install pigpio python3-pigpio
# sudo systemctl start pigpiod
'''
import os
import donkeycar as dk
from donkeycar.parts.controller import PS3JoystickController
from donkeycar.parts.actuator import PWMSteering, PWMThrottle
adapted from http://wiki.tekkotsu.org/index.php/Sony_PlayStation_Eye_driver_install_instructions
sudo -s
cd /usr/src
apt-get update
apt-get install -y build-essential kernel-package linux-source libssl-dev
tar --bzip2 -xvf linux-source-*.tar.bz2
ln -s `find . -maxdepth 1 -type d -name "linux-source-*"` linux
#PS3 Eye Drivers
@tawnkramer
tawnkramer / intel path follow redme.txt
Last active April 25, 2019 03:29
Intel RealSense T265 Path follower on Donkey
Setup on the pi:
git clone https://github.com/tawnkramer/donkey donkey_tkramer
cd donkey_tkramer
git checkout dev
pip3 uninstall donkeycar
pip3 install .[pi]
donkey createcar --path ~/follow --template path_follower
cd ~/follow
python3 manage.py drive