pic_scanner.api

Attributes

DEFAULT_BASE_URL

str:

Functions

provision_path(→ pathlib.Path)

Provision a path.

create_payload(image_path[, do_not_expand, ...])

Create a payload for the request.

make_request(image_path[, base_url, do_not_expand, ...])

Make a request to the inference server.

analyze_image(→ dict)

Analyze an image using the inference server.

Package Contents

pic_scanner.api.DEFAULT_BASE_URL = 'http://localhost:8080/infer'

str: The default base URL for the API.

pic_scanner.api.provision_path(path: str | pathlib.Path, do_not_expand: bool = False, do_not_resolve: bool = False, do_not_convert: bool = False) pathlib.Path

Provision a path.

Parameters:
  • path (str) – The path to provision.

  • do_not_convert (bool) – A flag indicating whether to convert the path to a string.

  • do_not_expand (bool) – A flag indicating whether to expand the path.

  • do_not_resolve (bool) – A flag indicating whether to resolve the path.

Returns:

The provisioned path.

Return type:

Path

pic_scanner.api.create_payload(image_path: str | pathlib.Path, do_not_expand: bool = False, do_not_resolve: bool = False, do_not_convert: bool = False, do_not_provision: bool = False)

Create a payload for the request.

Parameters:
  • image_path (str) – The path to the image.

  • do_not_expand (bool) – A flag indicating whether to expand the path.

  • do_not_resolve (bool) – A flag indicating whether to resolve the path.

  • do_not_convert (bool) – A flag indicating whether to convert the path to a string.

  • do_not_provision (bool)

Returns:

The payload for the request.

Return type:

dict

Raises:

ValueError – If the path is invalid.

pic_scanner.api.make_request(image_path: str | pathlib.Path, base_url: str | None = DEFAULT_BASE_URL, do_not_expand: bool = False, do_not_resolve: bool = False, do_not_convert: bool = False, do_not_provision: bool = False)

Make a request to the inference server.

Parameters:
  • image_path (Union[str, Path]) – The path to the image.

  • base_url (str) – The base URL of the inference server.

  • do_not_expand (bool) – A flag indicating whether to expand the path.

  • do_not_resolve (bool) – A flag indicating whether to resolve the path.

  • do_not_convert (bool) – A flag indicating whether to convert a string to a pathlib.Path object.

  • do_not_provision (bool) – A flag indicating whether to provision the path.

Returns:

The result of the request.

Return type:

dict

Raises:
  • requests.exceptions.HTTPError – If the request was unsuccessful.

  • ValueError – If the path is invalid.

  • FileNotFoundError – If the file does not exist.

  • PermissionError – If the file is not accessible.

  • IsADirectoryError – If the path is a directory.

pic_scanner.api.analyze_image(image_path: str | pathlib.Path, base_url: str | None = None, do_not_provision: bool = False, do_not_convert: bool = False, **kwargs) dict

Analyze an image using the inference server.

Parameters:
  • image_path (str) – The path to the image.

  • base_url (Optional[str]) – The base URL of the inference server.

  • do_not_provision (bool)

  • do_not_convert (bool)

Returns:

The result of the analysis.

Return type:

dict