-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): adapt openAPI "getStatistics"
- Loading branch information
Showing
9 changed files
with
265 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ tensorbay.client | |
version | ||
diff | ||
profile | ||
statistics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
tensorbay.client.statistics | ||
=========================== | ||
|
||
.. automodule:: tensorbay.client.statistics | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
###################### | ||
Get Label Statistics | ||
###################### | ||
|
||
This topic describes the get label statistics operation. | ||
|
||
Label statistics of dataset could be obtained via :func:`~tensorbay.client.dataset.DatasetClientBase.get_label_statistics` | ||
as follows: | ||
|
||
>>> from tensorbay import GAS | ||
>>> ACCESS_KEY = "Accesskey-*****" | ||
>>> gas = GAS(ACCESS_KEY) | ||
>>> dataset_client = gas.get_dataset("targetDataset") | ||
>>> statistics = dataset_client.get_label_statistics() | ||
>>> statistics | ||
Statistics { | ||
'BOX2D': {...}, | ||
'BOX3D': {...}, | ||
'KEYPOINTS2D': {...} | ||
} | ||
|
||
The details of the statistics structure for the targetDataset are as follows: | ||
|
||
.. code-block:: json | ||
{ | ||
"BOX2D": { | ||
"quantity": 1508722, | ||
"categories": [ | ||
{ | ||
"name": "vehicle.bike", | ||
"quantity": 8425, | ||
"attributes": [ | ||
{ | ||
"name": "trafficLightColor", | ||
"enum": ["none", "red", "yellow"], | ||
"quantities": [8420, 3, 2] | ||
} | ||
] | ||
} | ||
], | ||
"attributes": [ | ||
{ | ||
"name": "trafficLightColor", | ||
"enum": ["none", "red", "yellow", "green"], | ||
"quantities": [1356224, 54481, 4107, 93910] | ||
} | ||
] | ||
}, | ||
"BOX3D": { | ||
"quantity": 1234 | ||
}, | ||
"KEYPOINTS2D":{ | ||
"quantity": 43234, | ||
"categories":[ | ||
{ | ||
"name": "person.person", | ||
"quantity": 43234 | ||
} | ||
] | ||
} | ||
} | ||
.. note:: | ||
The method :func:`~tensorbay.client.statistics.Statistics.dumps` of :class:`~tensorbay.client.statistics.Statistics` can dump the statistics into a dict. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright 2021 Graviti. Licensed under MIT License. | ||
# | ||
|
||
"""Class Statistics. | ||
:class:`Statistics` defines the basic structure of the label statistics obtained by | ||
:meth:`DatasetClientBase.get_label_statistics`. | ||
""" | ||
from typing import Any, Dict | ||
|
||
from ..utility import UserMapping | ||
|
||
|
||
class Statistics(UserMapping[str, Any]): # pylint: disable=too-many-ancestors | ||
"""This class defines the basic structure of the label statistics. | ||
Arguments: | ||
data: The dict containing label statistics. | ||
""" | ||
|
||
def __init__(self, data: Dict[str, Any]) -> None: | ||
self._data: Dict[str, Any] = data | ||
|
||
def dumps(self) -> Dict[str, Any]: | ||
"""Dumps the label statistics into a dict. | ||
Returns: | ||
A dict containing all the information of the label statistics. | ||
Examples: | ||
>>> label_statistics = Statistics( | ||
... { | ||
... 'BOX3D': { | ||
... 'quantity': 1234 | ||
... }, | ||
... 'KEYPOINTS2D': { | ||
... 'quantity': 43234, | ||
... 'categories': [ | ||
... { | ||
... 'name': 'person.person', | ||
... 'quantity': 43234 | ||
... } | ||
... ] | ||
... } | ||
... } | ||
... ) | ||
>>> label_statistics.dumps() | ||
... { | ||
... 'BOX3D': { | ||
... 'quantity': 1234 | ||
... }, | ||
... 'KEYPOINTS2D': { | ||
... 'quantity': 43234, | ||
... 'categories': [ | ||
... { | ||
... 'name': 'person.person', | ||
... 'quantity': 43234 | ||
... } | ||
... ] | ||
... } | ||
... } | ||
""" | ||
return self._data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters