def test_post_get_image_success(): test_image_bytes = make_test_image_bytes() image_id = image_storage.post_image(image_storage.ISO, "ds-id", test_image_bytes) fetched_image_bytes = image_storage.get_image(image_storage.ISO, "ds-id", image_id) assert fetched_image_bytes == test_image_bytes
def _annotation_image_shape(db, ds): logger.debug(f'Querying annotation image shape for "{ds.id}" dataset') ion_img_id = db.select(IMG_URLS_BY_ID_SEL + ' LIMIT 1', params=(ds.id, ))[0][0][0] image_bytes = image_storage.get_image(image_storage.ISO, ds.id, ion_img_id) image = Image.open(io.BytesIO(image_bytes)) result = image.size logger.debug(f'Annotation image shape for "{ds.id}" dataset is {result}') return result
def classify(chunk): logger.debug(f'Classifying chunk of {len(chunk)} images') base64_images = [] for img_id in chunk: img_bytes = image_storage.get_image(image_storage.ISO, ds_id, img_id) img_base64 = base64.b64encode(img_bytes).decode() base64_images.append(img_base64) images_doc = base64_images_to_doc(base64_images) pred_doc = call_api(api_endpoint + '/predict', doc=images_doc) return pred_doc['predictions']
def load_npy_image(ds_id: str, image_id: str): buf = image_storage.get_image(image_storage.DIAG, ds_id, image_id) return np.load(BytesIO(buf), allow_pickle=False)
def assert_no_image(image_id): try: image_storage.get_image(image_storage.ISO, "ds-id", image_id) except botocore.exceptions.ClientError as error: assert error.response['Error']['Code'] == 'NoSuchKey'