Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions packages/tasks/src/model-libraries-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ const diffusersImg2ImgDefaultPrompt = "Turn this cat into a dog";
const diffusersVideoDefaultPrompt = "A man with short gray hair plays a red electric guitar.";

const diffusers_default = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("${model.id}")

Expand All @@ -340,7 +342,9 @@ image = pipe(prompt).images[0]`,
];

const diffusers_image_to_image = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline
from diffusers.utils import load_image

pipe = DiffusionPipeline.from_pretrained("${model.id}")
Expand All @@ -352,7 +356,9 @@ image = pipe(image=input_image, prompt=prompt).images[0]`,
];

const diffusers_image_to_video = (model: ModelData) => [
`import torch
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image, export_to_video

Expand All @@ -369,7 +375,9 @@ export_to_video(output, "output.mp4")`,
];

const diffusers_controlnet = (model: ModelData) => [
`from diffusers import ControlNetModel, StableDiffusionControlNetPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import ControlNetModel, StableDiffusionControlNetPipeline

controlnet = ControlNetModel.from_pretrained("${model.id}")
pipe = StableDiffusionControlNetPipeline.from_pretrained(
Expand All @@ -378,7 +386,9 @@ pipe = StableDiffusionControlNetPipeline.from_pretrained(
];

const diffusers_lora = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
pipe.load_lora_weights("${model.id}")
Expand All @@ -388,7 +398,9 @@ image = pipe(prompt).images[0]`,
];

const diffusers_lora_image_to_image = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline
from diffusers.utils import load_image

pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
Expand All @@ -401,7 +413,9 @@ image = pipe(image=input_image, prompt=prompt).images[0]`,
];

const diffusers_lora_text_to_video = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline
from diffusers.utils import export_to_video

pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
Expand All @@ -414,7 +428,9 @@ export_to_video(output, "output.mp4")`,
];

const diffusers_lora_image_to_video = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline
from diffusers.utils import load_image, export_to_video

pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
Expand All @@ -428,14 +444,18 @@ export_to_video(output, "output.mp4")`,
];

const diffusers_textual_inversion = (model: ModelData) => [
`from diffusers import DiffusionPipeline
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("${get_base_diffusers_model(model)}")
pipe.load_textual_inversion("${model.id}")`,
];

const diffusers_flux_fill = (model: ModelData) => [
`import torch
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


import torch
from diffusers import FluxFillPipeline
from diffusers.utils import load_image

Expand All @@ -458,7 +478,9 @@ image.save(f"flux-fill-dev.png")`,
];

const diffusers_inpainting = (model: ModelData) => [
`import torch
`!pip install -U transformers diffusers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`!pip install -U transformers diffusers
`# !pip install -U transformers diffusers


import torch
from diffusers import AutoPipelineForInpainting
from diffusers.utils import load_image

Expand Down