Oak Creek Valley is a very popular destination for hiking and recreation for the city of Corvallis. Accessible forests in the Oak Creek Valley include the McDonald Forest, Cardwell Hill, Fitton Green, Bald Hill Farm, and others. These natural areas are enjoyed by many for hiking, mountain biking, and more. Our project, Know Before You Go, is an Internet of Things platform with a mobile app to help park visitors determine how busy a recreation site is before they arrive. By providing park visitors with this insight, we alleviate traffic congestion at trailheads, saving park visitors time and preventing overuse of natural areas.
This repo contains all the code for running our Machine learning model. You'll find the code for the object detection in img_classifier.py and a commandline interface in detect.py. For a deeper dive into the code and how to train your own ML model check out the repo wiki, otherwise install/usage instructions are below.
There are a view dependecies that can be tricky to install. Tensorflow lite is one of them. Tested on linux, pythom 3.9
# Requires the latest pip
pip install --upgrade pip
#install cv2 for image processing
pip install opencv-python
pip install numpy
# Install tensorflow
pip install tensorflow
pip install tflite_support>=0.3.0
# install local package objdetection must clone and cd into the repo
pip install -e .To run tests, run the following command
pytest Flags
- --image # Path to .png or .jpg image
- --model # Path to model directory, should contain detect.tflite file
python detect.py --image {FULL_IMG_PATH} --model coco_ssd_mobilenet_v1_1.0_quant_2018_06_29image_classifier.py
Args
- IMG_PATH #(REQUIRED) Path to .png or .jpg image
- MODEL_NAME #(REQUIRED) Name of one of the models listed in the `obj_detection/models` directory
- MIN_CONF_LEVEL #(OPTIONAL) minimum confidence level to accept (float 0-1), default 0.5
- GRAPH_NAME #(OPTIONAL) name of .tflite file, default detect.tflite
- LABELMAP_NAME #(OPTIONAL) name of label file, default labelmap.txt
- SAVED_IMG_PATH #(OPTIONAL) Where or not to save image with detection boxes, default null
- COORDS #(OPTIONAL) Where or not to return coordinates of detect object, default False
from obj_detection import objDetection
result = objDetection(model_name, img_path)
print("Number of vehicles: ", result["vehicles"])
print("Number of pedestrians: ", result["pedestrians"])
print("Number of objects: ", result["objects"])
print("Error: ", result["error"])Distributed under the GPL-3.0 license. See LICENSE.txt for more information.
!! TODO
Your Name - @twitter_handle - email@email_client.com
