mediacatch 0.2.2__tar.gz → 0.2.4__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.
Files changed (45) hide show
  1. {mediacatch-0.2.2 → mediacatch-0.2.4}/PKG-INFO +17 -7
  2. {mediacatch-0.2.2 → mediacatch-0.2.4}/README.md +14 -2
  3. mediacatch-0.2.4/docs/assets/mc_logo.svg +21 -0
  4. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/__init__.py +1 -1
  5. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/commands/vision.py +20 -0
  6. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/speech/result.py +4 -1
  7. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/vision/result.py +21 -2
  8. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/vision/upload.py +8 -0
  9. {mediacatch-0.2.2 → mediacatch-0.2.4}/pyproject.toml +2 -5
  10. {mediacatch-0.2.2 → mediacatch-0.2.4}/.github/workflows/check.yaml +0 -0
  11. {mediacatch-0.2.2 → mediacatch-0.2.4}/.github/workflows/documentation.yaml +0 -0
  12. {mediacatch-0.2.2 → mediacatch-0.2.4}/.github/workflows/publish.yaml +0 -0
  13. {mediacatch-0.2.2 → mediacatch-0.2.4}/.github/workflows/test.yaml +0 -0
  14. {mediacatch-0.2.2 → mediacatch-0.2.4}/.gitignore +0 -0
  15. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/assets/favicon.ico +0 -0
  16. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/assets/logo.png +0 -0
  17. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/index.md +0 -0
  18. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/speech.md +0 -0
  19. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/utils.md +0 -0
  20. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/vision.md +0 -0
  21. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/vizualization/detect.md +0 -0
  22. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/vizualization/face.md +0 -0
  23. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/vizualization/ocr.md +0 -0
  24. {mediacatch-0.2.2 → mediacatch-0.2.4}/docs/vizualization/speech.md +0 -0
  25. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/assets/Arial.ttf +0 -0
  26. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/commands/__init__.py +0 -0
  27. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/commands/cli.py +0 -0
  28. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/commands/speech.py +0 -0
  29. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/commands/viz.py +0 -0
  30. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/speech/__init__.py +0 -0
  31. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/speech/upload.py +0 -0
  32. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/utils/__init__.py +0 -0
  33. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/utils/exceptions.py +0 -0
  34. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/utils/general.py +0 -0
  35. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/vision/__init__.py +0 -0
  36. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/__init__.py +0 -0
  37. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/annotator.py +0 -0
  38. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/base_viz.py +0 -0
  39. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/detect.py +0 -0
  40. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/face.py +0 -0
  41. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/ocr.py +0 -0
  42. {mediacatch-0.2.2 → mediacatch-0.2.4}/mediacatch/viz/speech.py +0 -0
  43. {mediacatch-0.2.2 → mediacatch-0.2.4}/mkdocs.yml +0 -0
  44. {mediacatch-0.2.2 → mediacatch-0.2.4}/tests/__init__.py +0 -0
  45. {mediacatch-0.2.2 → mediacatch-0.2.4}/tests/test_main.py +0 -0
@@ -1,11 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mediacatch
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Python package for easily interfacing with MediaCatch APIs and data formats.
5
- Project-URL: Documentation, https://github.com/mediacatch/mediacatch#readme
6
- Project-URL: Issues, https://github.com/mediacatch/mediacatch/issues
7
- Project-URL: Source, https://github.com/mediacatch/mediacatch
8
- Author-email: Mathias Nielsen <mathias@mediacatch.io>, Frederik Haarslev <frederik@mediacatch.io>
5
+ Project-URL: Documentation, https://api.mediacatch.io/mediacatch/docs/
6
+ Author-email: Mathias Nielsen <mathias@mediacatch.io>
9
7
  License-Expression: MIT
10
8
  Classifier: Framework :: FastAPI
11
9
  Classifier: Intended Audience :: Developers
@@ -49,13 +47,25 @@ Requires-Dist: pytest-cov; extra == 'test'
49
47
  Requires-Dist: ruff; extra == 'test'
50
48
  Description-Content-Type: text/markdown
51
49
 
