mediapipe-nightly 0.10.11.post20240302__cp39-cp39-macosx_11_0_universal2.whl → 0.10.11.post20240303__cp39-cp39-macosx_11_0_universal2.whl

Sign up to get free protection for your applications and to get access to all the features.
mediapipe/__init__.py CHANGED
@@ -23,4 +23,4 @@ del modules
23
23
  del python
24
24
  del mediapipe
25
25
  del util
26
- __version__ = '0.10.11-20240302'
26
+ __version__ = '0.10.11-20240303'
@@ -1,5 +1,6 @@
1
1
  """Functions to perform the checkpoint conversion."""
2
2
 
3
+ import contextlib
3
4
  import os
4
5
  from typing import List, Optional
5
6
 
@@ -168,16 +169,41 @@ def convert_bpe_vocab(vocab_model_file: str, output_dir: str) -> str:
168
169
  return output_vocab_file
169
170
 
170
171
 
172
+ @contextlib.contextmanager
173
+ def filemanager(filename: str, mode: str):
174
+ try:
175
+ with open(filename, mode) as f:
176
+ yield f
177
+ finally:
178
+ pass
179
+
180
+
181
+ def sort_layer_info(layer_info_file: str) -> None:
182
+ """Loads and sorts the layer info file."""
183
+ layer_info = []
184
+ with filemanager(layer_info_file, 'r') as finfo:
185
+ for line in finfo:
186
+ line = line.strip()
187
+ if line:
188
+ layer_info.append(line)
189
+ layer_info = list(set(layer_info))
190
+ layer_info.sort()
191
+ with filemanager(layer_info_file, 'w') as finfo:
192
+ for line in layer_info:
193
+ finfo.write(line + '\n')
194
+ finfo.write('\n')
195
+
196
+
171
197
  def convert_checkpoint(config: ConversionConfig) -> None:
172
198
  """Converts the checkpoint to tflite file."""
173
199
  logging.info('input folder: %s', config.input_ckpt)
174
200
 
175
- if config.model_type == 'GEMMA_2B':
176
- vocab_model_path = config.vocab_model_file
177
- else:
201
+ if os.path.isdir(config.vocab_model_file):
178
202
  vocab_model_path = convert_bpe_vocab(
179
203
  config.vocab_model_file, config.output_dir
180
204
  )
205
+ else:
206
+ vocab_model_path = config.vocab_model_file
181
207
 
182
208
  if not config.combine_file_only:
183
209
  # Load the layer weights and prepare the quantization configurations.
@@ -209,6 +235,8 @@ def convert_checkpoint(config: ConversionConfig) -> None:
209
235
  del quantized_tensors
210
236
  del writer
211
237
 
