MLX
Safetensors

Run this model with HF Jobs

Run Xylolabs/openpilot-driving-MLX on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/Xylolabs/openpilot-driving-MLX. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/Xylolabs/openpilot-driving-MLX on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
openpilot-driving-MLX / kl /example.py
hletrd's picture
Update model files
e9113c0 verified
Raw History Blame Contribute Delete
1.17 kB
"""Run the packaged model on synthetic inputs and reuse its next state."""
import mlx.core as mx
from model import Model
def main():
mx.set_default_device(mx.cpu)
model = Model()
states = model.initial_state()
inputs = {name: mx.zeros(shape, dtype) for name, (shape, dtype) in model.inputs.items()
if name not in states}
if "traffic_convention" in inputs:
shape, dtype = model.inputs["traffic_convention"]
inputs["traffic_convention"] = mx.array([1, 0], dtype=dtype).reshape(shape)
if "action_t" in inputs:
inputs["action_t"] = mx.array([[0.2, 0.3]], dtype=mx.float32)
for _ in range(2 if states else 1):
outputs = model(**inputs, **states)
mx.eval(*outputs.values())
states = {name: outputs[f"next_{name}"] for name in states}
print({name: (value.shape, str(value.dtype)) for name, value in outputs.items()})
for head in model.graph["output_slices"]:
tensor = head.get("tensor", "outputs")
values = outputs[tensor][..., head["start"]:head["stop"]]
print(head["name"], values.shape, values[0, 0].item())
if __name__ == "__main__":
main()