class TestSpatialPrediction(unittest.TestCase): def setUp(self): rospy.loginfo("Initializing test for spatial predictions") self.model = ImageLocationLearner() self.model.load_models("/ros/catkin_ws/src/hrc_discrim_learning/model/spatial_regressors") def test_prediction(self): features = { "location": [1, .2, .2], "orientation": [0, 0, 0, 0], "description" : "right" } obj_file = "/ros/catkin_ws/src/hrc_discrim_learning/train/objects.json" with open(obj_file, 'r') as f: obj_dict = json.load(f) all_objs = [Object(x) for id, x in obj_dict.items()] context = AdaptiveContext(all_objs) for o in all_objs: self.assertEqual(o.get_feature_class_value('description'), self.model.predict(o, context))
def setUp(self): print() print("-----------Testing SGD selection--------------") loc_model = ImageLocationLearner() loc_model.load_models( "/ros/catkin_ws/src/hrc_discrim_learning/model/spatial") features_ordered = ['size_relative', 'color', 'material', 'location'] self.m = SGDPrimeSelector(features_ordered, loc_model, 0, 0)
def setUp(self): print() print("-----------Testing FullBrevity selection--------------") loc_model = ImageLocationLearner() loc_model.load_models( "/ros/catkin_ws/src/hrc_discrim_learning/model/spatial") rank = ['color', 'material', 'size_relative', 'location'] self.m = FullBrevSelector(rank, loc_model, 0, 0)
def setUp(self): rospy.loginfo("Initializing test for spatial predictions") self.model = ImageLocationLearner() self.model.load_models("/ros/catkin_ws/src/hrc_discrim_learning/model/spatial_regressors")
# from hrc_discrim_learning.feature_learning import IncrementalLearner from hrc_discrim_learning.sgd_learner import SGDPrimeSelector from hrc_discrim_learning.spatial_learning import ImageLocationLearner # if __name__ == "__main__": # spatial_model_dest = rospy.get_param("hrc_discrim_learning/spatial_model") # loc_model = ImageLocationLearner() # loc_model.load_models(spatial_model_dest) # # feat_learner = IncrementalLearner(loc_model) # # all_learners = [feat_learner] # # t = TrainHarness('train_feature', '/train_input_provider', all_learners, 'feature') # t.run_training() if __name__ == "__main__": spatial_model_dest = rospy.get_param("hrc_discrim_learning/spatial_model") loc_model = ImageLocationLearner() loc_model.load_models(spatial_model_dest) rank = ['size_relative', 'color', 'material', 'location'] feat_learner = SGDPrimeSelector(rank, loc_model, 0, 0) all_learners = [feat_learner] t = TrainHarness('train_feature', '/train_input_provider', all_learners, 'feature') t.run_training()
#!/usr/bin/env python from hrc_discrim_learning.spatial_learning import ImageLocationLearner, ObjectLocationLearner from hrc_discrim_learning.trainer_common import TrainHarness import rospy if __name__ == '__main__': l1 = ImageLocationLearner() # l2 = ObjectLocationLearner() all_learners = [l1] t = TrainHarness('train_spatial', '/train_input_provider', all_learners, 'spatial') t.run_training()