hyper-models 0.3.3__tar.gz → 0.3.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.
- {hyper_models-0.3.3 → hyper_models-0.3.4}/PKG-INFO +9 -9
- {hyper_models-0.3.3 → hyper_models-0.3.4}/README.md +8 -8
- {hyper_models-0.3.3 → hyper_models-0.3.4}/pyproject.toml +1 -1
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/models.py +17 -3
- {hyper_models-0.3.3 → hyper_models-0.3.4}/.gitignore +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/LICENSE +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/__init__.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/__init__.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/encoders.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/experimental.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/himo.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/hyper3_clip.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/lorentz.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/losses.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/objectives.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/models/tren.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/training/__init__.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper3_clip/training/distributed.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/__init__.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/loader.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/loaders.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/preprocessing.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/registry.py +0 -0
- {hyper_models-0.3.3 → hyper_models-0.3.4}/src/hyper_models/torch_models.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hyper-models
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A model zoo for non-Euclidean embedding models (hyperbolic, spherical, product manifolds)
|
|
5
5
|
Project-URL: Homepage, https://github.com/Hyper3Labs/hyper-models
|
|
6
6
|
Project-URL: Repository, https://github.com/Hyper3Labs/hyper-models
|
|
@@ -96,7 +96,7 @@ hyper_models.list_loaders()
|
|
|
96
96
|
# Load model (auto-downloads from Hugging Face Hub)
|
|
97
97
|
model = hyper_models.load("hycoclip-vit-s")
|
|
98
98
|
model.geometry # 'hyperboloid'
|
|
99
|
-
model.dim
|
|
99
|
+
model.dim # 513
|
|
100
100
|
|
|
101
101
|
# Encode PIL images
|
|
102
102
|
images = [Image.open("image.jpg")]
|
|
@@ -104,9 +104,9 @@ embeddings = model.encode_images(images) # (1, 513) ndarray
|
|
|
104
104
|
|
|
105
105
|
# Get model info
|
|
106
106
|
info = hyper_models.get_model_info("hycoclip-vit-s")
|
|
107
|
-
info.hub_id
|
|
108
|
-
info.loader
|
|
109
|
-
info.license
|
|
107
|
+
info.hub_id # 'mnm-matin/hyperbolic-clip'
|
|
108
|
+
info.loader # 'onnx'
|
|
109
|
+
info.license # 'CC-BY-NC'
|
|
110
110
|
|
|
111
111
|
# Low-level: preprocess images yourself
|
|
112
112
|
batch = hyper_models.preprocess_images(images) # (B, 3, 224, 224)
|
|
@@ -149,10 +149,10 @@ HyperView auto-detects `hyper-models` names and routes them to the `hyper-models
|
|
|
149
149
|
import hyperview as hv
|
|
150
150
|
|
|
151
151
|
dataset = hv.Dataset.from_huggingface(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
name="demo",
|
|
153
|
+
hf_dataset="uoft-cs/cifar10",
|
|
154
|
+
split="train",
|
|
155
|
+
image_key="img",
|
|
156
156
|
)
|
|
157
157
|
|
|
158
158
|
# Uses provider='hyper-models' automatically.
|
|
@@ -55,7 +55,7 @@ hyper_models.list_loaders()
|
|
|
55
55
|
# Load model (auto-downloads from Hugging Face Hub)
|
|
56
56
|
model = hyper_models.load("hycoclip-vit-s")
|
|
57
57
|
model.geometry # 'hyperboloid'
|
|
58
|
-
model.dim
|
|
58
|
+
model.dim # 513
|
|
59
59
|
|
|
60
60
|
# Encode PIL images
|
|
61
61
|
images = [Image.open("image.jpg")]
|
|
@@ -63,9 +63,9 @@ embeddings = model.encode_images(images) # (1, 513) ndarray
|
|
|
63
63
|
|
|
64
64
|
# Get model info
|
|
65
65
|
info = hyper_models.get_model_info("hycoclip-vit-s")
|
|
66
|
-
info.hub_id
|
|
67
|
-
info.loader
|
|
68
|
-
info.license
|
|
66
|
+
info.hub_id # 'mnm-matin/hyperbolic-clip'
|
|
67
|
+
info.loader # 'onnx'
|
|
68
|
+
info.license # 'CC-BY-NC'
|
|
69
69
|
|
|
70
70
|
# Low-level: preprocess images yourself
|
|
71
71
|
batch = hyper_models.preprocess_images(images) # (B, 3, 224, 224)
|
|
@@ -108,10 +108,10 @@ HyperView auto-detects `hyper-models` names and routes them to the `hyper-models
|
|
|
108
108
|
import hyperview as hv
|
|
109
109
|
|
|
110
110
|
dataset = hv.Dataset.from_huggingface(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
name="demo",
|
|
112
|
+
hf_dataset="uoft-cs/cifar10",
|
|
113
|
+
split="train",
|
|
114
|
+
image_key="img",
|
|
115
115
|
)
|
|
116
116
|
|
|
117
117
|
# Uses provider='hyper-models' automatically.
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
from shutil import copyfile
|
|
7
|
+
from tempfile import TemporaryDirectory
|
|
6
8
|
|
|
7
9
|
import numpy as np
|
|
8
10
|
from PIL import Image
|
|
@@ -32,14 +34,26 @@ class ONNXModel:
|
|
|
32
34
|
self._output_name = output_name
|
|
33
35
|
self._image_config = image_config or ImageConfig()
|
|
34
36
|
self._session = None
|
|
37
|
+
self._artifact_directory = None
|
|
35
38
|
|
|
36
39
|
def _ensure_session(self) -> None:
|
|
37
40
|
if self._session is None:
|
|
38
41
|
import onnxruntime as ort
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
path = self._path
|
|
44
|
+
# Hub snapshots link the graph and external weights to different
|
|
45
|
+
# blob directories. New ONNX Runtime versions correctly reject
|
|
46
|
+
# external data outside the resolved graph directory. Materialize
|
|
47
|
+
# our catalog's graph and sidecars together, keeping validation on.
|
|
48
|
+
artifacts = [path, *path.parent.glob(f"{path.name}.*")]
|
|
49
|
+
if any(artifact.is_symlink() for artifact in artifacts):
|
|
50
|
+
self._artifact_directory = TemporaryDirectory(prefix="hyper-models-onnx-")
|
|
51
|
+
directory = Path(self._artifact_directory.name)
|
|
52
|
+
for artifact in artifacts:
|
|
53
|
+
if artifact.is_file():
|
|
54
|
+
copyfile(artifact, directory / artifact.name)
|
|
55
|
+
path = directory / path.name
|
|
56
|
+
self._session = ort.InferenceSession(str(path), providers=["CPUExecutionProvider"])
|
|
43
57
|
|
|
44
58
|
def encode(self, inputs: np.ndarray) -> np.ndarray:
|
|
45
59
|
"""Encode preprocessed inputs (B, C, H, W) to embeddings (B, D)."""
|
|
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
|