• This repository has been archived on 31/Oct/2022
  • Stars
    star
    407
  • Rank 105,570 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

bee detection tensorflow conv net for a rasp pi on side of a hive

BNN v2

unet style image translation from image of hive entrance to bitmap of location of center of bees.

trained in a semi supervised way on a desktop gpu and deployed to run in real time on the hive using either a raspberry pi using a neural compute stick or a je vois embedded smart camera

see this blog post for more info..

here's an example of predicting bee position on some held out data. the majority of examples trained had ~10 bees per image.

rgb_labels_predictions.png

the ability to locate each bee means you can summarise with a count. note the spike around 4pm when the bees at this time of year come back to base.

counts_over_days.png

usage

see run_sample_training_pipeline.sh for an executable end to end smoke test walkthrough of these steps (using sample data)

dependencies

code depends in requirements.txt

sudo apt-get install python3-tk python3-pil python3-pil.imagetk
sudo pip3 install -r requirements.txt

gathering data

the rasp_pi sub directory includes one method of collecting images on a raspberry pi.

labelling

start by using the label_ui.py tool to manually label some images and create a sqlite label.db

the following command starts the labelling tool for some already labelled (by me!) sample data provided with in this repro.

./label_ui.py \
--image-dir sample_data/training/ \
--label-db sample_data/labels.db \
--width 768 --height 1024

hints

  • left click to label the center of a bee
  • right click to remove the closest label
  • press up to toggle labels on / off. this can help in tricky cases.
  • use left / right to move between images. it's often helpful when labelling to quickly switch back/forth between images to help distinguish background
  • use whatever system your OS provides to zoom in; e.g. in ubuntu super+up / down

you can merge entries from a.db into b.db with merge_db.py

./merge_dbs.py --from-db a.db --into-db b.db

training

before training we materialise a label.db (which is a database of x,y coords) into black and white bitmaps using ./materialise_label_db.py

./materialise_label_db.py \
--label-db sample_data/labels.db \
--directory sample_data/labels/ \
--width 768 --height 1024

we can visualise the training data with data.py. this will generate a number of test*png files with the input data on the left (with data augmentation) and the output labels on the right.

./data.py \
--image-dir sample_data/training/ \
--label-dir sample_data/labels/ \
--width 768 --height 1024

sample_data/test_002_001.png

train with train.py.

run denotes the subdirectory for ckpts and tensorboard logs; e.g. --run r12 checkpoints under ckpts/r12/ and logs under tb/r12.

use --help to get complete list of options including model config, defining validation data and stopping conditions.

