Пример #1
0
async def _predict_async_post(
    data: Data,
    job_id: str,
    background_tasks: BackgroundTasks = BackgroundTasks()
) -> Dict[str, List[float]]:
    image = base64.b64decode(str(data.image_data))
    io_bytes = io.BytesIO(image)
    data.image_data = Image.open(io_bytes)
    store_data_job._save_data_job(data, job_id, background_tasks, True)
    return {'job_id': job_id}
Пример #2
0
async def _predict_label(
    data: Data,
    job_id: str,
    background_tasks: BackgroundTasks = BackgroundTasks()
) -> Dict[str, List[float]]:
    image = base64.b64decode(str(data.image_data))
    io_bytes = io.BytesIO(image)
    data.image_data = Image.open(io_bytes)
    label_proba = await __async_predict_label(data)
    store_data_job._save_data_job(data, job_id, background_tasks, False)
    return {'prediction': label_proba, 'job_id': job_id}
Пример #3
0
async def _test_label(data: Data = Data()) -> Dict[str, Dict[str, float]]:
    data.image_data = data.test_data
    label_proba = __predict_label(data)
    return {'prediction': label_proba}
Пример #4
0
async def _test(data: Data = Data()) -> Dict[str, int]:
    data.image_data = data.test_data
    __predict(data)
    return {'prediction': data.prediction}