mediacatch 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mediacatch-0.2.0 → mediacatch-0.2.2}/PKG-INFO +1 -1
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/__init__.py +1 -1
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/speech/result.py +20 -8
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/speech/upload.py +15 -7
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/vision/upload.py +28 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/.github/workflows/check.yaml +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/.github/workflows/documentation.yaml +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/.github/workflows/publish.yaml +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/.github/workflows/test.yaml +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/.gitignore +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/README.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/assets/favicon.ico +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/assets/logo.png +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/index.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/speech.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/utils.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/vision.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/vizualization/detect.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/vizualization/face.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/vizualization/ocr.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/docs/vizualization/speech.md +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/assets/Arial.ttf +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/commands/__init__.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/commands/cli.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/commands/speech.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/commands/vision.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/commands/viz.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/speech/__init__.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/utils/__init__.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/utils/exceptions.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/utils/general.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/vision/__init__.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/vision/result.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/__init__.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/annotator.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/base_viz.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/detect.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/face.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/ocr.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mediacatch/viz/speech.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/mkdocs.yml +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/pyproject.toml +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/tests/__init__.py +0 -0
- {mediacatch-0.2.0 → mediacatch-0.2.2}/tests/test_main.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mediacatch
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Python package for easily interfacing with MediaCatch APIs and data formats.
|
|
5
5
|
Project-URL: Documentation, https://github.com/mediacatch/mediacatch#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/mediacatch/mediacatch/issues
|
|
@@ -6,6 +6,8 @@ from typing import Any
|
|
|
6
6
|
|
|
7
7
|
import requests
|
|
8
8
|
|
|
9
|
+
from mediacatch.utils import MediacatchAPIError, MediacatchError, MediacatchTimeoutError
|
|
10
|
+
|
|
9
11
|
logger = logging.getLogger('mediacatch.speech.result')
|
|
10
12
|
|
|
11
13
|
|
|
@@ -14,6 +16,7 @@ def wait_for_result(
|
|
|
14
16
|
url: str = 'https://s2t.mediacatch.io/api/v2',
|
|
15
17
|
timeout: int = 3600,
|
|
16
18
|
delay: int = 10,
|
|
19
|
+
verbose: bool = True,
|
|
17
20
|
) -> dict[str, Any] | None:
|
|
18
21
|
"""Wait for result from a URL.
|
|
19
22
|
|
|
@@ -22,33 +25,42 @@ def wait_for_result(
|
|
|
22
25
|
url (str): The URL to get the result from.
|
|
23
26
|
timeout (int, optional): Timeout for waiting in seconds. Defaults to 3600.
|
|
24
27
|
delay (int, optional): Delay between each request. Defaults to 10.
|
|
28
|
+
verbose (bool, optional): Show verbose output. Defaults to True.
|
|
25
29
|
|
|
26
30
|
Returns:
|
|
27
31
|
dict[str, Any] | None: Dictionary with the result from the URL or None if failed.
|
|
28
32
|
"""
|
|
29
33
|
result_url = f'{url}/result/{file_id}'
|
|
30
|
-
|
|
34
|
+
if verbose:
|
|
35
|
+
logger.info(f'Waiting for result from {result_url}')
|
|
31
36
|
start_time = time.time()
|
|
32
37
|
end_time = start_time + timeout
|
|
33
38
|
while time.time() < end_time:
|
|
34
39
|
try:
|
|
35
40
|
response = requests.get(result_url)
|
|
36
41
|
if response.status_code in [404, 500]:
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
if verbose:
|
|
43
|
+
pprint(response.json())
|
|
44
|
+
raise MediacatchAPIError(response.status_code, response.json())
|
|
39
45
|
|
|
40
46
|
response.raise_for_status()
|
|
41
47
|
result = response.json()
|
|
42
48
|
elapsed_time = time.time() - start_time
|
|
43
|
-
|
|
49
|
+
if verbose:
|
|
50
|
+
logger.info(f'Got result from {result_url} in {elapsed_time:.2f} seconds')
|
|
51
|
+
|
|
44
52
|
return result
|
|
45
53
|
|
|
46
54
|
except (requests.RequestException, json.JSONDecodeError):
|
|
47
55
|
time.sleep(delay)
|
|
48
56
|
|
|
49
57
|
except Exception as e:
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
if verbose:
|
|
59
|
+
logger.error(f'Failed to get result from {result_url}: {e}')
|
|
60
|
+
|
|
61
|
+
raise MediacatchError(f'Failed to get result from {result_url}: {e}')
|
|
62
|
+
|
|
63
|
+
if verbose:
|
|
64
|
+
logger.error(f'Timeout waiting for result from {result_url}, give up')
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
return None
|
|
66
|
+
raise MediacatchTimeoutError(f'Timeout waiting for result from {result_url}')
|
|
@@ -5,7 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
import requests
|
|
6
6
|
|
|
7
7
|
from mediacatch import mediacatch_api_key
|
|
8
|
-
from mediacatch.utils
|
|
8
|
+
from mediacatch.utils import MediacatchUploadError, make_request, read_file_in_chunks
|
|
9
9
|
|
|
10
10
|
logger = logging.getLogger('mediacatch.speech.upload')
|
|
11
11
|
|
|
@@ -19,6 +19,7 @@ def upload(
|
|
|
19
19
|
request_delay: float = 0.5,
|
|
20
20
|
chunk_size=100 * 1024 * 1024, # 100 MB
|
|
21
21
|
url: str = 'https://s2t.mediacatch.io/api/v2',
|
|
22
|
+
verbose: bool = True,
|
|
22
23
|
) -> str:
|
|
23
24
|
"""Uploads a file to MediaCatch Speech API.
|
|
24
25
|
|
|
@@ -30,6 +31,8 @@ def upload(
|
|
|
30
31
|
max_request_retries (int, optional): Number of maximum retries for request. Defaults to 3.
|
|
31
32
|
request_delay (float, optional): Delay between request retries. Defaults to 0.5.
|
|
32
33
|
chunk_size (_type_, optional): Size of each chunk to upload. Defaults to 100*1024*1024.
|
|
34
|
+
url (str, optional): URL of the MediaCatch Speech API. Defaults to 'https://s2t.mediacatch.io/api/v2'.
|
|
35
|
+
verbose (bool, optional): Show verbose output. Defaults to True.
|
|
33
36
|
|
|
34
37
|
Returns:
|
|
35
38
|
str: File ID of the uploaded file.
|
|
@@ -37,9 +40,11 @@ def upload(
|
|
|
37
40
|
if not isinstance(fpath, Path):
|
|
38
41
|
fpath = Path(fpath)
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
if not fpath.is_file():
|
|
44
|
+
raise MediacatchUploadError(f'File {fpath} does not exist')
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
if verbose:
|
|
47
|
+
logger.info(f'Uploading file {fpath} to MediaCatch Speech API')
|
|
43
48
|
|
|
44
49
|
headers = {
|
|
45
50
|
'Content-type': 'application/json',
|
|
@@ -99,14 +104,17 @@ def upload(
|
|
|
99
104
|
try:
|
|
100
105
|
future.result()
|
|
101
106
|
except Exception as e:
|
|
102
|
-
|
|
107
|
+
if verbose:
|
|
108
|
+
logger.error(f'Chunk {part_number} failed to upload due to: {e}')
|
|
103
109
|
|
|
104
110
|
# Complete file upload
|
|
105
111
|
complete_upload_url = f'{url}/upload/{file_id}/complete'
|
|
106
112
|
response = make_request('post', complete_upload_url, json={'parts': etags}, headers=headers)
|
|
107
113
|
estimated_processing_time = response.json()['estimated_processing_time']
|
|
108
114
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
if verbose:
|
|
116
|
+
logger.info(
|
|
117
|
+
f'File {fpath} uploaded successfully. Estimated processing time: {estimated_processing_time}'
|
|
118
|
+
)
|
|
119
|
+
|
|
112
120
|
return file_id
|
|
@@ -34,6 +34,13 @@ def upload(
|
|
|
34
34
|
max_height_width_ratio: float | None = None,
|
|
35
35
|
get_detection_histogram: bool | None = None,
|
|
36
36
|
detection_histogram_bins: int | None = None,
|
|
37
|
+
get_frame_index: bool | None = None,
|
|
38
|
+
get_bbox: bool | None = None,
|
|
39
|
+
face_recognition: bool | None = None,
|
|
40
|
+
face_age: bool | None = None,
|
|
41
|
+
face_gender: bool | None = None,
|
|
42
|
+
face_expression: bool | None = None,
|
|
43
|
+
face_ethnicity: bool | None = None,
|
|
37
44
|
max_retries: int = 5,
|
|
38
45
|
delay: float = 10.0,
|
|
39
46
|
verbose: bool = True,
|
|
@@ -55,6 +62,13 @@ def upload(
|
|
|
55
62
|
max_height_width_ratio (float, optional): Discard detection if height/width ratio is greater than this value. Defaults to 2.0.
|
|
56
63
|
get_detection_histogram (bool, optional): If true, get histogram of detection. Defaults to False.
|
|
57
64
|
detection_histogram_bins (int, optional): Number of bins for histogram calculation. Defaults to 8.
|
|
65
|
+
get_frame_index (bool, optional): If true, get frame index. Defaults to None.
|
|
66
|
+
get_bbox (bool, optional): If true, get bounding box. Defaults to None.
|
|
67
|
+
face_recognition (bool, optional): If true, run face recognition. Defaults to None.
|
|
68
|
+
face_age (bool, optional): If true, get face age. Defaults to None.
|
|
69
|
+
face_gender (bool, optional): If true, get face gender. Defaults to None.
|
|
70
|
+
face_expression (bool, optional): If true, get face expression. Defaults to None.
|
|
71
|
+
face_ethnicity (bool, optional): If true, get face ethnicity. Defaults to None.
|
|
58
72
|
max_retries (int, optional): Maximum number of retries. Defaults to 5.
|
|
59
73
|
delay (float, optional): Delay between retries. Defaults to 10.0.
|
|
60
74
|
verbose (bool, optional): If True, print log messages. Defaults to True.
|
|
@@ -88,6 +102,20 @@ def upload(
|
|
|
88
102
|
extra['get_detection_histogram'] = get_detection_histogram
|
|
89
103
|
if detection_histogram_bins is not None:
|
|
90
104
|
extra['detection_histogram_bins'] = detection_histogram_bins
|
|
105
|
+
if get_frame_index is not None:
|
|
106
|
+
extra['frame'] = get_frame_index
|
|
107
|
+
if get_bbox is not None:
|
|
108
|
+
extra['bbox'] = get_bbox
|
|
109
|
+
if face_recognition is not None:
|
|
110
|
+
extra['recognition'] = face_recognition
|
|
111
|
+
if face_age is not None:
|
|
112
|
+
extra['age'] = face_age
|
|
113
|
+
if face_gender is not None:
|
|
114
|
+
extra['gender'] = face_gender
|
|
115
|
+
if face_expression is not None:
|
|
116
|
+
extra['expression'] = face_expression
|
|
117
|
+
if face_ethnicity is not None:
|
|
118
|
+
extra['ethnicity'] = face_ethnicity
|
|
91
119
|
|
|
92
120
|
# Get presigned URL
|
|
93
121
|
data = {'filename': fpath, 'type': type, 'extra': extra}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|