e.g. to train for a short time on sample_data run the following... (for a more realistic result we'd want to train for many more steps on much more data)

./train.py \
--run r12 \
--steps 300 \
--train-steps 50 \
--train-image-dir sample_data/training/ \
--test-image-dir sample_data/test/ \
--label-dir sample_data/labels/ \
--width 768 --height 1024

progress can be visualised with tensorboard (serves at localhost:6006)

tensorboard --log-dir tb

inference

predictions can be run with predict.py. to specifiy what type of output set one of the following...

  • --output-label-db to create a label db; this can be merged with a human labelled db, using ./merge_dbs.py for semi supervised learning
  • --export-pngs centroids to export output bitmaps equivalent as those made by ./materialise_label_db.py
  • --export-pngs predictions to export explicit model output (i.e. before connected components post processing)

NOTE: given the above step that only runs a short period on a small dataset we DON'T expect this to give a great result; these instructions are more included to prove the plumbing works...

./predict.py \
--run r12 \
--image-dir sample_data/unlabelled \
--output-label-db sample_predictions.db \
--export-pngs predictions

output predictions can be compared to labelled data to calculate precision recall. (we deem a detection correct if it is within a thresholded distance from a label)

./compare_label_dbs.py --true-db ground_truth.db --predicted-db predictions.db
precision 0.936  recall 0.797  f1 0.861

running on compute stick

after loads of hacking i did eventually get this running on the compute stick. some info is included in this issue with additional background info in this forum post

[update] given how long ago this was, i'm hoping things are easier these days :D

some available datasets

More Repositories

1

resemblance

trying shingling / resemblance / simhash / sketching to do some data deduping
Ruby
98
star
2

common-crawl

playing around with the common crawl dataset
Java
70
star
3

drivebot

tensorflow deep RL for driving a rover around
Python
64
star
4

cartpoleplusplus

3d cartpole gym env using bullet physics trained from pixels with tensorflow LRPG, DDPG & NAF
Python
57
star
5

malmomo

tensorflow deep RL hacking on minecraft with malmo
Python
54
star
6

procedural_objects

blender based random procedural object generation for bullet grasping
Python
39
star
7

rnn_lm

various simple RNNs trained on synthetic grammars
Python
30
star
8

dither_net

a GAN experiment to generate dithers minimising pixel change between frames for a very slow movie player
Python
28
star
9

ros-mpu6050-node

raspberry pi c++ ROS mpu6050 IMU node
C++
23
star
10

wikipediaPhilosophy

do all first links on wikipedia _really_ lead to philosophy?
Python
22
star
11

collocations

bigram / trigram analysis of wikipedia; mainly mutual info
Python
22
star
12

tcn_grasping

pybullet grasping with time contrastive network embeddings
Jupyter Notebook
21
star
13

ros-hc-sr04-node

raspberry pi c++ ROS hc-sr04 sonar node
CMake
20
star
14

lsa

latent semantic analysis experiments
Ruby
19
star
15

common-crawl-quick-hacks

common crawl quick hack examples
Java
19
star
16

doing_bayesian_data_analysis

R
17
star
17

median

erlang experiment in distributed median finding
Erlang
17
star
18

snli_nn

hacking on the stanford natural language inference (SNLI) corpus (in theano)
Python
17
star
19

rss-feed-experiments

machine learning experiments around a bunch of rss articles
Ruby
14
star
20

farmbot_api

python api for bulk farm bed sweeps, image capture and plant detection
Python
14
star
21

movidius_minimal_example

minimal example of training tf conv net and deploying to movidius neural compute stick
Python
14
star
22

snli_nn_tf

hacking on the stanford natural language inference (SNLI) corpus (tensorflow)
Python
10
star
23

yahoo_lda_utils

some simple pre/post processing utils for yahoo lda
Python
10
star
24

semisupervised_naive_bayes

semisupervised naive bayes
Ruby
10
star
25

neural_prob_lang_model

hacky exploratory variants on NN language models
Python
9
star
26

diy_twitter_client

a simple twitter client that learns what i like to read
Ruby
9
star
27

trending

testing out some trending algorithms, mostly written in hadoop pig
Ruby
9
star
28

tgraph

mine and analyse twitter friend graph
Ruby
9
star
29

audioscrobbler-experiments

finding the shortest path from napalm death to celion dion through audioscrobbler associations
Ruby
8
star
30

movidius_bug_reports

repro cases for bugs related to NCS api
Python
8
star
31

evolved_channel_selection

rather than use all 13 channels in a multi spectral image for classification can we train a model that is robust to all combos, at all resolutions, and use a genetic algorithm to choose which are the most valuable?
Python
8
star
32

gardenhose-microslurp

bootstrap scripts for getting a micro ec2 instance piping gardenhose to s3
Shell
7
star
33

ros-motorhat-node

raspberry pi c++ ROS wrapper for adafruit motorhat
Python
7
star
34

ensemble_net

training ensembles with jax
Python
6
star
35

sip

hadoop ruby/streaming statistically improbable phrases
Ruby
6
star
36

cached_dilated_causal_convolutions

1D dilated causal convolutions with extreme caching for fast inference on a daisy patch ( cortex m7 ) or eurorack pmod ( FPGA )
Jupyter Notebook
6
star
37

bullet_grasping

hacking with the bullet grasping setup
Python
5
star
38

named-entity-extraction

proof of concept using NLTK for named entity extraction
Ruby
5
star
39

consistent_hash

afternoon hackery visualising the consistent hash method
Ruby
4
star
40

mislabelled-training-data

quick experiment on an approach to correct mislabelled data
Python
4
star
41

twitter

small scale twitter experiments
Java
3
star
42

large_batch

quick hack with global batch size of 172,000
Python
3
star
43

dets_test

testing scalability aspects of erlang dets tables
Erlang
3
star
44

text-utils

simple c++ corpus munging apps
C++
3
star
45

statistical_synonyms

statistical approache to deriving synonyms from a large corpus
Ruby
3
star
46

evolved_cartpole

evolving a gym cartpole controller; directly against bytes of a tf lite microcontroller model
Python
3
star
47

embedding-cache

local file cache over tf.hub resnet inception feature vectors
Python
3
star
48

aliens_drum_kit

building sample embeddings so we can extract a drum kit from the audio of "aliens"
Python
2
star
49

tf-icf-experiment

code for tf/icf experiment (term freq, inverse corpus freq) a system for calculating tf/icf on a stream of data
Ruby
2
star
50

connected-components

test of iterative python embedded pig
Ruby
2
star
51

burnit

the dvd packing problem
Ruby
2
star
52

pseudocounts

comparing pseudocount methods
C
2
star
53

minimal_pybullet_on_dataflow_eg

Minimal example of running Pybullet under Google Cloud Dataflow
Python
2
star
54

poi-dups

near duplicate detection (with ngram frequency weighting)
Ruby
2
star
55

nnwaveshaper

neural net waveshaper POC
C
1
star
56

tcache

memcache over disk over curl cache for twitter api calls
Ruby
1
star
57

rtw_tweet

animations of heatmaps of lat longs plucked from twitter gardenhose
Ruby
1
star
58

tweet_utils

a gemified version of my common twitter utils
Ruby
1
star
59

matpalm.github.io

HTML
1
star
60

twitter_follow_recommendations

simple collaborative filter recommendations to decide who i should follow based on the friends of my friends followers
Ruby
1
star
61

dead-simple-ga

a dead simple genetic algorithm for whietpages book club
Ruby
1
star
62

bipartite-dispersion

Python
1
star
63

random-projection

simple random projection experiments
Ruby
1
star