fxn 0.0.29__py3-none-any.whl → 0.0.30__py3-none-any.whl

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.
@@ -7,9 +7,9 @@ from aiohttp import ClientSession
7
7
  from ctypes import byref, c_double, c_int32, create_string_buffer
8
8
  from dataclasses import asdict, is_dataclass
9
9
  from datetime import datetime, timezone
10
- from filetype import guess_mime
11
10
  from io import BytesIO
12
11
  from json import dumps, loads
12
+ from magika import Magika
13
13
  from numpy import array, float32, frombuffer, int32, ndarray
14
14
  from numpy.typing import NDArray
15
15
  from pathlib import Path
@@ -367,28 +367,35 @@ class PredictionService:
367
367
  )
368
368
  finally:
369
369
  fxnc.FXNProfileRelease(profile)
370
- #fxnc.FXNValueMapRelease(input_map)
370
+ fxnc.FXNValueMapRelease(input_map)
371
371
  fxnc.FXNValueMapRelease(output_map)
372
372
 
373
- def __parse_prediction (self, data: Dict[str, Any], *, raw_outputs: bool, return_binary_path: bool) -> Prediction:
373
+ def __parse_prediction (
374
+ self,
375
+ data: Dict[str, Any],
376
+ *,
377
+ raw_outputs: bool,
378
+ return_binary_path: bool
379
+ ) -> Prediction:
374
380
  prediction = Prediction(**data)
375
381
  prediction.results = [Value(**value) for value in prediction.results] if prediction.results is not None else None
376
382
  prediction.results = [self.to_object(value, return_binary_path=return_binary_path) for value in prediction.results] if prediction.results is not None and not raw_outputs else prediction.results
377
383
  return prediction
378
384
 
379
385
  def __get_data_dtype (self, data: Union[Path, BytesIO]) -> Dtype:
380
- mime = guess_mime(str(data) if isinstance(data, Path) else data)
381
- if not mime:
382
- return Dtype.binary
383
- if mime.startswith("image"):
386
+ magika = Magika()
387
+ result = magika.identify_bytes(data.getvalue()) if isinstance(data, BytesIO) else magika.identify_path(data)
388
+ group = result.output.group
389
+ if group == "image":
384
390
  return Dtype.image
385
- if mime.startswith("video"):
386
- return Dtype.video
387
- if mime.startswith("audio"):
391
+ elif group == "audio":
388
392
  return Dtype.audio
389
- if isinstance(data, Path) and data.suffix in [".obj", ".gltf", ".glb", ".fbx", ".usd", ".usdz", ".blend"]:
393
+ elif group == "video":
394
+ return Dtype.video
395
+ elif isinstance(data, Path) and data.suffix in [".obj", ".gltf", ".glb", ".fbx", ".usd", ".usdz", ".blend"]:
390
396
  return Dtype._3d
391
- return Dtype.binary
397
+ else:
398
+ return Dtype.binary
392
399
 
393
400
  def __download_value_data (self, url: str) -> BytesIO:
394
401
  if url.startswith("data:"):
fxn/version.py CHANGED
@@ -3,4 +3,4 @@
3
3
  # Copyright © 2024 NatML Inc. All Rights Reserved.
4
4
  #
5
5
 
6
- __version__ = "0.0.29"
6
+ __version__ = "0.0.30"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fxn
3
- Version: 0.0.29
3
+ Version: 0.0.30
4
4
  Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
5
5
  Home-page: https://fxn.ai
6
6
  Author: NatML Inc.
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: Apache Software License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Topic :: Scientific/Engineering :: Image Recognition
16
16
  Classifier: Topic :: Software Development :: Libraries
17
- Requires-Python: >=3.7
17
+ Requires-Python: >=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: aiohttp
@@ -1,7 +1,7 @@
1
1
  fxn/__init__.py,sha256=tWk0-aCNHX_yCS-Dg90pYnniNka9MWFoNMk6xY7u4nI,157
2
2
  fxn/function.py,sha256=H2oviHGWfal2O7d386R8BZDMUZYdfOuMB7OijiPKo54,1632
3
3
  fxn/magic.py,sha256=PQmXhO9EvJ5EZylioV-6gsCvqhVRYscKBSOBoN4VhTk,1041
