Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added eval ipynb #14

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: carnd-capstone
dependencies:
- jupyter
- matplotlib==2.1.2
669 changes: 669 additions & 0 deletions eval.ipynb

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions ros/src/tl_detector/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import tensorflow as tf
Copy link
Owner

@ser94mor ser94mor Jan 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is no longer exist in master. I suggest just move eval.ipynb and environment.yaml to a new branch, started from the current master branch. It seems like your branch is merged with the old SSD Classifier branch that is not currently in master.


def load_graph(graph_file):
"""Loads a frozen inference graph"""
graph = tf.Graph()
with graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(graph_file, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')

return graph
Binary file not shown.
14 changes: 14 additions & 0 deletions ros/src/tl_detector/light_classification/tl_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
from abc import ABCMeta, abstractmethod


import tensorflow as tf
from helpers import load_graph

import rospkg
import os.path as path

# Model path
r = rospkg.RosPack()
base_path = r.get_path('tl_detector')
SSD_INCEPTION_SIM = path.join(base_path,'light_classification/models/ssd_inception_v2_coco_retrained_sim/frozen_inference_graph.pb')

# Labels dictionary
labels_dict = {1: 'Green', 2: 'Red', 3: 'Yellow',4: 'Unknown'}

class TLClassifier(object):
"""
Base class for traffic light classifiers. The subclasses should provide implementations for the following methods:
Expand Down
Binary file added ros/src/tl_detector/models/ssd-sim.pb
Binary file not shown.
9 changes: 8 additions & 1 deletion ros/src/tl_detector/tl_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import tf
import yaml


class TLDetector(object):
def __init__(self):

Expand Down Expand Up @@ -97,10 +96,18 @@ def image_cb(self, msg):
:param msg: image from car-mounted camera
:type msg: Image
"""
if self.last_state == TrafficLight.RED:
# High threshold for accelerating
self.state_count_threshold = STATE_COUNT_THRESHOLD_DRIVE
else:
# Low threshold for stopping
self.state_count_threshold = STATE_COUNT_THRESHOLD_STOP

self.has_image = True
self.camera_image_msg = msg
light_wp, state = self.process_traffic_lights()


# Publish upcoming red lights at camera frequency.
# Each predicted state has to occur `self.light_classifier.get_state_count_threshold(self.last_state)` number
# of times till we start using it. Otherwise the previous stable state is used.
Expand Down