50
+ <div align="center">
51
+
52
+ [<img src="docs/assets/mc_logo.svg" alt="mc-logo" width=400>](https://api.mediacatch.io/mediacatch/docs/)<br>
53
+
52
54
  [![Unit Tests](https://github.com/mediacatch/mediacatch/actions/workflows/test.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/test.yaml)
53
55
  [![codecov](https://codecov.io/gh/mediacatch/mediacatch/graph/badge.svg?token=D3bBQ64Cs9)](https://codecov.io/gh/mediacatch/mediacatch)
54
56
  [![Quality Check](https://github.com/mediacatch/mediacatch/actions/workflows/check.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/check.yaml)
55
57
  [![Publish](https://github.com/mediacatch/mediacatch/actions/workflows/publish.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/publish.yaml)
56
- [![Documentation](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml)
58
+ [![Documentation](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml)<br>
59
+
60
+ <h4 align="center">
61
+ <p>
62
+ <a href="#requirements">Requirements</a> |
63
+ <a href="#installation">Installation</a> |
64
+ <a href="#getting-started">Getting Started</a> |
65
+ <p>
66
+ </h4>
57
67
 
58
- # MediaCatch
68
+ </div>
59
69
 
60
70
  Python package for easily interfacing with MediaCatch APIs and data formats. Documentation can be found at [api.mediacatch.io/mediacatch/docs/](https://api.mediacatch.io/mediacatch/docs/).
61
71
 
@@ -1,10 +1,22 @@
1
+ <div align="center">
2
+
3
+ [<img src="docs/assets/mc_logo.svg" alt="mc-logo" width=400>](https://api.mediacatch.io/mediacatch/docs/)<br>
4
+
1
5
  [![Unit Tests](https://github.com/mediacatch/mediacatch/actions/workflows/test.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/test.yaml)
2
6
  [![codecov](https://codecov.io/gh/mediacatch/mediacatch/graph/badge.svg?token=D3bBQ64Cs9)](https://codecov.io/gh/mediacatch/mediacatch)
3
7
  [![Quality Check](https://github.com/mediacatch/mediacatch/actions/workflows/check.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/check.yaml)
4
8
  [![Publish](https://github.com/mediacatch/mediacatch/actions/workflows/publish.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/publish.yaml)
5
- [![Documentation](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml)
9
+ [![Documentation](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml/badge.svg)](https://github.com/mediacatch/mediacatch/actions/workflows/documentation.yaml)<br>
10
+
11
+ <h4 align="center">
12
+ <p>
13
+ <a href="#requirements">Requirements</a> |
14
+ <a href="#installation">Installation</a> |
15
+ <a href="#getting-started">Getting Started</a> |
16
+ <p>
17
+ </h4>
6
18
 
7
- # MediaCatch
19
+ </div>
8
20
 
9
21
  Python package for easily interfacing with MediaCatch APIs and data formats. Documentation can be found at [api.mediacatch.io/mediacatch/docs/](https://api.mediacatch.io/mediacatch/docs/).
10
22
 
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="259px" height="32px" viewBox="0 0 259 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>mc_logo</title>
4
+ <g id="Social-media" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="mc_logo" fill="#000000" fill-rule="nonzero">
6
+ <path d="M5.2261008,0.0132134395 L29.8682986,2.59855825 C31.1757299,2.73575455 32.1242044,3.90494078 31.986763,5.21004021 L29.3900862,29.8720617 C29.2526447,31.1771612 28.0813695,32.123944 26.7739382,31.9867952 L2.13174035,29.4014029 C0.824309029,29.2642541 -0.124165435,28.0950679 0.0132283961,26.7899684 L2.60995277,2.12789937 C2.74739421,0.822799936 3.91866948,-0.123982864 5.2261008,0.0132134395 Z M24.4055811,6.33082069 C24.2693398,5.47002125 23.4594639,4.88305274 22.5966754,5.01976749 L6.33509989,7.59686183 C5.47231134,7.73357659 4.88334655,8.5422238 5.01958783,9.40302324 L7.5943965,25.6692099 C7.73066834,26.5300012 8.54054424,27.1169697 9.40332462,26.9802244 L25.6649083,24.4031606 C26.5276887,24.2664153 27.1166534,23.4577681 26.9804122,22.5969687 L24.4055811,6.33082069 Z" id="Shape"></path>
7
+ <g id="MEDIACATCH" transform="translate(45, 6)">
8
+ <polygon id="Path" points="19.620064 1 12.0384205 10.5142857 4.45677695 1 0 1 0 19 3.9701174 19 3.9701174 6.47714286 11.8335112 16.12 12.0384205 16.12 19.9018143 6.47714286 19.9018143 19 24 19 24 1"></polygon>
9
+ <polygon id="Path" points="33.1900139 15.5542857 33.1900139 11.5942857 45.3384189 11.5942857 45.3384189 8.14857143 33.1900139 8.14857143 33.1900139 4.44571429 47.7364771 4.44571429 47.7364771 1 29 1 29 19 48 19 48 15.5542857"></polygon>
10
+ <path d="M60.7043478,1 L51,1 L51,19 L60.7043478,19 C67.5913043,19 72,15.6057143 72,10 C72,4.39428571 67.5913043,1 60.7043478,1 Z M60.3913043,15.5028571 L55.173913,15.5028571 L55.173913,4.49714286 L60.3913043,4.49714286 C64.773913,4.49714286 67.7478261,6.29714286 67.7478261,10 C67.7478261,13.7028571 64.773913,15.5028571 60.3913043,15.5028571 Z" id="Shape"></path>
11
+ <polygon id="Path" points="80 19 80 1 76 1 76 19"></polygon>
12
+ <path d="M102.472192,19 L107,19 L97.2900763,1 L92.7099237,1 L83,19 L87.4754635,19 L89.438386,15.1942857 L100.509269,15.1942857 L102.472192,19 Z M91.1657579,11.8514286 L94.9607415,4.52285714 L98.7557252,11.8514286 L91.1657579,11.8514286 Z" id="Shape"></path>
13
+ <path d="M118.846154,17.0026954 C113.641026,17.0026954 110.205128,14.4420485 110.205128,9.5 C110.205128,4.55795148 113.641026,1.99730458 118.846154,1.99730458 C121.974359,1.99730458 124.538462,3.04716981 125.948718,5.42857143 L128,4.40431267 C126.307692,1.74123989 123.179487,0 118.871795,0 C112.102564,0 108,3.68733154 108,9.5 C108,15.3126685 112.102564,19 118.794872,19 C123.179487,19 126.307692,17.2843666 128,14.5956873 L125.948718,13.5714286 C124.564103,15.9784367 121.974359,17.0026954 118.846154,17.0026954 Z" id="Path"></path>
14
+ <path d="M149.471065,19 L152,19 L141.751157,1 L139.248843,1 L129,19 L131.475694,19 L134.190972,14.1657143 L146.755787,14.1657143 L149.471065,19 Z M135.282407,12.2114286 L140.47338,2.98 L145.664352,12.2114286 L135.282407,12.2114286 Z" id="Shape"></path>
15
+ <polygon id="Path" points="169 1 150 1 150 2.95428571 158.416107 2.95428571 158.416107 19 160.558389 19 160.558389 2.95428571 169 2.95428571"></polygon>
16
+ <path d="M181.846154,17.0026954 C176.641026,17.0026954 173.205128,14.4420485 173.205128,9.5 C173.205128,4.55795148 176.641026,1.99730458 181.846154,1.99730458 C184.974359,1.99730458 187.538462,3.04716981 188.948718,5.42857143 L191,4.40431267 C189.307692,1.74123989 186.179487,0 181.871795,0 C175.102564,0 171,3.68733154 171,9.5 C171,15.3126685 175.102564,19 181.794872,19 C186.179487,19 189.307692,17.2843666 191,14.5956873 L188.948718,13.5714286 C187.564103,15.9784367 184.974359,17.0026954 181.846154,17.0026954 Z" id="Path"></path>
17
+ <polygon id="Path" points="211.854839 1 211.854839 8.84285714 197.145161 8.84285714 197.145161 1 195 1 195 19 197.145161 19 197.145161 10.9 211.854839 10.9 211.854839 19 214 19 214 1"></polygon>
18
+ </g>
19
+ </g>
20
+ </g>
21
+ </svg>
@@ -14,4 +14,4 @@ logging.basicConfig(
14
14
  load_dotenv()
15
15
  mediacatch_api_key = os.environ['MEDIACATCH_API_KEY']
16
16
 
17
- __version__ = '0.2.2'
17
+ __version__ = '0.2.4'
@@ -26,6 +26,8 @@ def vision_cli_factory(args):
26
26
  max_height_width_ratio=args.max_height_width_ratio,
27
27
  get_detection_histogram=args.get_detection_histogram,
28
28
  detection_histogram_bins=args.detection_histogram_bins,
29
+ max_height_difference_ratio=args.max_height_difference_ratio,
30
+ max_horizontal_distance_ratio=args.max_horizontal_distance_ratio,
29
31
  only_upload=args.only_upload,
30
32
  )
31
33
 
@@ -115,6 +117,18 @@ class VisionCLI(BaseCLICommand):
115
117
  default=None,
116
118
  help='Number of bins for histogram calculation',
117
119
  )
120
+ vision_parser.add_argument(
121
+ '--max-height-difference-ratio',
122
+ type=float,
123
+ default=None,
124
+ help='Determine the maximum allowed difference in height between two text boxes for them to be merged',
125
+ )
126
+ vision_parser.add_argument(
127
+ '--max-horizontal-distance-ratio',
128
+ type=float,
129
+ default=None,
130
+ help='Determine if two boxes are close enough horizontally to be considered part of the same text line',
131
+ )
118
132
  vision_parser.add_argument(
119
133
  '--only-upload',
120
134
  action='store_true',
@@ -138,6 +152,8 @@ class VisionCLI(BaseCLICommand):
138
152
  max_height_width_ratio: float | None = None,
139
153
  get_detection_histogram: bool | None = None,
140
154
  detection_histogram_bins: int | None = None,
155
+ max_height_difference_ratio: float | None = None,
156
+ max_horizontal_distance_ratio: float | None = None,
141
157
  only_upload: bool = False,
142
158
  ) -> None:
143
159
  self.file_path = file_path
@@ -154,6 +170,8 @@ class VisionCLI(BaseCLICommand):
154
170
  self.max_height_width_ratio = max_height_width_ratio
155
171
  self.get_detection_histogram = get_detection_histogram
156
172
  self.detection_histogram_bins = detection_histogram_bins
173
+ self.max_height_difference_ratio = max_height_difference_ratio
174
+ self.max_horizontal_distance_ratio = max_horizontal_distance_ratio
157
175
  self.only_upload = only_upload
158
176
 
159
177
  def run(self) -> None:
@@ -172,6 +190,8 @@ class VisionCLI(BaseCLICommand):
172
190
  max_height_width_ratio=self.max_height_width_ratio,
173
191
  get_detection_histogram=self.get_detection_histogram,
174
192
  detection_histogram_bins=self.detection_histogram_bins,
193
+ max_height_difference_ratio=self.max_height_difference_ratio,
194
+ max_horizontal_distance_ratio=self.max_horizontal_distance_ratio,
175
195
  )
176
196
  if self.only_upload:
177
197
  logger.info(f'Find result at https://api.mediacatch.io/vision/result/{file_id}')
@@ -52,7 +52,8 @@ def wait_for_result(
52
52
  return result
53
53
 
54
54
  except (requests.RequestException, json.JSONDecodeError):
55
- time.sleep(delay)
55
+ if verbose:
56
+ logger.error('Error occurred while waiting for JSON response')
56
57
 
57
58
  except Exception as e:
58
59
  if verbose:
@@ -60,6 +61,8 @@ def wait_for_result(
60
61
 
61
62
  raise MediacatchError(f'Failed to get result from {result_url}: {e}')
62
63
 
64
+ time.sleep(delay)
65
+
63
66
  if verbose:
64
67
  logger.error(f'Timeout waiting for result from {result_url}, give up')
65
68
 
@@ -45,7 +45,23 @@ def wait_for_result(
45
45
 
46
46
  raise MediacatchAPIError(response.status_code, response.json())
47
47
 
48
+ if response.status_code == 102:
49
+ if verbose:
50
+ logger.info(f'Waiting for result from {result_url}')
51
+
52
+ time.sleep(delay)
53
+ continue
54
+ elif response.status_code == 504:
55
+ time.sleep(delay)
56
+ continue
57
+
48
58
  response.raise_for_status()
59
+ if response.status_code == 204:
60
+ if verbose:
61
+ logger.info(f'No results found for {file_id}')
62
+
63
+ return {}
64
+
49
65
  result = response.json()
50
66
  elapsed_time = time.time() - start_time
51
67
  if verbose:
@@ -54,7 +70,8 @@ def wait_for_result(
54
70
  return result
55
71
 
56
72
  except (requests.RequestException, json.JSONDecodeError):
57
- time.sleep(delay)
73
+ if verbose:
74
+ logger.error('Error occurred while waiting for JSON response')
58
75
 
59
76
  except Exception as e:
60
77
  if verbose:
@@ -62,6 +79,8 @@ def wait_for_result(
62
79
 
63
80
  raise MediacatchError(f'Failed to get result from {result_url}: {e}')
64
81
 
82
+ time.sleep(delay)
83
+
65
84
  if verbose:
66
85
  logger.error(f'Timeout waiting for result from {result_url}, give up')
67
86
 
@@ -69,6 +88,6 @@ def wait_for_result(
69
88
 
70
89
 
71
90
  if __name__ == '__main__':
72
- file_id = '667bc663c8a5993596bf2803'
91
+ file_id = '66e6fb29b775ebfd11fb40f7'
73
92
  result = wait_for_result(file_id)
74
93
  print(result)
@@ -34,6 +34,8 @@ 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
+ max_height_difference_ratio: float | None = None,
38
+ max_horizontal_distance_ratio: float | None = None,
37
39
  get_frame_index: bool | None = None,
38
40
  get_bbox: bool | None = None,
39
41
  face_recognition: bool | None = None,
@@ -62,6 +64,8 @@ def upload(
62
64
  max_height_width_ratio (float, optional): Discard detection if height/width ratio is greater than this value. Defaults to 2.0.
63
65
  get_detection_histogram (bool, optional): If true, get histogram of detection. Defaults to False.
64
66
  detection_histogram_bins (int, optional): Number of bins for histogram calculation. Defaults to 8.
67
+ max_height_difference_ratio (float, optional): Determine the maximum allowed difference in height between two text boxes for them to be merged. Defaults to 0.5.
68
+ max_horizontal_distance_ratio (float, optional): Determine if two boxes are close enough horizontally to be considered part of the same text line. Defaults to 0.9.
65
69
  get_frame_index (bool, optional): If true, get frame index. Defaults to None.
66
70
  get_bbox (bool, optional): If true, get bounding box. Defaults to None.
67
71
  face_recognition (bool, optional): If true, run face recognition. Defaults to None.
@@ -102,6 +106,10 @@ def upload(
102
106
  extra['get_detection_histogram'] = get_detection_histogram
103
107
  if detection_histogram_bins is not None:
104
108
  extra['detection_histogram_bins'] = detection_histogram_bins
109
+ if max_height_difference_ratio is not None:
110
+ extra['max_height_difference_ratio'] = max_height_difference_ratio
111
+ if max_horizontal_distance_ratio is not None:
112
+ extra['max_horizontal_distance_ratio'] = max_horizontal_distance_ratio
105
113
  if get_frame_index is not None:
106
114
  extra['frame'] = get_frame_index
107
115
  if get_bbox is not None:
@@ -3,9 +3,7 @@ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
  [project.urls]
6
- Documentation = "https://github.com/mediacatch/mediacatch#readme"
7
- Issues = "https://github.com/mediacatch/mediacatch/issues"
8
- Source = "https://github.com/mediacatch/mediacatch"
6
+ Documentation = "https://api.mediacatch.io/mediacatch/docs/"
9
7
 
10
8
  [tool.hatch.version]
11
9
  path = "mediacatch/__init__.py"
@@ -17,8 +15,7 @@ readme = "README.md"
17
15
  requires-python = ">=3.10"
18
16
  license = "MIT"
19
17
  authors = [
20
- { name = "Mathias Nielsen", email = "mathias@mediacatch.io" },
21
- { name = "Frederik Haarslev", email = "frederik@mediacatch.io" },
18
+ { name = "Mathias Nielsen", email = "mathias@mediacatch.io" }
22
19
  ]
23
20
  classifiers = [
24
21
  "Topic :: Internet",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes