Text-to-Image
MLX
MiniMax H3
Safetensors
English
apple-silicon
macos
image-to-image
image-editing
image-generation
Instructions to use devin-lai/MiniMax-H3-Image-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use devin-lai/MiniMax-H3-Image-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download devin-lai/MiniMax-H3-Image-mlx --local-dir MiniMax-H3-Image-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download examples/generate.py from devin-lai/MiniMax-H3-Image-mlx: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/devin-lai/MiniMax-H3-Image-mlx/resolve/refs%2Fpr%2F1/examples/generate.py
- Command line
-
hf download hf://devin-lai/MiniMax-H3-Image-mlx@refs/pr/1/examples/generate.py
-
curl -L -o generate.py https://huggingface.co/devin-lai/MiniMax-H3-Image-mlx/resolve/refs%2Fpr%2F1/examples/generate.py
1.93 kB
| """Run a recorded sample through the public inference pipeline.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--model", required=True) | |
| parser.add_argument("--text-encoder", required=True) | |
| parser.add_argument( | |
| "--case", | |
| choices=("product", "portrait", "holdout-detail", "edit"), | |
| default="product", | |
| ) | |
| parser.add_argument( | |
| "--image", help="Original edit reference, required for the edit case" | |
| ) | |
| parser.add_argument("--cache-dir", default="cache") | |
| parser.add_argument("--output", default="outputs/sample.png") | |
| args = parser.parse_args() | |
| if args.case == "edit" and args.image is None: | |
| parser.error( | |
| "The edit sample requires --image pointing to the original reference" | |
| ) | |
| catalog = json.loads(Path(__file__).with_name("catalog.json").read_text()) | |
| case = next(e for e in catalog["examples"] if e["case"] == args.case) | |
| from h3_mlx.runtime import Pipeline | |
| pipe = Pipeline( | |
| args.model, | |
| args.text_encoder, | |
| cache_dir=args.cache_dir, | |
| compile_blocks=True, | |
| eval_every=0, | |
| prefetch_blocks=4, | |
| vae_compile=True, | |
| vae_batch=4, | |
| kernel="metal-qk-exact", | |
| tune_matmul=True, | |
| ) | |
| try: | |
| _, record = pipe.generate( | |
| case["prompt"], | |
| seed=case["seed"], | |
| width=case["requested_size"][0], | |
| height=case["requested_size"][1], | |
| images=[args.image] if args.case == "edit" else [], | |
| output=args.output, | |
| save_trace=True, | |
| ) | |
| print( | |
| json.dumps( | |
| {"output": record["output"], "png_sha256": record["png_sha256"]}, | |
| indent=2, | |
| ) | |
| ) | |
| finally: | |
| pipe.clear() | |
| if __name__ == "__main__": | |
| main() | |