Skip to content

Commit

Permalink
package renamed to tensorflow_node
Browse files Browse the repository at this point in the history
  • Loading branch information
elggem committed Feb 14, 2017
1 parent 5cf654d commit f7cd8ee
Show file tree
Hide file tree
Showing 28 changed files with 51 additions and 50 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.3)
project(ros_destin)
project(tensorflow_node)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
Expand All @@ -16,8 +16,8 @@ catkin_python_setup()
## Generate messages in the 'msg' folder
add_message_files(
FILES
DestinNodeState.msg
DestinStatus.msg
TFNodeState.msg
TFStatus.msg
)

## Generate services in the 'srv' folder
Expand Down Expand Up @@ -90,4 +90,4 @@ install(PROGRAMS
#############

## Add folders to be run by python nosetests
catkin_add_nosetests(src/destin/tests)
catkin_add_nosetests(src/tensorflow_node/tests)
2 changes: 1 addition & 1 deletion config/small-ae-destin.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
destin:
tensorflow_node:
inputlayer:
type: OpenCVInputLayer
params:
Expand Down
2 changes: 1 addition & 1 deletion launch/mnist.launch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<launch>
<!-- Destin Configuration -->
<rosparam command="load" file="$(find ros_destin)/config/small-ae-destin.yaml" />
<node name="destin" pkg="ros_destin" type="daemon" output="screen" />
<node name="tf_node" pkg="tensorflow_node" type="daemon" output="screen" />
</launch>
2 changes: 1 addition & 1 deletion msg/DestinNodeState.msg → msg/TFNodeState.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DestinNodeState.msg
# TFNodeState.msg
Header header
string id # might be 'ae-e239j0-1-3-2'
string type # might be 'autoencoder'
Expand Down
2 changes: 1 addition & 1 deletion msg/DestinStatus.msg → msg/TFStatus.msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DestinStatus.msg
# TFStatus.msg
Header header
string id # might be 'chest_camera'
bool running
Expand Down
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<package format="2">
<name>ros_destin</name>
<name>tensorflow_node</name>
<version>0.0.1</version>
<description>Tensorflow implementation of DeSTIN</description>
<description>Persistent Tensorflow node</description>
<maintainer email="[email protected]">Ralf Mayet</maintainer>
<license>Unlicense</license>

Expand Down
32 changes: 15 additions & 17 deletions scripts/daemon
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,46 @@ import rospy
import tensorflow as tf
import numpy as np

from destin import *
from tensorflow_node import *

from std_msgs.msg import Header
from ros_destin.msg import DestinNodeState
from tensorflow_node.msg import TFNodeState

def str_to_class(str):
return getattr(sys.modules[__name__], str)

with tf.Session() as sess:
# initialize ROS node
rospy.init_node('destin', anonymous=False, log_level=rospy.INFO)
rospy.loginfo("Destin ROS node launching")
rospy.init_node('tensorflow_daemon', anonymous=False, log_level=rospy.INFO)
rospy.loginfo("Tensorflow daemon ROS node launching")

# TODO Assertions:
# - inputlayer size and receptive field / stride fit together...
# - ...?
config_prefix = "tensorflow_node"

# initialize input layer from yaml
inputlayer_type = rospy.get_param("destin/inputlayer/type")
inputlayer_type = rospy.get_param(config_prefix+"/inputlayer/type")
inputlayer_class = str_to_class(inputlayer_type)
inputlayer_params = rospy.get_param("destin/inputlayer/params")
inputlayer_params = rospy.get_param(config_prefix+"/inputlayer/params")
inputlayer = inputlayer_class(**inputlayer_params)

# initialize network from yaml
architecture_type = rospy.get_param("destin/architecture/type")
architecture_type = rospy.get_param(config_prefix+"/architecture/type")
architecture_class = str_to_class(architecture_type)
architecture_params = rospy.get_param("destin/architecture/params")
architecture_params = rospy.get_param(config_prefix+"/architecture/params")
architecture = architecture_class(sess, inputlayer, **architecture_params)

# initialize summary writer
if (rospy.get_param("destin/publishing/summaries")):
if (rospy.get_param(config_prefix+"/publishing/summaries")):
rospy.loginfo("recording summaries to " + SummaryWriter().get_summary_folder())
# initialize summary writer with graph
SummaryWriter().writer.add_graph(sess.graph)
merged_summary_op = tf.merge_all_summaries()

# initialize publishers for network
publishers = {}
topic_name = rospy.get_param("destin/publishing/topic")
queue_size = rospy.get_param("/destin/inputlayer/params/batch_size")
topic_name = rospy.get_param(config_prefix+"/publishing/topic")
queue_size = rospy.get_param(config_prefix+"/inputlayer/params/batch_size")
for node in architecture.nodes:
publishers[node.name] = rospy.Publisher('/'+topic_name+'/'+node.name, DestinNodeState, queue_size=queue_size)
publishers[node.name] = rospy.Publisher('/'+topic_name+'/'+node.name, TFNodeState, queue_size=queue_size)

# main callback to evaluate architecture and publish states
iteration = 0
Expand All @@ -67,7 +65,7 @@ with tf.Session() as sess:

for state in ae_state:
# formulate message
msg = DestinNodeState()
msg = TFNodeState()

msg.header = Header()
msg.header.stamp = rospy.Time.now()
Expand All @@ -80,7 +78,7 @@ with tf.Session() as sess:
publishers[node.name].publish(msg)

# publish summary output
if (rospy.get_param("destin/publishing/summaries")):
if (rospy.get_param(config_prefix+"/publishing/summaries")):
summary_str = merged_summary_op.eval(feed_dict=feed_dict, session=sess)
SummaryWriter().writer.add_summary(summary_str, iteration)
SummaryWriter().writer.flush()
Expand Down
2 changes: 1 addition & 1 deletion scripts/tensorboard
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

tensorboard --logdir=runs:`rosparam get destin/publishing/summary_folder` --port 6006 --reload_interval 5
tensorboard --logdir=runs:`rosparam get tensorflow_node/publishing/summary_folder` --port 6006 --reload_interval 5
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
packages=['destin'],
packages=['tensorflow_node'],
package_dir={'': 'src'}
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .architecture import NetworkArchitecture
from .destin_arch import DestinArchitecture
from .destin import DestinArchitecture
from .handcoded_destin import HandcodedDestinArchitecture
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import rospy
import tensorflow as tf

from destin.nodes import *
from tensorflow_node.nodes import *

class NetworkArchitecture(object):
__metaclass__ = abc.ABCMeta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import tensorflow as tf
import numpy as np

from destin.nodes import *
from destin.architectures import NetworkArchitecture
from tensorflow_node.nodes import *
from tensorflow_node.architectures import NetworkArchitecture

class DestinArchitecture(NetworkArchitecture):

def __init__(self, session, inputlayer, node_type, node_params, receptive_field=[14,14], stride=[7,7]):

# TODO Assertions:
# - inputlayer size and receptive field / stride fit together...
# - ...?

self.nodes = []
self.train_op = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import rospy
import tensorflow as tf

from destin.architectures import NetworkArchitecture
from tensorflow_node.architectures import NetworkArchitecture

class HandcodedDestinArchitecture(NetworkArchitecture):

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os.path
import rospy

from destin.input import InputLayer
from tensorflow_node.input import InputLayer


class OpenCVInputLayer(InputLayer):
Expand All @@ -22,8 +22,8 @@ def __init__(self, batch_size=1, output_size=[28, 28], input="", number_of_frame
def feed_to(self, feed_callback):

# TODO: there should be clearer distinction here, get these params via daemon.
frames = rospy.get_param("/destin/inputlayer/params/number_of_frames")
repeat = rospy.get_param("/destin/inputlayer/params/repeat")
frames = rospy.get_param("tensorflow_node/inputlayer/params/number_of_frames")
repeat = rospy.get_param("tensorflow_node/inputlayer/params/repeat")

# check if file exists
if not os.path.isfile(self.input) or self.input == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os.path
from skimage import transform

from destin.input import InputLayer
from tensorflow_node.input import InputLayer

from sensor_msgs.msg import Image

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import rospy

from destin import SummaryWriter
from tensorflow_node import SummaryWriter


class AutoEncoderNode(object):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import tensorflow as tf
import numpy as np

from destin import AutoEncoderNode
from destin import SummaryWriter
from destin import OpenCVInputLayer
from tensorflow_node import AutoEncoderNode
from tensorflow_node import SummaryWriter
from tensorflow_node import OpenCVInputLayer


# this tests very basic functionality of the autoencoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import tensorflow as tf
import numpy as np

from destin import AutoEncoderNode
from destin import SummaryWriter
from destin import OpenCVInputLayer
from tensorflow_node import AutoEncoderNode
from tensorflow_node import SummaryWriter
from tensorflow_node import OpenCVInputLayer


# this tests the cropping of the input layer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import tensorflow as tf
import numpy as np

from destin import StackedAutoEncoderNode
from destin import SummaryWriter
from destin import OpenCVInputLayer
from tensorflow_node import StackedAutoEncoderNode
from tensorflow_node import SummaryWriter
from tensorflow_node import OpenCVInputLayer


# this tests very basic functionality of the stacked autoencoder
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):

def get_output_folder(self, path):
#output_path = pjoin(os.getcwd(), 'output', path)
output_path = rospy.get_param("destin/publishing/summary_folder")
output_path = rospy.get_param("tensorflow_node/publishing/summary_folder")
if not os.path.exists(output_path):
os.makedirs(output_path)
return output_path
Expand Down
File renamed without changes.

0 comments on commit f7cd8ee

Please sign in to comment.