Exemplo n.º 1
0
def test_get_model_by_task():
    models = ModelService.get_models_by_task(Task.IMAGE_CLASSIFICATION)

    # check length
    assert len(models) == 1
    # check name
    for model in models:
        assert model.task == Task.IMAGE_CLASSIFICATION
Exemplo n.º 2
0
def test_get_model_by_task():
    models = ModelService.get_models_by_task('image classification')

    # check length
    assert len(models) == 1
    # check name
    for model in models:
        assert model.task == 'image classification'
Exemplo n.º 3
0
def retrieve_model_by_task(task='image classification') -> ModelBO:
    """Query a model by task.
    This function will download a cache model from the model DB.
    Arguments:
        task (str): Task name. Default to "image classification"
    Returns:
        ModelBo: Model business object.
    """
    # retrieve
    models = ModelService.get_models_by_task(task)
    # check if found
    if len(models) == 0:
        raise FileNotFoundError('Model not found!')
    model = models[0]

    get_remote_model_weight(model)

    return model
Exemplo n.º 4
0
def retrieve_model_by_task(task: Task) -> List[ModelBO]:
    """Query a model by task.
    This function will download a cache model from the model DB.

    Arguments:
        task (Task): Task name the model is used for.

    Returns:
        List[ModelBO]: A list of model business object.
    """
    # retrieve
    models = ModelService.get_models_by_task(task)
    # check if found
    if len(models) == 0:
        raise FileNotFoundError('Model not found!')

    _get_remote_model_weights(models)

    return models