4
- fxn/version.py,sha256=2bH3KKQTSZHS38Wa1uImYccLoJHRXdAc_UJR20CpoME,95
4
+ fxn/version.py,sha256=A2_mJosEtqos00n0S2q_ctD70NhvQ0jouy6KHj5ttxI,95
5
5
  fxn/cli/__init__.py,sha256=gwMG0euV0qCe_vSvJLqBd6VWoQ99T-y4xQXeA4m4Wf0,1492
6
6
  fxn/cli/auth.py,sha256=MpHxhqPjGY92TmaTh3o58i868Cv-6Xgf13Si1NFluMg,1677
7
7
  fxn/cli/env.py,sha256=shqoP4tUiXdOoil73oiUYpqGeVcR119HPYFKgnoF894,1553
@@ -17,7 +17,7 @@ fxn/services/storage.py,sha256=MY4in8XXVHDIpp8f928PFdujwegESb6m1zzop6d-z58,5517
17
17
  fxn/services/user.py,sha256=z7mencF-muknruaUuoleu6JoL-QsPJcrJ6ONT_6U7fk,1219
18
18
  fxn/services/prediction/__init__.py,sha256=TPox_z58SRjIvziCt1UnLNN1O23n_iF6HcmI0p9hwpQ,129
19
19
  fxn/services/prediction/fxnc.py,sha256=UsU95dWaRoyxMEEKYjh5b4Sa0bspUn7tXdwNu9ug6fc,11673
20
- fxn/services/prediction/service.py,sha256=rBz51l2jh8K2LldHyWjA-XROYwHCtaUlAmUrDOSpL_E,20217
20
+ fxn/services/prediction/service.py,sha256=-p-J5LOX18EQcAO316C0DGZw6YS9Kvjc5Y7VomqaNKs,20333
21
21
  fxn/types/__init__.py,sha256=jHLpQnvUKGQujVPK3li1rIkANBBvw6l_EznzIsfoD88,438
22
22
  fxn/types/dtype.py,sha256=YpTnIG-yzrQwda27GzfGZcel-zF3gOMMoHhcWD915BY,617
23
23
  fxn/types/environment.py,sha256=FbmfGjSb5yYMT9IyDj8zNUpsoP3RbzqM6tK8gn2TfDs,394
@@ -28,9 +28,9 @@ fxn/types/storage.py,sha256=AtVKR3CtHzvSWLiJS_bbUyIA2Of_IKZVeL5_1PqqrQ0,228
28
28
  fxn/types/tag.py,sha256=hWzSDCo8VjRHjS5ZLuFi3xVo8cuCNaNeULQ2mHEuwzM,707
29
29
  fxn/types/user.py,sha256=_hc1YQh0WydniAurywA70EDs4VCY5rnGRYSiRc97Ab0,150
30
30
  fxn/types/value.py,sha256=_Euyb3ffydKV1Q68Mf2G9mz7gKD5NzFap-aX1NEuNuY,767
31
- fxn-0.0.29.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
32
- fxn-0.0.29.dist-info/METADATA,sha256=Hei9Ql3Jq6M_7zmVU6TxLPvbAjndXA_7rcexy45dRs8,3340
33
- fxn-0.0.29.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
- fxn-0.0.29.dist-info/entry_points.txt,sha256=QBwKIRed76CRY98VYQYrQDVEBZtJugxJJmBpilxuios,46
35
- fxn-0.0.29.dist-info/top_level.txt,sha256=1ULIEGrnMlhId8nYAkjmRn9g3KEFuHKboq193SEKQkA,4
36
- fxn-0.0.29.dist-info/RECORD,,
31
+ fxn-0.0.30.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
32
+ fxn-0.0.30.dist-info/METADATA,sha256=0gDRWpFCUFnqGqMVveI9E7pf5YQEZYO54gG1vBKdDmc,3340
33
+ fxn-0.0.30.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
+ fxn-0.0.30.dist-info/entry_points.txt,sha256=QBwKIRed76CRY98VYQYrQDVEBZtJugxJJmBpilxuios,46
35
+ fxn-0.0.30.dist-info/top_level.txt,sha256=1ULIEGrnMlhId8nYAkjmRn9g3KEFuHKboq193SEKQkA,4
36
+ fxn-0.0.30.dist-info/RECORD,,
File without changes
File without changes