nexaai 1.0.16rc9__cp310-cp310-macosx_14_0_universal2.whl → 1.0.16rc10__cp310-cp310-macosx_14_0_universal2.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.
Potentially problematic release.
This version of nexaai might be problematic. Click here for more details.
- nexaai/__init__.py +0 -7
- nexaai/_stub.cpython-310-darwin.so +0 -0
- nexaai/_version.py +1 -1
- nexaai/binds/common_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/libnexa_bridge.dylib +0 -0
- nexaai/binds/llm_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib +0 -0
- nexaai/binds/nexa_mlx/libnexa_plugin.dylib +0 -0
- nexaai/binds/nexa_mlx/py-lib/ml.py +14 -60
- nexaai/mlx_backend/ml.py +14 -60
- nexaai/mlx_backend/sd/modeling/model_io.py +17 -72
- nexaai/runtime.py +0 -4
- {nexaai-1.0.16rc9.dist-info → nexaai-1.0.16rc10.dist-info}/METADATA +1 -1
- {nexaai-1.0.16rc9.dist-info → nexaai-1.0.16rc10.dist-info}/RECORD +16 -29
- nexaai/log.py +0 -92
- nexaai/mlx_backend/image_gen/__init__.py +0 -1
- nexaai/mlx_backend/image_gen/generate_sd.py +0 -244
- nexaai/mlx_backend/image_gen/interface.py +0 -82
- nexaai/mlx_backend/image_gen/main.py +0 -281
- nexaai/mlx_backend/image_gen/stable_diffusion/__init__.py +0 -306
- nexaai/mlx_backend/image_gen/stable_diffusion/clip.py +0 -116
- nexaai/mlx_backend/image_gen/stable_diffusion/config.py +0 -65
- nexaai/mlx_backend/image_gen/stable_diffusion/model_io.py +0 -386
- nexaai/mlx_backend/image_gen/stable_diffusion/sampler.py +0 -105
- nexaai/mlx_backend/image_gen/stable_diffusion/tokenizer.py +0 -100
- nexaai/mlx_backend/image_gen/stable_diffusion/unet.py +0 -460
- nexaai/mlx_backend/image_gen/stable_diffusion/vae.py +0 -274
- {nexaai-1.0.16rc9.dist-info → nexaai-1.0.16rc10.dist-info}/WHEEL +0 -0
- {nexaai-1.0.16rc9.dist-info → nexaai-1.0.16rc10.dist-info}/top_level.txt +0 -0
nexaai/__init__.py
CHANGED
|
@@ -21,9 +21,6 @@ except ImportError:
|
|
|
21
21
|
# Import common configuration classes first (no external dependencies)
|
|
22
22
|
from .common import ModelConfig, GenerationConfig, ChatMessage, SamplerConfig, PluginID
|
|
23
23
|
|
|
24
|
-
# Import logging functionality
|
|
25
|
-
from .log import set_logger, get_error_message
|
|
26
|
-
|
|
27
24
|
# Create alias for PluginID to be accessible as plugin_id
|
|
28
25
|
plugin_id = PluginID
|
|
29
26
|
|
|
@@ -48,10 +45,6 @@ __all__ = [
|
|
|
48
45
|
"EmbeddingConfig",
|
|
49
46
|
"PluginID",
|
|
50
47
|
"plugin_id",
|
|
51
|
-
|
|
52
|
-
# Logging functionality
|
|
53
|
-
"set_logger",
|
|
54
|
-
"get_error_message",
|
|
55
48
|
|
|
56
49
|
"LLM",
|
|
57
50
|
"Embedder",
|
|
Binary file
|
nexaai/_version.py
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
# This file defines the python interface that c-lib expects from a python backend
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from typing import Optional
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from dataclasses import dataclass
|
|
7
4
|
|
|
8
5
|
from abc import ABC, abstractmethod
|
|
9
6
|
from dataclasses import dataclass, field
|
|
@@ -104,12 +101,9 @@ class ModelConfig:
|
|
|
104
101
|
n_threads_batch: int = 0 # number of threads to use for batch processing
|
|
105
102
|
n_batch: int = 0 # logical maximum batch size that can be submitted to llama_decode
|
|
106
103
|
n_ubatch: int = 0 # physical maximum batch size
|
|
107
|
-
# max number of sequences (i.e. distinct states for recurrent models)
|
|
108
|
-
|
|
109
|
-
#
|
|
110
|
-
chat_template_path: Optional[Path] = None
|
|
111
|
-
# content of chat template file, optional
|
|
112
|
-
chat_template_content: Optional[str] = None
|
|
104
|
+
n_seq_max: int = 0 # max number of sequences (i.e. distinct states for recurrent models)
|
|
105
|
+
chat_template_path: Optional[Path] = None # path to chat template file, optional
|
|
106
|
+
chat_template_content: Optional[str] = None # content of chat template file, optional
|
|
113
107
|
|
|
114
108
|
|
|
115
109
|
@dataclass
|
|
@@ -124,8 +118,7 @@ class SamplerConfig:
|
|
|
124
118
|
frequency_penalty: float = 0.0
|
|
125
119
|
seed: int = -1 # –1 for random
|
|
126
120
|
grammar_path: Optional[Path] = None
|
|
127
|
-
# Optional grammar string (BNF-like format)
|
|
128
|
-
grammar_string: Optional[str] = None
|
|
121
|
+
grammar_string: Optional[str] = None # Optional grammar string (BNF-like format)
|
|
129
122
|
|
|
130
123
|
|
|
131
124
|
@dataclass
|
|
@@ -135,10 +128,8 @@ class GenerationConfig:
|
|
|
135
128
|
stop: Sequence[str] = field(default_factory=tuple)
|
|
136
129
|
n_past: int = 0
|
|
137
130
|
sampler_config: Optional[SamplerConfig] = None
|
|
138
|
-
# Array of image paths for VLM (None if none)
|
|
139
|
-
|
|
140
|
-
# Array of audio paths for VLM (None if none)
|
|
141
|
-
audio_paths: Optional[Sequence[Path]] = None
|
|
131
|
+
image_paths: Optional[Sequence[Path]] = None # Array of image paths for VLM (None if none)
|
|
132
|
+
audio_paths: Optional[Sequence[Path]] = None # Array of audio paths for VLM (None if none)
|
|
142
133
|
|
|
143
134
|
|
|
144
135
|
@dataclass
|
|
@@ -179,32 +170,6 @@ class RerankConfig:
|
|
|
179
170
|
normalize_method: str = "softmax" # "softmax" | "min-max" | "none"
|
|
180
171
|
|
|
181
172
|
|
|
182
|
-
# image-gen
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
@dataclass
|
|
186
|
-
class ImageGenTxt2ImgInput:
|
|
187
|
-
"""Input structure for text-to-image generation."""
|
|
188
|
-
prompt: str
|
|
189
|
-
config: ImageGenerationConfig
|
|
190
|
-
output_path: Optional[Path] = None
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
@dataclass
|
|
194
|
-
class ImageGenImg2ImgInput:
|
|
195
|
-
"""Input structure for image-to-image generation."""
|
|
196
|
-
init_image_path: Path
|
|
197
|
-
prompt: str
|
|
198
|
-
config: ImageGenerationConfig
|
|
199
|
-
output_path: Optional[Path] = None
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
@dataclass
|
|
203
|
-
class ImageGenOutput:
|
|
204
|
-
"""Output structure for image generation."""
|
|
205
|
-
output_image_path: Path
|
|
206
|
-
|
|
207
|
-
|
|
208
173
|
@dataclass
|
|
209
174
|
class ImageSamplerConfig:
|
|
210
175
|
"""Configuration for image sampling."""
|
|
@@ -215,27 +180,17 @@ class ImageSamplerConfig:
|
|
|
215
180
|
seed: int = -1 # –1 for random
|
|
216
181
|
|
|
217
182
|
|
|
218
|
-
@dataclass
|
|
219
|
-
class ImageGenCreateInput:
|
|
220
|
-
"""Configuration for image generation."""
|
|
221
|
-
model_name: str
|
|
222
|
-
model_path: Path
|
|
223
|
-
config: ModelConfig
|
|
224
|
-
scheduler_config_path: Path
|
|
225
|
-
plugin_id: str
|
|
226
|
-
device_id: Optional[str] = None
|
|
227
|
-
|
|
228
|
-
|
|
229
183
|
@dataclass
|
|
230
184
|
class ImageGenerationConfig:
|
|
231
185
|
"""Configuration for image generation."""
|
|
232
|
-
prompts: List[str]
|
|
233
|
-
|
|
234
|
-
scheduler_config: SchedulerConfig
|
|
235
|
-
strength: float
|
|
236
|
-
negative_prompts: Optional[List[str]] = None
|
|
186
|
+
prompts: str | List[str]
|
|
187
|
+
negative_prompts: str | List[str] | None = None
|
|
237
188
|
height: int = 512
|
|
238
189
|
width: int = 512
|
|
190
|
+
sampler_config: Optional[ImageSamplerConfig] = None
|
|
191
|
+
lora_id: int = -1 # –1 for none
|
|
192
|
+
init_image: Optional[Image] = None
|
|
193
|
+
strength: float = 1.0
|
|
239
194
|
|
|
240
195
|
|
|
241
196
|
@dataclass
|
|
@@ -306,7 +261,7 @@ class TTSResult:
|
|
|
306
261
|
class BoundingBox:
|
|
307
262
|
"""Generic bounding box structure."""
|
|
308
263
|
x: float # X coordinate (normalized or pixel, depends on model)
|
|
309
|
-
y: float # Y coordinate (normalized or pixel, depends on model)
|
|
264
|
+
y: float # Y coordinate (normalized or pixel, depends on model)
|
|
310
265
|
width: float # Width
|
|
311
266
|
height: float # Height
|
|
312
267
|
|
|
@@ -320,8 +275,7 @@ class CVResult:
|
|
|
320
275
|
confidence: float = 0.0 # Confidence score [0.0-1.0]
|
|
321
276
|
bbox: Optional[BoundingBox] = None # Bounding box (example: YOLO)
|
|
322
277
|
text: Optional[str] = None # Text result (example: OCR)
|
|
323
|
-
# Feature embedding (example: CLIP embedding)
|
|
324
|
-
embedding: Optional[List[float]] = None
|
|
278
|
+
embedding: Optional[List[float]] = None # Feature embedding (example: CLIP embedding)
|
|
325
279
|
embedding_dim: int = 0 # Embedding dimension
|
|
326
280
|
|
|
327
281
|
|
nexaai/mlx_backend/ml.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
# This file defines the python interface that c-lib expects from a python backend
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from typing import Optional
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from dataclasses import dataclass
|
|
7
4
|
|
|
8
5
|
from abc import ABC, abstractmethod
|
|
9
6
|
from dataclasses import dataclass, field
|
|
@@ -104,12 +101,9 @@ class ModelConfig:
|
|
|
104
101
|
n_threads_batch: int = 0 # number of threads to use for batch processing
|
|
105
102
|
n_batch: int = 0 # logical maximum batch size that can be submitted to llama_decode
|
|
106
103
|
n_ubatch: int = 0 # physical maximum batch size
|
|
107
|
-
# max number of sequences (i.e. distinct states for recurrent models)
|
|
108
|
-
|
|
109
|
-
#
|
|
110
|
-
chat_template_path: Optional[Path] = None
|
|
111
|
-
# content of chat template file, optional
|
|
112
|
-
chat_template_content: Optional[str] = None
|
|
104
|
+
n_seq_max: int = 0 # max number of sequences (i.e. distinct states for recurrent models)
|
|
105
|
+
chat_template_path: Optional[Path] = None # path to chat template file, optional
|
|
106
|
+
chat_template_content: Optional[str] = None # content of chat template file, optional
|
|
113
107
|
|
|
114
108
|
|
|
115
109
|
@dataclass
|
|
@@ -124,8 +118,7 @@ class SamplerConfig:
|
|
|
124
118
|
frequency_penalty: float = 0.0
|
|
125
119
|
seed: int = -1 # –1 for random
|
|
126
120
|
grammar_path: Optional[Path] = None
|
|
127
|
-
# Optional grammar string (BNF-like format)
|
|
128
|
-
grammar_string: Optional[str] = None
|
|
121
|
+
grammar_string: Optional[str] = None # Optional grammar string (BNF-like format)
|
|
129
122
|
|
|
130
123
|
|
|
131
124
|
@dataclass
|
|
@@ -135,10 +128,8 @@ class GenerationConfig:
|
|
|
135
128
|
stop: Sequence[str] = field(default_factory=tuple)
|
|
136
129
|
n_past: int = 0
|
|
137
130
|
sampler_config: Optional[SamplerConfig] = None
|
|
138
|
-
# Array of image paths for VLM (None if none)
|
|
139
|
-
|
|
140
|
-
# Array of audio paths for VLM (None if none)
|
|
141
|
-
audio_paths: Optional[Sequence[Path]] = None
|
|
131
|
+
image_paths: Optional[Sequence[Path]] = None # Array of image paths for VLM (None if none)
|
|
132
|
+
audio_paths: Optional[Sequence[Path]] = None # Array of audio paths for VLM (None if none)
|
|
142
133
|
|
|
143
134
|
|
|
144
135
|
@dataclass
|
|
@@ -179,32 +170,6 @@ class RerankConfig:
|
|
|
179
170
|
normalize_method: str = "softmax" # "softmax" | "min-max" | "none"
|
|
180
171
|
|
|
181
172
|
|
|
182
|
-
# image-gen
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
@dataclass
|
|
186
|
-
class ImageGenTxt2ImgInput:
|
|
187
|
-
"""Input structure for text-to-image generation."""
|
|
188
|
-
prompt: str
|
|
189
|
-
config: ImageGenerationConfig
|
|
190
|
-
output_path: Optional[Path] = None
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
@dataclass
|
|
194
|
-
class ImageGenImg2ImgInput:
|
|
195
|
-
"""Input structure for image-to-image generation."""
|
|
196
|
-
init_image_path: Path
|
|
197
|
-
prompt: str
|
|
198
|
-
config: ImageGenerationConfig
|
|
199
|
-
output_path: Optional[Path] = None
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
@dataclass
|
|
203
|
-
class ImageGenOutput:
|
|
204
|
-
"""Output structure for image generation."""
|
|
205
|
-
output_image_path: Path
|
|
206
|
-
|
|
207
|
-
|
|
208
173
|
@dataclass
|
|
209
174
|
class ImageSamplerConfig:
|
|
210
175
|
"""Configuration for image sampling."""
|
|
@@ -215,27 +180,17 @@ class ImageSamplerConfig:
|
|
|
215
180
|
seed: int = -1 # –1 for random
|
|
216
181
|
|
|
217
182
|
|
|
218
|
-
@dataclass
|
|
219
|
-
class ImageGenCreateInput:
|
|
220
|
-
"""Configuration for image generation."""
|
|
221
|
-
model_name: str
|
|
222
|
-
model_path: Path
|
|
223
|
-
config: ModelConfig
|
|
224
|
-
scheduler_config_path: Path
|
|
225
|
-
plugin_id: str
|
|
226
|
-
device_id: Optional[str] = None
|
|
227
|
-
|
|
228
|
-
|
|
229
183
|
@dataclass
|
|
230
184
|
class ImageGenerationConfig:
|
|
231
185
|
"""Configuration for image generation."""
|
|
232
|
-
prompts: List[str]
|
|
233
|
-
|
|
234
|
-
scheduler_config: SchedulerConfig
|
|
235
|
-
strength: float
|
|
236
|
-
negative_prompts: Optional[List[str]] = None
|
|
186
|
+
prompts: str | List[str]
|
|
187
|
+
negative_prompts: str | List[str] | None = None
|
|
237
188
|
height: int = 512
|
|
238
189
|
width: int = 512
|
|
190
|
+
sampler_config: Optional[ImageSamplerConfig] = None
|
|
191
|
+
lora_id: int = -1 # –1 for none
|
|
192
|
+
init_image: Optional[Image] = None
|
|
193
|
+
strength: float = 1.0
|
|
239
194
|
|
|
240
195
|
|
|
241
196
|
@dataclass
|
|
@@ -306,7 +261,7 @@ class TTSResult:
|
|
|
306
261
|
class BoundingBox:
|
|
307
262
|
"""Generic bounding box structure."""
|
|
308
263
|
x: float # X coordinate (normalized or pixel, depends on model)
|
|
309
|
-
y: float # Y coordinate (normalized or pixel, depends on model)
|
|
264
|
+
y: float # Y coordinate (normalized or pixel, depends on model)
|
|
310
265
|
width: float # Width
|
|
311
266
|
height: float # Height
|
|
312
267
|
|
|
@@ -320,8 +275,7 @@ class CVResult:
|
|
|
320
275
|
confidence: float = 0.0 # Confidence score [0.0-1.0]
|
|
321
276
|
bbox: Optional[BoundingBox] = None # Bounding box (example: YOLO)
|
|
322
277
|
text: Optional[str] = None # Text result (example: OCR)
|
|
323
|
-
# Feature embedding (example: CLIP embedding)
|
|
324
|
-
embedding: Optional[List[float]] = None
|
|
278
|
+
embedding: Optional[List[float]] = None # Feature embedding (example: CLIP embedding)
|
|
325
279
|
embedding_dim: int = 0 # Embedding dimension
|
|
326
280
|
|
|
327
281
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Copyright © 2023-2024 Apple Inc.
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
import os
|
|
5
4
|
from typing import Optional
|
|
6
5
|
|
|
7
6
|
import mlx.core as mx
|
|
@@ -177,37 +176,19 @@ def _load_safetensor_weights(mapper, model, weight_file, float16: bool = False):
|
|
|
177
176
|
|
|
178
177
|
|
|
179
178
|
def _check_key(key: str, part: str):
|
|
180
|
-
# Check if it's a local path
|
|
181
|
-
if os.path.exists(key) or '/' in key or '\\' in key:
|
|
182
|
-
# For local paths, we'll use a default model structure
|
|
183
|
-
return
|
|
184
179
|
if key not in _MODELS:
|
|
185
180
|
raise ValueError(
|
|
186
181
|
f"[{part}] '{key}' model not found, choose one of {{{','.join(_MODELS.keys())}}}"
|
|
187
182
|
)
|
|
188
183
|
|
|
189
|
-
def _get_model_path(key: str, file_path: str):
|
|
190
|
-
"""Get the full path for a model file, supporting both local and HuggingFace paths"""
|
|
191
|
-
if os.path.exists(key) or '/' in key or '\\' in key:
|
|
192
|
-
# Local path
|
|
193
|
-
return os.path.join(key, file_path)
|
|
194
|
-
else:
|
|
195
|
-
# HuggingFace path
|
|
196
|
-
return hf_hub_download(key, file_path)
|
|
197
|
-
|
|
198
184
|
|
|
199
185
|
def load_unet(key: str = _DEFAULT_MODEL, float16: bool = False):
|
|
200
186
|
"""Load the stable diffusion UNet from Hugging Face Hub."""
|
|
201
187
|
_check_key(key, "load_unet")
|
|
202
188
|
|
|
203
|
-
#
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
unet_config = "unet/config.json"
|
|
207
|
-
else:
|
|
208
|
-
unet_config = _MODELS[key]["unet_config"]
|
|
209
|
-
|
|
210
|
-
with open(_get_model_path(key, unet_config)) as f:
|
|
189
|
+
# Download the config and create the model
|
|
190
|
+
unet_config = _MODELS[key]["unet_config"]
|
|
191
|
+
with open(hf_hub_download(key, unet_config)) as f:
|
|
211
192
|
config = json.load(f)
|
|
212
193
|
|
|
213
194
|
n_blocks = len(config["block_out_channels"])
|
|
@@ -238,13 +219,8 @@ def load_unet(key: str = _DEFAULT_MODEL, float16: bool = False):
|
|
|
238
219
|
)
|
|
239
220
|
|
|
240
221
|
# Download the weights and map them into the model
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
unet_weights = "unet/diffusion_pytorch_model.safetensors"
|
|
244
|
-
else:
|
|
245
|
-
unet_weights = _MODELS[key]["unet"]
|
|
246
|
-
|
|
247
|
-
weight_file = _get_model_path(key, unet_weights)
|
|
222
|
+
unet_weights = _MODELS[key]["unet"]
|
|
223
|
+
weight_file = hf_hub_download(key, unet_weights)
|
|
248
224
|
_load_safetensor_weights(map_unet_weights, model, weight_file, float16)
|
|
249
225
|
|
|
250
226
|
return model
|
|
@@ -262,13 +238,8 @@ def load_text_encoder(
|
|
|
262
238
|
config_key = config_key or (model_key + "_config")
|
|
263
239
|
|
|
264
240
|
# Download the config and create the model
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
text_encoder_config = f"{model_key}/config.json"
|
|
268
|
-
else:
|
|
269
|
-
text_encoder_config = _MODELS[key][config_key]
|
|
270
|
-
|
|
271
|
-
with open(_get_model_path(key, text_encoder_config)) as f:
|
|
241
|
+
text_encoder_config = _MODELS[key][config_key]
|
|
242
|
+
with open(hf_hub_download(key, text_encoder_config)) as f:
|
|
272
243
|
config = json.load(f)
|
|
273
244
|
|
|
274
245
|
with_projection = "WithProjection" in config["architectures"][0]
|
|
@@ -286,13 +257,8 @@ def load_text_encoder(
|
|
|
286
257
|
)
|
|
287
258
|
|
|
288
259
|
# Download the weights and map them into the model
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
text_encoder_weights = f"{model_key}/model.safetensors"
|
|
292
|
-
else:
|
|
293
|
-
text_encoder_weights = _MODELS[key][model_key]
|
|
294
|
-
|
|
295
|
-
weight_file = _get_model_path(key, text_encoder_weights)
|
|
260
|
+
text_encoder_weights = _MODELS[key][model_key]
|
|
261
|
+
weight_file = hf_hub_download(key, text_encoder_weights)
|
|
296
262
|
_load_safetensor_weights(map_clip_text_encoder_weights, model, weight_file, float16)
|
|
297
263
|
|
|
298
264
|
return model
|
|
@@ -303,13 +269,8 @@ def load_autoencoder(key: str = _DEFAULT_MODEL, float16: bool = False):
|
|
|
303
269
|
_check_key(key, "load_autoencoder")
|
|
304
270
|
|
|
305
271
|
# Download the config and create the model
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
vae_config = "vae/config.json"
|
|
309
|
-
else:
|
|
310
|
-
vae_config = _MODELS[key]["vae_config"]
|
|
311
|
-
|
|
312
|
-
with open(_get_model_path(key, vae_config)) as f:
|
|
272
|
+
vae_config = _MODELS[key]["vae_config"]
|
|
273
|
+
with open(hf_hub_download(key, vae_config)) as f:
|
|
313
274
|
config = json.load(f)
|
|
314
275
|
|
|
315
276
|
model = Autoencoder(
|
|
@@ -326,13 +287,8 @@ def load_autoencoder(key: str = _DEFAULT_MODEL, float16: bool = False):
|
|
|
326
287
|
)
|
|
327
288
|
|
|
328
289
|
# Download the weights and map them into the model
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
vae_weights = "vae/diffusion_pytorch_model.safetensors"
|
|
332
|
-
else:
|
|
333
|
-
vae_weights = _MODELS[key]["vae"]
|
|
334
|
-
|
|
335
|
-
weight_file = _get_model_path(key, vae_weights)
|
|
290
|
+
vae_weights = _MODELS[key]["vae"]
|
|
291
|
+
weight_file = hf_hub_download(key, vae_weights)
|
|
336
292
|
_load_safetensor_weights(map_vae_weights, model, weight_file, float16)
|
|
337
293
|
|
|
338
294
|
return model
|
|
@@ -342,13 +298,8 @@ def load_diffusion_config(key: str = _DEFAULT_MODEL):
|
|
|
342
298
|
"""Load the stable diffusion config from Hugging Face Hub."""
|
|
343
299
|
_check_key(key, "load_diffusion_config")
|
|
344
300
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
diffusion_config = "scheduler/scheduler_config.json"
|
|
348
|
-
else:
|
|
349
|
-
diffusion_config = _MODELS[key]["diffusion_config"]
|
|
350
|
-
|
|
351
|
-
with open(_get_model_path(key, diffusion_config)) as f:
|
|
301
|
+
diffusion_config = _MODELS[key]["diffusion_config"]
|
|
302
|
+
with open(hf_hub_download(key, diffusion_config)) as f:
|
|
352
303
|
config = json.load(f)
|
|
353
304
|
|
|
354
305
|
return DiffusionConfig(
|
|
@@ -366,17 +317,11 @@ def load_tokenizer(
|
|
|
366
317
|
):
|
|
367
318
|
_check_key(key, "load_tokenizer")
|
|
368
319
|
|
|
369
|
-
|
|
370
|
-
# Local path - use SDXL Turbo structure
|
|
371
|
-
vocab_file = _get_model_path(key, f"tokenizer/{vocab_key.split('_')[1]}.json")
|
|
372
|
-
merges_file = _get_model_path(key, f"tokenizer/{merges_key.split('_')[1]}.txt")
|
|
373
|
-
else:
|
|
374
|
-
vocab_file = _get_model_path(key, _MODELS[key][vocab_key])
|
|
375
|
-
merges_file = _get_model_path(key, _MODELS[key][merges_key])
|
|
376
|
-
|
|
320
|
+
vocab_file = hf_hub_download(key, _MODELS[key][vocab_key])
|
|
377
321
|
with open(vocab_file, encoding="utf-8") as f:
|
|
378
322
|
vocab = json.load(f)
|
|
379
323
|
|
|
324
|
+
merges_file = hf_hub_download(key, _MODELS[key][merges_key])
|
|
380
325
|
with open(merges_file, encoding="utf-8") as f:
|
|
381
326
|
bpe_merges = f.read().strip().split("\n")[1 : 49152 - 256 - 2 + 1]
|
|
382
327
|
bpe_merges = [tuple(m.split()) for m in bpe_merges]
|
nexaai/runtime.py
CHANGED
|
@@ -28,10 +28,6 @@ def _shutdown_runtime() -> None:
|
|
|
28
28
|
# Public helper so advanced users can reclaim memory on demand
|
|
29
29
|
shutdown = _shutdown_runtime
|
|
30
30
|
|
|
31
|
-
def is_initialized() -> bool:
|
|
32
|
-
"""Check if the runtime has been initialized."""
|
|
33
|
-
return _runtime_alive
|
|
34
|
-
|
|
35
31
|
# ----------------------------------------------------------------------
|
|
36
32
|
# Single public class
|
|
37
33
|
# ----------------------------------------------------------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
nexaai/__init__.py,sha256=
|
|
2
|
-
nexaai/_stub.cpython-310-darwin.so,sha256=
|
|
3
|
-
nexaai/_version.py,sha256=
|
|
1
|
+
nexaai/__init__.py,sha256=jXdC4vv6DBK1fVewYTYSUhOOYfvf_Mk81UIeMGGIKUg,2029
|
|
2
|
+
nexaai/_stub.cpython-310-darwin.so,sha256=Izt7MU4HQisUgbHwKkOH1Uo_GRUa9INqjjoGcBiZv5s,66768
|
|
3
|
+
nexaai/_version.py,sha256=rM7mysA3I6mJ-jXt3DwjydINMplIqs78L_Oid1wMpI8,144
|
|
4
4
|
nexaai/asr.py,sha256=NljMXDErwPNMOPaRkJZMEDka9Nk8xyur7L8i924TStY,2054
|
|
5
5
|
nexaai/base.py,sha256=N8PRgDFA-XPku2vWnQIofQ7ipz3pPlO6f8YZGnuhquE,982
|
|
6
6
|
nexaai/common.py,sha256=yBnIbqYaQYnfrl7IczOBh6MDibYZVxwaRJEglYcKgGs,3422
|
|
@@ -8,19 +8,18 @@ nexaai/cv.py,sha256=RHCDo8gvBH8BkGZx7qVyp-OKxqi7E1GG9XzyaXehCNA,3273
|
|
|
8
8
|
nexaai/embedder.py,sha256=Cw0tSHkPgd-RI62afCqQAcTHMnQhaI2CvfTMO-1JKOg,2452
|
|
9
9
|
nexaai/image_gen.py,sha256=0C_5Tjj4BYmxLbmMmvwajp-yy2mmEEOKwBFnDQNPzx4,4356
|
|
10
10
|
nexaai/llm.py,sha256=S1o_k2VQoF5w2wO25f142OO1R75TP89Ii69VZv8pIGo,3567
|
|
11
|
-
nexaai/log.py,sha256=Kwo2CIfWN6iP4M4F5EUIV8KIO5hAsvz6HZAaOwJ27Og,2628
|
|
12
11
|
nexaai/rerank.py,sha256=vWaBucoQ1wz-2iYnZqyFIcEjm-4Xcs1KDbFN5X8zzDQ,1872
|
|
13
|
-
nexaai/runtime.py,sha256=
|
|
12
|
+
nexaai/runtime.py,sha256=mxxHYsb5iBUAm2K_u-XJWr_U-spJ9S4eApc8kf9myjw,1957
|
|
14
13
|
nexaai/tts.py,sha256=ZnBpWUxIfHhh7KfEjddtH7hHOTa91zg7ogGLakMIALo,2167
|
|
15
14
|
nexaai/vlm.py,sha256=OCxwML-Z5uVGp3fjzJVtbCxfTLpgxkhQ8Wo6MVysoiw,4733
|
|
16
15
|
nexaai/asr_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
16
|
nexaai/asr_impl/mlx_asr_impl.py,sha256=eosd8-TIWAOwV0HltmoFrLwzXHcU4jyxtncvuZE9pgA,3257
|
|
18
17
|
nexaai/asr_impl/pybind_asr_impl.py,sha256=pE9Hb_hMi5yAc4MF83bLVOb8zDtreCkB3_u7XED9YpA,1516
|
|
19
18
|
nexaai/binds/__init__.py,sha256=eYuay_8DDXeOUWz2_R9HFSabohxs6hvZn391t2L0Po0,104
|
|
20
|
-
nexaai/binds/common_bind.cpython-310-darwin.so,sha256=
|
|
19
|
+
nexaai/binds/common_bind.cpython-310-darwin.so,sha256=hVxY76tn7hN6uHDIgM7LWNvgoudHgNZVoaygM9X1RWE,217232
|
|
21
20
|
nexaai/binds/embedder_bind.cpython-310-darwin.so,sha256=tPa0c0Dv_GiW66fgmAGWGCHXRGNApznqoQS0eQx9GFM,202064
|
|
22
|
-
nexaai/binds/libnexa_bridge.dylib,sha256=
|
|
23
|
-
nexaai/binds/llm_bind.cpython-310-darwin.so,sha256=
|
|
21
|
+
nexaai/binds/libnexa_bridge.dylib,sha256=EsxYPjSQUQ6sbqhVcfFF10beAY8EAudisHH56uB0xg0,251144
|
|
22
|
+
nexaai/binds/llm_bind.cpython-310-darwin.so,sha256=6vRO5eOsL6s-hCKdz6onIjBKR_wcpCIsXHtUJY9vJBI,182704
|
|
24
23
|
nexaai/binds/vlm_bind.cpython-310-darwin.so,sha256=nd6eG_m2EiPthzkSZ97hlXWUOZQir4cQfFJZ4p6eR2U,182704
|
|
25
24
|
nexaai/binds/nexa_llama_cpp/libggml-base.dylib,sha256=JM4oOkie1su0ES5hMdtILeQHlRukRzH1vTleTupUXhg,650736
|
|
26
25
|
nexaai/binds/nexa_llama_cpp/libggml-cpu.so,sha256=qiYxbTe4Nt7n36zJVvq3zovgSZEmrN2is6gzTern7UI,677728
|
|
@@ -28,9 +27,9 @@ nexaai/binds/nexa_llama_cpp/libggml-metal.so,sha256=zfaX7rIBYQazH2lf-vza007BMhPT
|
|
|
28
27
|
nexaai/binds/nexa_llama_cpp/libggml.dylib,sha256=aOTj_6RrAMkfDO0ZI28_3nfcC-l4Y3dRCiS3C0d0_eI,58592
|
|
29
28
|
nexaai/binds/nexa_llama_cpp/libllama.dylib,sha256=RkBd5usb8RvEIOamvxCW3UvMauI5bC66G_n6hw83NpY,1786128
|
|
30
29
|
nexaai/binds/nexa_llama_cpp/libmtmd.dylib,sha256=o6mQqefzQNF0CS4j6odwJKj0gkXm15hIxwlNt88FOn4,605248
|
|
31
|
-
nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib,sha256=
|
|
32
|
-
nexaai/binds/nexa_mlx/libnexa_plugin.dylib,sha256=
|
|
33
|
-
nexaai/binds/nexa_mlx/py-lib/ml.py,sha256=
|
|
30
|
+
nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib,sha256=4rTxwHGSVUfGnvA6laPpLztMMFooy-inG2798HXqKPY,1862104
|
|
31
|
+
nexaai/binds/nexa_mlx/libnexa_plugin.dylib,sha256=pSLYF-LN-s6ZaJomznSY8G6cNeKNwnsE2gZAaLfUdTw,598328
|
|
32
|
+
nexaai/binds/nexa_mlx/py-lib/ml.py,sha256=LafDM_TeXmuQkld2tdQxUBGgooT0JPMXngLam2TADqU,23179
|
|
34
33
|
nexaai/binds/nexa_mlx/py-lib/profiling.py,sha256=Dc-mybFwBdCIKFWL7CbSHjkOJGAoYHG7r_e_XPhzwBU,9361
|
|
35
34
|
nexaai/binds/nexa_mlx/py-lib/mlx_audio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
35
|
nexaai/binds/nexa_mlx/py-lib/mlx_audio/server.py,sha256=Pqy13Fafq4WX_cTuvRFz1jq89beQm2QQGpXmhK4b9jc,17547
|
|
@@ -194,7 +193,7 @@ nexaai/image_gen_impl/pybind_image_gen_impl.py,sha256=ms34VYoD5AxZFG6cIG0QAJDjCt
|
|
|
194
193
|
nexaai/llm_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
195
194
|
nexaai/llm_impl/mlx_llm_impl.py,sha256=4v7jUFzHfE7zw2uViekGQDaTROz8A6oaW31Z3iVe6tg,11157
|
|
196
195
|
nexaai/llm_impl/pybind_llm_impl.py,sha256=aooqkcXZWhCo07wbSafGgBrA3WnijtnUADShjjgFsBQ,8051
|
|
197
|
-
nexaai/mlx_backend/ml.py,sha256=
|
|
196
|
+
nexaai/mlx_backend/ml.py,sha256=LafDM_TeXmuQkld2tdQxUBGgooT0JPMXngLam2TADqU,23179
|
|
198
197
|
nexaai/mlx_backend/profiling.py,sha256=Dc-mybFwBdCIKFWL7CbSHjkOJGAoYHG7r_e_XPhzwBU,9361
|
|
199
198
|
nexaai/mlx_backend/asr/__init__.py,sha256=fuT_9_xpYJ28m4yjly5L2jChUrzlSQz-b_S7nujxkSM,451
|
|
200
199
|
nexaai/mlx_backend/asr/interface.py,sha256=pE5expr8sP7O9bEgWaUaJ4ITX0MsCxFovG9iVWqVDVU,4246
|
|
@@ -211,18 +210,6 @@ nexaai/mlx_backend/embedding/interface.py,sha256=M7AGiq_UVLNIi2Ie6H08ySnMxIjIhUl
|
|
|
211
210
|
nexaai/mlx_backend/embedding/main.py,sha256=xKRebBcooKuf8DzWKwCicftes3MAcYAd1QvcT9_AAPQ,6003
|
|
212
211
|
nexaai/mlx_backend/embedding/modeling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
213
212
|
nexaai/mlx_backend/embedding/modeling/nexa_jina_v2.py,sha256=F9Z_9r-Dh0wNThiMp5W5hqE2dt5bf4ps5_c6h4BuWGw,15218
|
|
214
|
-
nexaai/mlx_backend/image_gen/__init__.py,sha256=8eFAF00-yWdEs0LJiszjHEsgPDAF8tSruBYvujCNgE0,42
|
|
215
|
-
nexaai/mlx_backend/image_gen/generate_sd.py,sha256=8DuPsJlxVf1LlFARVThiW807G-0cWPReYONj-x8qKRo,8616
|
|
216
|
-
nexaai/mlx_backend/image_gen/interface.py,sha256=7ElIiLm5gZXAfKPs497wLkn8qqLFLL5T-oV-hXVmEdw,3285
|
|
217
|
-
nexaai/mlx_backend/image_gen/main.py,sha256=jKkGDfqmGIsQwhHJaL_j_CTtr04xplD6dnnGe3AcilU,8123
|
|
218
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/__init__.py,sha256=wriLb0wA5vCBlCoQMtfKrVVWMJw8fhXCCk6R9_Nrb9c,9524
|
|
219
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/clip.py,sha256=feHQXi1NiGa01AMo7nK8M-sgBoZBHI95xAGMfAv64kE,3733
|
|
220
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/config.py,sha256=lq2sWXevpnCk8KXOywEVOzgFT6WBNnG4xr7NLWgidII,1773
|
|
221
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/model_io.py,sha256=ei-pdrqFxjeHLL6Ov5NZaHT5lceqZbHDyNFfUFUh_04,13755
|
|
222
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/sampler.py,sha256=nJxiSmF79E2aDGzLqygOat4zpgaTzfR7Kp1PD0bmhWA,3397
|
|
223
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/tokenizer.py,sha256=WMcmyQmb5MmhCp-NNU72Bqjq9vQvDzgR8KAfGKA2Qso,2991
|
|
224
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/unet.py,sha256=rYj1-baAugL7CNyYYvLch891WUgpunhAJCVBNKxfZSA,14762
|
|
225
|
-
nexaai/mlx_backend/image_gen/stable_diffusion/vae.py,sha256=sQ1943x5SKyTmeL2xe3t84FL9DGO72Eab2m88r-BSe8,8044
|
|
226
213
|
nexaai/mlx_backend/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
227
214
|
nexaai/mlx_backend/llm/generate.py,sha256=Phes0tzxbbEWA2hDylQvD0LjorMaPwvcfZq9RKCAOt0,4399
|
|
228
215
|
nexaai/mlx_backend/llm/interface.py,sha256=SZFkuAUi2vxj_dSqj8RXf9vPTGMtpks_pZxxrF7iIe8,29330
|
|
@@ -390,7 +377,7 @@ nexaai/mlx_backend/sd/main.py,sha256=cHlZhG8KHDFXbYRH-diKA7B1Qacq1euuGw0pKeXJGAI
|
|
|
390
377
|
nexaai/mlx_backend/sd/modeling/__init__.py,sha256=wriLb0wA5vCBlCoQMtfKrVVWMJw8fhXCCk6R9_Nrb9c,9524
|
|
391
378
|
nexaai/mlx_backend/sd/modeling/clip.py,sha256=feHQXi1NiGa01AMo7nK8M-sgBoZBHI95xAGMfAv64kE,3733
|
|
392
379
|
nexaai/mlx_backend/sd/modeling/config.py,sha256=lq2sWXevpnCk8KXOywEVOzgFT6WBNnG4xr7NLWgidII,1773
|
|
393
|
-
nexaai/mlx_backend/sd/modeling/model_io.py,sha256=
|
|
380
|
+
nexaai/mlx_backend/sd/modeling/model_io.py,sha256=0jpMHJdMoTk0Jo4Uz1ZGiXekAWzPuTTD5g7ms4m4idY,11668
|
|
394
381
|
nexaai/mlx_backend/sd/modeling/sampler.py,sha256=nJxiSmF79E2aDGzLqygOat4zpgaTzfR7Kp1PD0bmhWA,3397
|
|
395
382
|
nexaai/mlx_backend/sd/modeling/tokenizer.py,sha256=WMcmyQmb5MmhCp-NNU72Bqjq9vQvDzgR8KAfGKA2Qso,2991
|
|
396
383
|
nexaai/mlx_backend/sd/modeling/unet.py,sha256=rYj1-baAugL7CNyYYvLch891WUgpunhAJCVBNKxfZSA,14762
|
|
@@ -541,7 +528,7 @@ nexaai/utils/quantization_utils.py,sha256=4gvp6UQfSO9G1FYBwnFtQspTzH9sDbi1PBXw2t
|
|
|
541
528
|
nexaai/vlm_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
542
529
|
nexaai/vlm_impl/mlx_vlm_impl.py,sha256=pLtWm_ckz8a0U-AtAOMVseFDO4OVPvHyYO2KlfBaGYk,10833
|
|
543
530
|
nexaai/vlm_impl/pybind_vlm_impl.py,sha256=FAbhpRJzHgI78r0mUvKybO97R1szvNhH0aTn_I52oT4,8597
|
|
544
|
-
nexaai-1.0.
|
|
545
|
-
nexaai-1.0.
|
|
546
|
-
nexaai-1.0.
|
|
547
|
-
nexaai-1.0.
|
|
531
|
+
nexaai-1.0.16rc10.dist-info/METADATA,sha256=_p5OXiFfM3Nb6BN_grqE9--aJ4A9bz_B84UPqWYxp9I,1202
|
|
532
|
+
nexaai-1.0.16rc10.dist-info/WHEEL,sha256=T2p57lol9__xkoU6aJTyN1Pm43ZpRU3q6km7mIbrAMs,114
|
|
533
|
+
nexaai-1.0.16rc10.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
|
|
534
|
+
nexaai-1.0.16rc10.dist-info/RECORD,,
|