Exemplo n.º 1
0
 def test_learnKnownObject(self):
     self.db_mock.get_feature = Mock(return_value=123)
     object_name = "green cover"
     object_spatial_desc = None
     object_entity = ObjectEntity()
     object_entity.name = object_name
     object_entity.spatial_descriptions = object_spatial_desc
     self.returned = self.grounding.learn_new_object(object_entity)
     self.assertEqual(self.returned.error_code,
                      GroundingErrorType.ALREADY_KNOWN)
Exemplo n.º 2
0
 def test_updateUnknownObject(self):
     object_info = ObjectInfoWithFeatures()
     features = []
     object_info.features = np.array([1, 1, 1, 1, 1])
     object_info.bbox_xxyy = np.array([1, 2, 3, 4])
     object_info.mask_full = np.array([4, 3, 2, 1])
     object_info.mask_cropped = np.array([5, 5, 5, 5])
     features.append(object_info)
     self.vision_mock.get_masks_with_features = Mock(return_value=features)
     object_name = "albert is cool"
     object_spatial_desc = None
     object_entity = ObjectEntity()
     object_entity.name = object_name
     object_entity.spatial_descriptions = object_spatial_desc
     self.returned = self.grounding.update_features(object_entity)
     self.assertEqual(self.returned.error_code, GroundingErrorType.UNKNOWN)
Exemplo n.º 3
0
 def test_updateCorrectObject(self):
     object_info = ObjectInfoWithFeatures()
     features = []
     object_info.features = np.array([1, 1, 1, 1, 1])
     object_info.bbox_xxyy = np.array([1, 2, 3, 4])
     object_info.mask_full = np.array([4, 3, 2, 1])
     object_info.mask_cropped = np.array([5, 5, 5, 5])
     features.append(object_info)
     self.vision_mock.get_masks_with_features = Mock(return_value=features)
     object_name = "black cover"
     object_spatial_desc = None
     object_entity = ObjectEntity()
     object_entity.name = object_name
     object_entity.spatial_descriptions = object_spatial_desc
     self.returned = self.grounding.update_features(object_entity)
     self.assertTrue(self.returned.is_success)
Exemplo n.º 4
0
 def test_newObject(self):
     object_info = ObjectInfoWithFeatures()
     features = []
     object_info.features = np.array([1, 1, 1, 1, 1])
     object_info.bbox_xxyy = np.array([1, 2, 3, 4])
     object_info.mask_full = np.array([4, 3, 2, 1])
     object_info.mask_cropped = np.array([5, 5, 5, 5])
     features.append(object_info)
     self.vision_mock.get_masks_with_features = Mock(return_value=features)
     entity_name = "green cover"  # Make sure this is a new object.
     spatial_desc = None
     object_entity = ObjectEntity()
     object_entity.name = entity_name
     object_entity.spatial_descriptions = spatial_desc
     self.returned = self.grounding.learn_new_object(object_entity)
     self.assertTrue(self.returned.is_success)
Exemplo n.º 5
0
 def test_failFindObject(self):
     object_info = ObjectInfoWithFeatures()
     features = []
     object_info.features = np.array([1, 1, 1, 1, 1])
     object_info.bbox_xxyy = np.array([1, 2, 3, 4])
     object_info.mask_full = np.array([4, 3, 2, 1])
     object_info.mask_cropped = np.array([5, 5, 5, 5])
     features.append(object_info)
     self.vision_mock.get_masks_with_features = Mock(return_value=features)
     object_name = "blue cover"
     object_spatial_desc = None
     object_entity = ObjectEntity()
     object_entity.name = object_name
     object_entity.spatial_descriptions = object_spatial_desc
     self.returned = self.grounding.find_object(object_entity)
     self.assertEqual(self.returned.error_code,
                      GroundingErrorType.CANT_FIND)