Instructions to use beshkenadze/moondream3-preview-mlx-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use beshkenadze/moondream3-preview-mlx-4bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("beshkenadze/moondream3-preview-mlx-4bit") config = load_config("beshkenadze/moondream3-preview-mlx-4bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
File size: 1,415 Bytes
a49db27 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import numpy as np
def remove_outlier_points(points_tuples, k_nearest=2, threshold=2.0):
"""
Robust outlier detection for list of (x,y) tuples.
Only requires numpy.
Args:
points_tuples: list of (x,y) tuples
k_nearest: number of neighbors to consider
threshold: multiplier for median distance
Returns:
list: filtered list of (x,y) tuples with outliers removed
list: list of booleans indicating which points were kept (True = kept)
"""
points = np.array(points_tuples)
n_points = len(points)
# Calculate pairwise distances manually
dist_matrix = np.zeros((n_points, n_points))
for i in range(n_points):
for j in range(i + 1, n_points):
# Euclidean distance between points i and j
dist = np.sqrt(np.sum((points[i] - points[j]) ** 2))
dist_matrix[i, j] = dist
dist_matrix[j, i] = dist
# Get k nearest neighbors' distances
k = min(k_nearest, n_points - 1)
neighbor_distances = np.partition(dist_matrix, k, axis=1)[:, :k]
avg_neighbor_dist = np.mean(neighbor_distances, axis=1)
# Calculate mask using median distance
median_dist = np.median(avg_neighbor_dist)
mask = avg_neighbor_dist <= threshold * median_dist
# Return filtered tuples and mask
filtered_tuples = [t for t, m in zip(points_tuples, mask) if m]
return filtered_tuples
|