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)
def test_unknownObject(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 self.returned = self.grounding.find_object(object_entity) self.assertEqual(self.returned.error_code, GroundingErrorType.UNKNOWN)
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)
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)
def test_learnKnownObject(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.learn_new_object(object_entity) self.assertEqual(self.returned.error_code, GroundingErrorType.ALREADY_KNOWN)