Ejemplo n.º 1
0
    def test_predictions_weak(self, client):
        picture = Picture.create(image_id='foobar.jpg')
        algorithm = Algorithm.create(name='DeevioNet', version='1.1')
        prediction = Prediction.create(picture_id=picture.id, algorithm_id=algorithm.id, proba=0.69)
        prediction = Prediction.create(picture_id=picture.id, algorithm_id=algorithm.id, proba=0.7)

        body = json.loads(client.get('/v1/predictions/weak').data)

        assert len(body) == 1
Ejemplo n.º 2
0
    def test_predictions_by_image_id(self, client):
        picture = Picture.create(image_id='foobar.jpg')
        algorithm = Algorithm.create(name='DeevioNet', version='1.1')
        prediction = Prediction.create(picture_id=picture.id, algorithm_id=algorithm.id, proba=0.99, status='complete', label='nail', result='good', bbox=[100, 200, 500, 500])

        body = json.loads(client.get('/v1/predictions/%s' % 'foobar.jpg').data)

        assert body['probability'] == prediction.proba
        assert body['status'] == prediction.status
        assert body['label'] == prediction.label
        assert body['result'] == prediction.result
        assert body['bbox'] == prediction.bbox
        assert body['algorithm']['type'] == 'GET'
        assert body['algorithm']['rel'] == 'algorithm'
        assert body['algorithm']['href'] == '/v1/algorithm/DeevioNet?version=1.1'
        assert body['picture']['type'] == 'GET'
        assert body['picture']['rel'] == 'picture'
        assert body['picture']['href'] == '/v1/picture/foobar.jpg'
Ejemplo n.º 3
0
 def test_find_by(self, image_id, image_path):
     Picture.create(image_id=image_id, image_path=image_path)
     assert Picture.find_by(image_id=image_id).image_id == image_id
Ejemplo n.º 4
0
 def test_picture_create_created_at(self):
     now = freeze_time('2018-10-11 11:26:01')
     now.start()
     assert Picture.create().created_at ==datetime.datetime(2018, 10, 11, 11, 26, 1)
     now.stop()
Ejemplo n.º 5
0
 def test_picture_create_image_path(self, image_path):
     assert Picture.create(image_path=image_path).image_path == image_path
Ejemplo n.º 6
0
 def test_picture_create_image_id(self, image_id):
     assert Picture.create(image_id=image_id).image_id == image_id
Ejemplo n.º 7
0
 def test_picture_init(self, image_id):
     assert Picture(image_id=image_id).image_id == image_id
Ejemplo n.º 8
0
 def test_get_picture(self, client):
     picture = Picture.create(image_path='20181012/foobar.jpg', image_id='foobar.jpg')
     body = json.loads(client.get('/v1/picture/%s' % picture.image_id).data)
     assert body['image_path'] == '20181012/foobar.jpg'
     assert body['image_id'] == 'foobar.jpg'
Ejemplo n.º 9
0
 def test_prediction_create_picture(self):
     picture = Picture.create()
     prediction = Prediction.create(picture_id=picture.id)
     assert prediction.picture == picture
     assert picture.predictions[-1] == prediction
Ejemplo n.º 10
0
def predictions(image_id):
    picture = Picture.find_by(image_id=image_id)
    prediction = Prediction.find_by(picture_id=picture.id)
    return jsonify(PredictionPresenter(prediction).to_dict())
Ejemplo n.º 11
0
def picture(picture_id):
    picture = Picture.find_by(image_id=picture_id)
    return jsonify(PicturePresenter(picture).to_dict())