238
+ sort_layer_info(os.path.join(config.output_dir, 'layer_info.txt'))
239
+
212
240
  combined_weight_bins_to_tflite(
213
241
  config.model_type,
214
242
  config.backend,
@@ -393,6 +393,14 @@ class GemmaMapper(converter_base.LayerActionMapperBase):
393
393
  quantize_axis = [1]
394
394
  elif layer_type == LayerType.EMBEDDING:
395
395
  quantize_bits = self._embedding_quant_bits
396
+ if tensor_value.shape[1] < 256128:
397
+ # Padd the embedding shape if the vocab size was smaller than the
398
+ # original setting: 256128.
399
+ pad_count = 256128 - tensor_value.shape[1]
400
+ tensor_value = np.pad(
401
+ tensor_value, ((0, 0), (0, pad_count)), mode="constant"
402
+ )
403
+
396
404
  target_name = self.update_target_name(layer_name)
397
405
 
398
406
  actions = [
@@ -106,7 +106,7 @@ class WeightBinsWriter(converter_base.ModelWriterBase):
106
106
  # Sort weights_info
107
107
  weights_info.sort()
108
108
  with filemanager(
109
- os.path.join(self._output_dir, 'layer_info.txt'), 'w'
109
+ os.path.join(self._output_dir, 'layer_info.txt'), 'a'
110
110
  ) as finfo:
111
111
  for line in weights_info:
112
112
  finfo.write(line + '\n')
mediapipe/version.txt CHANGED
@@ -1 +1 @@
1
- 0.10.11-20240302
1
+ 0.10.11-20240303
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mediapipe-nightly
3
- Version: 0.10.11.post20240302
3
+ Version: 0.10.11.post20240303
4
4
  Summary: MediaPipe is the simplest way for researchers and developers to build world-class ML solutions and applications for mobile, edge, cloud and the web.
5
5
  Home-page: https://github.com/google/mediapipe
6
6
  Author: The MediaPipe Authors
@@ -1,9 +1,4 @@
1
- mediapipe_nightly-0.10.11.post20240302.dist-info/RECORD,,
2
- mediapipe_nightly-0.10.11.post20240302.dist-info/LICENSE,sha256=hwfu8FM5h-_FsVXWR2HutuIHk_ULm9Gmja0c9HGdDtg,12331
3
- mediapipe_nightly-0.10.11.post20240302.dist-info/WHEEL,sha256=Roq3jd81zxBo_pMxKZzXrRts-yky38mkvNnjvr99fPU,109
4
- mediapipe_nightly-0.10.11.post20240302.dist-info/top_level.txt,sha256=LG-epD1oIiiHFRqLp--7jacjB3dbx2RfMcLYjCIhmxU,175
5
- mediapipe_nightly-0.10.11.post20240302.dist-info/METADATA,sha256=Z_ixYoKtEPje2xOmQuHu44KTR17vwvA_rhw1LA27h1E,9715
6
- mediapipe/__init__.py,sha256=FG3p8a-sPsr3_nru1WF1PkqKrAHldPzVed4uOfnptR8,816
1
+ mediapipe/__init__.py,sha256=EXN6Y5HrB1DAy9ze__JS6IX9nIpv7DrRL1sPkN6BX6Y,816
7
2
  mediapipe/tasks/__init__.py,sha256=sVJS2p8J2PNVl8DLRPVY6KLpHenP_z3QVPRU0x_iL5g,571
8
3
  mediapipe/tasks/python/__init__.py,sha256=wIM_WOWboOVI1MeehN8fkN_DjoA0MEBVw5mShAd8AS4,858
9
4
  mediapipe/tasks/python/benchmark/__init__.py,sha256=epEucluzX0HinwBZoS7Tgb19j_qgfTuBf-vBkqemch8,587
@@ -89,15 +84,15 @@ mediapipe/tasks/python/genai/__init__.py,sha256=7rri6fT6wNurla8O2c5yKiLs9_3qIY0v
89
84
  mediapipe/tasks/python/genai/converter/pytorch_converter_test.py,sha256=y_Mg9pOQtlUDh6uVmkz5LcUbk-pmDLA9L3KcxKR-OaA,3041
90
85
  mediapipe/tasks/python/genai/converter/safetensors_converter_test.py,sha256=oCk4FnsjBJkEPlXtv8fdq9dn3I06LsSQRMi0BV_9mew,2802
91
86
  mediapipe/tasks/python/genai/converter/quantization_util.py,sha256=B6i13GqRRIwMabEJWO8rFHPMBjIgdOhFpHiwMD4GzRc,17196
92
- mediapipe/tasks/python/genai/converter/safetensors_converter.py,sha256=ttCpqyMeHkIFzppP8G8uMG5VsslK5-ULFT5U3R_qif0,18713
87
+ mediapipe/tasks/python/genai/converter/safetensors_converter.py,sha256=C7C2ZpZmryDwCZyLNzaAKv-n8klctlLB8jZ2-44_BHY,19039
93
88
  mediapipe/tasks/python/genai/converter/weight_bins_writer_test.py,sha256=6qgNYXODNOsbveZ0ighEW4JBdawil9mPcC16MZ0mdm8,1994
94
89
  mediapipe/tasks/python/genai/converter/converter_base.py,sha256=1nBgvcY5xaI0ZPjBJTVdViDFraVyJUZHLXBT0dYOX9c,6568
95
90
  mediapipe/tasks/python/genai/converter/pytorch_converter.py,sha256=b-GWYOzgD-ZRGgyqcXE9LG_JOL0Mqba4q0pc_imrbrg,10771
96
91
  mediapipe/tasks/python/genai/converter/__init__.py,sha256=jfUkinDJR5BVldnbJMbo5vIr2Xc5Z4TTnaCJTNoAUvg,893
97
92
  mediapipe/tasks/python/genai/converter/converter_factory.py,sha256=2K16PZBQym0WhXM2HOdBMHMugykohoD4OTaOIo-UKko,2928
98
- mediapipe/tasks/python/genai/converter/llm_converter.py,sha256=OJqrYEDPQYwoOftBw-Ajsqtkcj9uRHBAb_Oo_RCEKa4,7896
93
+ mediapipe/tasks/python/genai/converter/llm_converter.py,sha256=ZaPNzH94zTtXOL6Zrei6Wq1lMZeR9MF-1xuGP_abj28,8596
99
94
  mediapipe/tasks/python/genai/converter/quantization_util_test.py,sha256=ICujhTFeREGuHGmNk1PlBpf1AUThFvv-Wl5UuZ-xWAk,9060
100
- mediapipe/tasks/python/genai/converter/weight_bins_writer.py,sha256=qrsjTWw99u-VDNhtHbnbDfMypx4sGfGyY8mMBXYnQtA,4347
95
+ mediapipe/tasks/python/genai/converter/weight_bins_writer.py,sha256=4nUVWlvR6CMFCgSTb5ckdiFiLQpF4rrCfZTuZCTwkaQ,4347
101
96
  mediapipe/tasks/python/metadata/metadata.py,sha256=EECQnM-Af0angD60jaBBOuNMgt7HExH6SqVtVMFNHGc,33763
102
97
  mediapipe/tasks/python/metadata/metadata_displayer_cli.py,sha256=tLhF0B1mXG0igFTA9nPh8t1efRpRw2hQ00XpTPYdk_o,1202
103
98
  mediapipe/tasks/python/metadata/__init__.py,sha256=YGHXQMz1ZGPcNgSXggu03b0USZKE8d9Xqvn6NDUl898,586
@@ -320,7 +315,7 @@ mediapipe/util/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
320
315
  mediapipe/util/analytics/mediapipe_log_extension_pb2.py,sha256=UX1x8jckc8NQbUz-SXOKkb8co3JNIRX3rfaMs4_Dz8g,4319
321
316
  mediapipe/util/analytics/mediapipe_logging_enums_pb2.py,sha256=9pxs-DNSQnXQe7E_LKokGDbD_G1FpmzzJw1jzex78lU,3781
322
317
  mediapipe/python/solution_base.py,sha256=nEIqsho9DlutfvWWzdSxCOpJ2QzN7n2938WLDmFzn38,26072
323
- mediapipe/python/_framework_bindings.cpython-39-darwin.so,sha256=1QHgiXRi2935VpdMBmqvg_ADecPdZ4e72B83LPl_Oos,78906451
318
+ mediapipe/python/_framework_bindings.cpython-39-darwin.so,sha256=w4h6YecKQD3ke494B6ka0Lcjydy8e8Wqu8nCTTlbL7M,78906451
324
319
  mediapipe/python/timestamp_test.py,sha256=oWKTZMsV586jH57OBV30rihcymETyGC29VbYURNLJQQ,2528
325
320
  mediapipe/python/image_frame_test.py,sha256=ZSjdE-an2t8i6MiA4_Xri91VMH5_CCx45fjhWUQptMY,8602
326
321
  mediapipe/python/__init__.py,sha256=BQglgytZUe7_ZuD8amosz-szWdJ2LQp81nsuiEY3W84,1493
@@ -578,3 +573,8 @@ mediapipe/modules/selfie_segmentation/selfie_segmentation.tflite,sha256=nuFo7HyP
578
573
  mediapipe/modules/palm_detection/palm_detection_full.tflite,sha256=GxTpQixq0AbN5lgaRsi5DdVzwHq385NLVYnnzqP4mlQ,2339846
579
574
  mediapipe/modules/palm_detection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
580
575
  mediapipe/modules/palm_detection/palm_detection_lite.tflite,sha256=6aSq3fkN2laocjUwPPAOTC0_socl9o_Yh3KZfayQXBg,1985440
576
+ mediapipe_nightly-0.10.11.post20240303.dist-info/RECORD,,
577
+ mediapipe_nightly-0.10.11.post20240303.dist-info/LICENSE,sha256=hwfu8FM5h-_FsVXWR2HutuIHk_ULm9Gmja0c9HGdDtg,12331
578
+ mediapipe_nightly-0.10.11.post20240303.dist-info/WHEEL,sha256=Roq3jd81zxBo_pMxKZzXrRts-yky38mkvNnjvr99fPU,109
579
+ mediapipe_nightly-0.10.11.post20240303.dist-info/top_level.txt,sha256=LG-epD1oIiiHFRqLp--7jacjB3dbx2RfMcLYjCIhmxU,175
580
+ mediapipe_nightly-0.10.11.post20240303.dist-info/METADATA,sha256=PzIBKWQFkkKcurgEWrf-xP3DXRNd6bRRmRsDXPMMvaQ,9715