Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/ml-explore/mlx-examples
/ functions
Functions
1,187 in github.com/ml-explore/mlx-examples
⨍
Functions
1,187
◇
Types & classes
308
↳
Endpoints
13
↓ 3 callers
Function
non_max_supression
( boxes: mx.array, scores: mx.array, iou_threshold: float = 0.5 )
segment_anything/segment_anything/automatic_mask_generator.py:406
↓ 3 callers
Function
parse_kwt_args
(**kwargs)
speechcommands/kwt.py:162
↓ 3 callers
Function
prepare_dataset
(batch_size, split, root=None)
speechcommands/main.py:27
↓ 3 callers
Function
replace_key
(key: str)
bert/convert.py:7
↓ 3 callers
Method
reset_image
Resets the currently set image.
segment_anything/segment_anything/predictor.py:163
↓ 3 callers
Function
run
(bert_model: str, mlx_model: str, batch: List[str])
bert/model.py:137
↓ 3 callers
Method
transcribe
(self)
whisper/mlx_whisper/tokenizer.py:182
↓ 3 callers
Function
wikitext
Load the WikiText-* language modeling dataset: https://paperswithcode.com/dataset/wikitext-2 https://paperswithcode.com/dataset/w
transformer_lm/datasets.py:43
↓ 2 callers
Method
__init__
( self, input_dim: int, hidden_dim: int, output_dim: int, num_layers:
segment_anything/segment_anything/mask_decoder.py:176
↓ 2 callers
Method
__init__
( self, embedding_dim: int, num_heads: int, downsample_rate: int = 1, )
segment_anything/segment_anything/transformer.py:184
↓ 2 callers
Method
__init__
(self, embed_dim, mask_in_chans, activation)
segment_anything/segment_anything/prompt_encoder.py:173
↓ 2 callers
Method
__init__
(self, in_dims, dims, stride=1)
cifar/resnet.py:39
↓ 2 callers
Method
__init__
(self)
video/wan2.1/wan/vae.py:277
↓ 2 callers
Function
_apply_rope
(x, pe)
flux/flux/layers.py:29
↓ 2 callers
Method
_attend
Compute self-attention. Returns attn output [B, n, L, d].
video/wan2.1/wan/layers.py:45
↓ 2 callers
Method
_decode_frame
( self, codes: mx.array, scale: Optional[mx.array] = None )
encodec/encodec.py:606
↓ 2 callers
Method
_decode_frame
( self, codes: mx.array, scale: Optional[mx.array] = None )
musicgen/encodec.py:606
↓ 2 callers
Function
_format_timestamp
(seconds: float)
whisper/mlx_whisper/transcribe.py:26
↓ 2 callers
Method
_generate
( self, x: mx.array, memory: mx.array, draft: bool = False, )
llms/speculative_decoding/decoder.py:55
↓ 2 callers
Method
_get_text_conditioning
( self, text: str, n_images: int = 1, cfg_weight: float = 7.5, negativ
stable_diffusion/stable_diffusion/__init__.py:46
↓ 2 callers
Method
_get_text_conditioning
( self, text: str, n_images: int = 1, cfg_weight: float = 7.5, negativ
stable_diffusion/stable_diffusion/__init__.py:199
↓ 2 callers
Function
_load
(save_dir, filenames)
transformer_lm/datasets.py:23
↓ 2 callers
Method
_pad1d
( self, hidden_states: mx.array, paddings: Tuple[int, int], mode: str = "zero"
encodec/encodec.py:137
↓ 2 callers
Method
_pad1d
( self, hidden_states: mx.array, paddings: Tuple[int, int], mode: str = "zero"
musicgen/encodec.py:137
↓ 2 callers
Method
_pe_encoding
Positionally encode points that are normalized to [0,1].
segment_anything/segment_anything/prompt_encoder.py:201
↓ 2 callers
Method
_prepare_latent_images
(self, x)
flux/flux/flux.py:53
↓ 2 callers
Function
_residual_gate
(x, y, gate)
video/wan2.1/wan/layers.py:22
↓ 2 callers
Method
_time_shift
(self, x, t)
flux/flux/sampler.py:15
↓ 2 callers
Method
add_noise
(self, x, t, key=None)
stable_diffusion/stable_diffusion/sampler.py:62
↓ 2 callers
Method
apply
Apply any filtering or masking to logits Parameters ---------- logits : mx.array, shape = (n_batch, vocab_size) p
whisper/mlx_whisper/decoding.py:287
↓ 2 callers
Method
apply_coords
Expects a mlx tensor with length 2 in the last dimension. Requires the original image size in (H, W) format.
segment_anything/segment_anything/utils/transforms.py:33
↓ 2 callers
Method
apply_mask
Transforms masked indices of `x` conditioned on unmasked indices using `func`.
normalizing_flow/bijectors.py:41
↓ 2 callers
Function
average_stats
(stats, count)
cifar/main.py:50
↓ 2 callers
Function
batched_mask_to_box
Calculates boxes in XYXY format around masks. Return [0,0,0,0] for an empty mask. For input shape C1xC2x...xHxW, the output shape is C1xC2x..
segment_anything/segment_anything/utils/amg.py:305
↓ 2 callers
Function
box_xyxy_to_xywh
(box_xyxy: mx.array)
segment_anything/segment_anything/utils/amg.py:85
↓ 2 callers
Function
crop_len
(orig_len, n_crops, overlap)
segment_anything/segment_anything/utils/amg.py:217
↓ 2 callers
Method
decode
(self, toks: List[int])
llms/gguf_llm/models.py:236
↓ 2 callers
Method
decode
(self, t: List[int])
llms/mistral/mistral.py:166
↓ 2 callers
Method
decode
(self, z)
cvae/vae.py:171
↓ 2 callers
Method
decode_with_timestamps
Timestamp tokens are above other special tokens' id range and are ignored by `decode()`. This method decodes given tokens with timest
whisper/mlx_whisper/tokenizer.py:170
↓ 2 callers
Method
encode
(self, s: str)
llms/mistral/mistral.py:163
↓ 2 callers
Method
encode
Encode video to latent. Args: x: Video tensor [F, H, W, C] (channels-last) Returns: Latent tensor [
video/wan2.1/wan/vae.py:368
↓ 2 callers
Method
ensure_models_are_loaded
(self)
flux/flux/flux.py:36
↓ 2 callers
Method
ensure_models_are_loaded
(self)
stable_diffusion/stable_diffusion/__init__.py:29
↓ 2 callers
Method
ensure_models_are_loaded
(self)
video/wan2.1/wan/pipeline.py:77
↓ 2 callers
Function
enwik8
Load the enwik8 language modeling dataset: https://mattmahoney.net/dc/textdata.html
transformer_lm/datasets.py:92
↓ 2 callers
Method
eos_id
(self)
llms/mixtral/mixtral.py:186
↓ 2 callers
Function
eval_fn
(dataset)
transformer_lm/main.py:90
↓ 2 callers
Function
eval_fn
(x, y)
gcn/main.py:25
↓ 2 callers
Function
evaluate
(model, dataset, loss, tokenizer, batch_size, num_batches)
lora/lora.py:225
↓ 2 callers
Method
forward
(self, x: Tensor)
whisper/mlx_whisper/torch_whisper.py:34
↓ 2 callers
Method
forward_and_log_det
(self, x: mx.array)
normalizing_flow/bijectors.py:10
↓ 2 callers
Method
forward_with_coords
Positionally encode points that are not normalized to [0,1].
segment_anything/segment_anything/prompt_encoder.py:222
↓ 2 callers
Method
from_dict
(cls, config)
flux/flux/t5.py:51
↓ 2 callers
Method
from_dict
(cls, params)
lora/models.py:39
↓ 2 callers
Method
from_pretrained
(cls, path_or_repo: str)
musicgen/musicgen.py:333
↓ 2 callers
Function
fun
()
encodec/benchmarks/bench_pt.py:18
↓ 2 callers
Function
fun
()
encodec/benchmarks/bench_mx.py:17
↓ 2 callers
Function
generate
(args)
llms/llama/llama.py:207
↓ 2 callers
Method
generate_latents
Generator yielding latents at each denoising step. First yield: conditioning tuple (for mx.eval by caller) Subsequent yields
video/wan2.1/wan/pipeline.py:215
↓ 2 callers
Function
generate_progress_images
Generate images to monitor the progress of the finetuning.
flux/dreambooth.py:19
↓ 2 callers
Function
get_features
(model, image_proc, iter)
clip/linear_probe.py:21
↓ 2 callers
Method
get_input_embeddings
( self, input_ids: Optional[mx.array] = None, pixel_values: Optional[mx.array] = None,
llava/llava.py:66
↓ 2 callers
Method
get_preprocess_shape
Compute the output size given input size and target long side length.
segment_anything/segment_anything/utils/transforms.py:55
↓ 2 callers
Function
get_rel_pos
Get relative positional embeddings according to the relative positions of query and key sizes. Args: q_size (int): size of qu
segment_anything/segment_anything/image_encoder.py:311
↓ 2 callers
Function
grid_image_from_batch
Generate a grid image from a batch of images. Assumes input has shape (B, H, W, C).
cvae/main.py:18
↓ 2 callers
Method
inverse_and_log_det
(self, y: mx.array)
normalizing_flow/bijectors.py:13
↓ 2 callers
Function
iterate_batches
(dset, tokenizer, batch_size, train=False)
lora/lora.py:193
↓ 2 callers
Method
iterate_result
( self, result: dict, options: Optional[dict] = None, *, max_line_widt
whisper/mlx_whisper/writers.py:73
↓ 2 callers
Method
linear_to_lora_layers
Swap the linear layers in the transformer blocks with LoRA layers.
flux/flux/flux.py:229
↓ 2 callers
Function
load_clip
(name: str)
flux/flux/utils.py:148
↓ 2 callers
Function
load_hf_models
(path)
llava/test.py:24
↓ 2 callers
Function
load_mlx_models
(path)
llava/test.py:18
↓ 2 callers
Function
load_model
(model_name: str)
llms/speculative_decoding/main.py:11
↓ 2 callers
Function
load_t5
(name: str)
flux/flux/utils.py:166
↓ 2 callers
Function
load_text_encoder
Load the stable diffusion text encoder from Hugging Face Hub.
stable_diffusion/stable_diffusion/model_io.py:229
↓ 2 callers
Function
load_tokenizer
( key: str = _DEFAULT_MODEL, vocab_key: str = "tokenizer_vocab", merges_key: str = "tokenizer_merg
stable_diffusion/stable_diffusion/model_io.py:313
↓ 2 callers
Function
load_torch_model
Load a Whisper ASR model Parameters ---------- name_or_path : str one of the official model names listed by `whisper.availab
whisper/convert.py:195
↓ 2 callers
Function
load_torch_weights_and_config
( name_or_path: str, download_root: str = None, )
whisper/convert.py:152
↓ 2 callers
Method
logits
Perform a forward pass on the decoder and return per-token logits
whisper/mlx_whisper/decoding.py:137
↓ 2 callers
Function
mask_to_rle_mlx
Encodes masks to an uncompressed RLE, in the format expected by pycoco tools.
segment_anything/segment_anything/utils/amg.py:101
↓ 2 callers
Function
mnist
Load the MNIST dataset in 4 tensors: train images, train labels, test images, and test labels. Checks `save_dir` for already downloaded
mnist/mnist.py:11
↓ 2 callers
Function
new_segment
( *, start: float, end: float, tokens: mx.array, result: DecodingResult )
whisper/mlx_whisper/transcribe.py:263
↓ 2 callers
Function
next_words_segment
(segments: List[dict])
whisper/mlx_whisper/transcribe.py:343
↓ 2 callers
Function
pad_or_trim
Pad or trim the audio array to N_SAMPLES, as expected by the encoder.
whisper/mlx_whisper/audio.py:66
↓ 2 callers
Method
postprocess_masks
Remove padding and upscale masks to the original image size. Args: masks (mx.array): Batched masks from the mask_decoder
segment_anything/segment_anything/sam.py:134
↓ 2 callers
Method
predict
Predict masks for the given input prompts, using the currently set image. Input prompts are batched mlx tensors and are expected to a
segment_anything/segment_anything/predictor.py:59
↓ 2 callers
Function
preproc
(x)
mnist/mnist.py:57
↓ 2 callers
Method
preprocess
Normalize pixel values and pad to a square input.
segment_anything/segment_anything/sam.py:172
↓ 2 callers
Function
print_help
()
flux/generate_interactive.py:59
↓ 2 callers
Function
ptb
Load the PTB language modeling dataset: https://paperswithcode.com/dataset/penn-treebank
transformer_lm/datasets.py:66
↓ 2 callers
Function
quantize
(weights, config, args)
whisper/convert.py:298
↓ 2 callers
Function
reconstruct
(model, batch, out_file)
cvae/main.py:57
↓ 2 callers
Function
remap
(k)
whisper/convert.py:126
↓ 2 callers
Function
remove_small_regions
Removes small disconnected regions and holes in a mask. Returns the mask and an indicator of if the mask has been modified.
segment_anything/segment_anything/utils/amg.py:269
↓ 2 callers
Function
rle_to_mask
Compute a binary mask from an uncompressed RLE.
segment_anything/segment_anything/utils/amg.py:134
↓ 2 callers
Function
rope_apply
Apply 3D RoPE using mx.fast.rope with reshapes. Args: x: Tensor of shape [B, L, H, D] grid_sizes: List of [frames, height, w
video/wan2.1/wan/rope.py:63
↓ 2 callers
Method
run
(self, mel: mx.array)
whisper/mlx_whisper/decoding.py:619
↓ 2 callers
Function
sample
(logits, temperature=0.0)
llava/generate.py:94
↓ 2 callers
Function
sample
(logits)
llms/mistral/mistral.py:193
← previous
next →
101–200 of 1,187, ranked by callers