# Stable diffusion models with Ort or candle

**URL:** <https://discuss.huggingface.co/t/stable-diffusion-models-with-ort-or-candle/167956>\
**Category:** Beginners\
**Created:** [August 31, 2025, 11:16am UTC](https://discuss.huggingface.co/t/stable-diffusion-models-with-ort-or-candle/167956 "2025-08-31T11:16:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jthulhu](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jthulhu/32/30331_2.png) [@jthulhu](https://discuss.huggingface.co/u/jthulhu)\
**Post date:** [August 31, 2025, 11:16am UTC](https://discuss.huggingface.co/t/stable-diffusion-models-with-ort-or-candle/167956/1 "2025-08-31T11:16:54Z")

</div>

Hello,

I have a very low understanding of machine learning, but I’m tinkering with several models from hugging face to see what is possible. To get an idea of how practical software depending on ML-based AI is, I’d like to write a small/medium-sized application that uses it. The hugging face repository of models and the seamless Python interface is great for quickly experimenting, but for a larger project, I’d rather write it in Rust. I was wondering if it were possible to integrate any of these models into a Rust application.

For the first test, I’ve tried text to image models (as I find it very impressive to be able to generate photorealistic images in tens of seconds out of thin air). I’ve browsed the hug, and selected some with various fine-tuning to compare them. Not all of them worked out of the box, some only provide a `.safetensors` file, so I had to download them and load them directly with `StableDiffusionXLPipeline.from_single_file`. It works great. Now, I’d like to be able to do the same in Rust. By googling this, I’ve fallen on `ort`, which seems to be an ONNX binding library for Rust. They say I just need to convert the models to the ONNX format, and then I’m good to go, but (after painfully managing to do the conversion without the `model_index.json` and `config.json` files, which `optimum-cli` apparently really wants) I get tons of files in the ONNX format, not a single `.safetensors` file. So I’m a bit lost about what I’m supposed do to next to.

I’ve seen there is an alternative to Ort, that is, candle, which is developed by Hugging Face, so maybe folks around here have more knowledge about it. I’m also open to hints on how to make this work with candle.

Concretely, say I’d like to have the [PixelGen](https://huggingface.co/OEvortex/PixelGen) model working in Rust. Is there a tutorial somewhere on how to do that? Or could you provide a MWE with it?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [August 31, 2025, 12:17pm UTC](https://discuss.huggingface.co/t/stable-diffusion-models-with-ort-or-candle/167956/2 "2025-08-31T12:17:09Z")

</div>

I haven’t tried Rust yet. For [`Candle`, there’s a dedicated channel on the HF Discord](https://discord.com/channels/879548962464493619/1136218819447238726), so it’s best to ask technical questions there.

However, for this time, I think the samples for [StableDiffusion](https://github.com/huggingface/candle/blob/main/candle-examples/examples/stable-diffusion) and [StableDiffusion3](https://github.com/huggingface/candle/tree/main/candle-examples/examples/stable-diffusion-3) on GitHub can be reused almost as-is.

- [candle](https://github.com/huggingface/candle)
- [Candle Documentation](https://huggingface.github.io/candle/guide/installation.html)
