Skip to content

Commit 94cb7fe

Browse files
ardaatahanpcuenca
andauthored
Add Argmax DiffusionKit Snippet (#869)
This PR: 1. Adds a new `diffusionkit` snippet in [model-libraries-snippets.ts](https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/model-libraries-snippets.ts). 2. Adds `diffusionkit` library with necessary information in `MODEL_LIBRARIES_UI_ELEMENTS` in [model-libraries.ts](https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/model-libraries.ts). --------- Co-authored-by: Pedro Cuenca <[email protected]>
1 parent bf73137 commit 94cb7fe

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,48 @@ export const diffusers = (model: ModelData): string[] => {
170170
}
171171
};
172172

173+
export const diffusionkit = (model: ModelData): string[] => {
174+
const sd3Snippet = `# Pipeline for Stable Diffusion 3
175+
from diffusionkit.mlx import DiffusionPipeline
176+
177+
pipeline = DiffusionPipeline(
178+
shift=3.0,
179+
use_t5=False,
180+
model_version=${model.id},
181+
low_memory_mode=True,
182+
a16=True,
183+
w16=True,
184+
)`;
185+
186+
const fluxSnippet = `# Pipeline for Flux
187+
from diffusionkit.mlx import FluxPipeline
188+
189+
pipeline = FluxPipeline(
190+
shift=1.0,
191+
model_version=${model.id},
192+
low_memory_mode=True,
193+
a16=True,
194+
w16=True,
195+
)`;
196+
197+
const generateSnippet = `# Image Generation
198+
HEIGHT = 512
199+
WIDTH = 512
200+
NUM_STEPS = ${model.tags.includes("flux") ? 4 : 50}
201+
CFG_WEIGHT = ${model.tags.includes("flux") ? 0 : 5}
202+
203+
image, _ = pipeline.generate_image(
204+
"a photo of a cat",
205+
cfg_weight=CFG_WEIGHT,
206+
num_steps=NUM_STEPS,
207+
latent_size=(HEIGHT // 8, WIDTH // 8),
208+
)`;
209+
210+
const pipelineSnippet = model.tags.includes("flux") ? fluxSnippet : sd3Snippet;
211+
212+
return [pipelineSnippet, generateSnippet];
213+
};
214+
173215
export const cartesia_pytorch = (model: ModelData): string[] => [
174216
`# pip install --no-binary :all: cartesia-pytorch
175217
from cartesia_pytorch import ReneLMHeadModel

packages/tasks/src/model-libraries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
181181
filter: true,
182182
/// diffusers has its own more complex "countDownloads" query
183183
},
184+
diffusionkit: {
185+
prettyLabel: "DiffusionKit",
186+
repoName: "DiffusionKit",
187+
repoUrl: "https://github.com/argmaxinc/DiffusionKit",
188+
snippets: snippets.diffusionkit,
189+
},
184190
doctr: {
185191
prettyLabel: "docTR",
186192
repoName: "doctr",

0 commit comments

Comments
 (0)