예제 #1
0
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
예제 #2
0
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
예제 #3
0
    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']
예제 #4
0
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)
예제 #5
0
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'