From 3ee992eb7ae80344a03f04758482f84002f6d6d7 Mon Sep 17 00:00:00 2001 From: lawrence-cj Date: Wed, 4 Dec 2024 22:43:08 +0800 Subject: [PATCH 01/11] add sana ckpt into count; --- .../tasks/src/model-libraries-snippets.ts | 29 +++++++++++++++++++ packages/tasks/src/model-libraries.ts | 7 +++++ 2 files changed, 36 insertions(+) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 3dc520e0c..61a8bc6a3 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -982,6 +982,35 @@ IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); `, ]; +export const sana = (model: ModelData): string[] => [ + ` +# Install from https://github.com/NVlabs/Sana + +# Load the model and infer image from text +import torch +from app.sana_pipeline import SanaPipeline +from torchvision.utils import save_image + +device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") +generator = torch.Generator(device=device).manual_seed(42) + +sana = SanaPipeline("configs/sana_config/1024ms/Sana_1600M_img1024.yaml") +sana.from_pretrained("hf:/${model.id}") +prompt = 'a cyberpunk cat with a neon sign that says "Sana"' + +image = sana( + prompt=prompt, + height=1024, + width=1024, + guidance_scale=5.0, + pag_guidance_scale=2.0, + num_inference_steps=18, + generator=generator, +) +save_image(image, 'output/sana.png', nrow=1, normalize=True, value_range=(-1, 1)) + `, +]; + export const vfimamba = (model: ModelData): string[] => [ `from Trainer_finetune import Model diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index d8d31a2d4..5c9cd09d7 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -787,6 +787,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { filter: true, countDownloads: `path_extension:"sentis"`, }, + "sana": { + prettyLabel: "Sana", + repoName: "Sana", + repoUrl: "https://github.com/NVlabs/Sana", + countDownloads: `path_extension:"pth" OR path_extension:"json"`, + snippets: snippets.sana, + }, "vfi-mamba": { prettyLabel: "VFIMamba", repoName: "VFIMamba", From 4a78d0835507d5bc39a76d122141c05cb531fb9d Mon Sep 17 00:00:00 2001 From: lawrence-cj Date: Wed, 4 Dec 2024 23:15:08 +0800 Subject: [PATCH 02/11] add `checkpoints` path into counting. --- packages/tasks/src/model-libraries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index 5c9cd09d7..b6b1f835b 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -791,7 +791,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { prettyLabel: "Sana", repoName: "Sana", repoUrl: "https://github.com/NVlabs/Sana", - countDownloads: `path_extension:"pth" OR path_extension:"json"`, + countDownloads: `path_prefix:"checkpoints/" OR path_extension:"json"`, snippets: snippets.sana, }, "vfi-mamba": { From 301514df0145f69f8e9a673eff72c04c448d520c Mon Sep 17 00:00:00 2001 From: lawrence-cj Date: Wed, 4 Dec 2024 23:22:29 +0800 Subject: [PATCH 03/11] Revert "add `checkpoints` path into counting." This reverts commit 4a78d0835507d5bc39a76d122141c05cb531fb9d. --- packages/tasks/src/model-libraries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index b6b1f835b..5c9cd09d7 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -791,7 +791,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { prettyLabel: "Sana", repoName: "Sana", repoUrl: "https://github.com/NVlabs/Sana", - countDownloads: `path_prefix:"checkpoints/" OR path_extension:"json"`, + countDownloads: `path_extension:"pth" OR path_extension:"json"`, snippets: snippets.sana, }, "vfi-mamba": { From b862c9ce6427e1d3e7121c2175fe6947290f05d2 Mon Sep 17 00:00:00 2001 From: Junsong Chen Date: Wed, 4 Dec 2024 23:24:55 +0800 Subject: [PATCH 04/11] Update packages/tasks/src/model-libraries.ts Co-authored-by: vb --- packages/tasks/src/model-libraries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index 5c9cd09d7..ef10591f8 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -787,7 +787,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { filter: true, countDownloads: `path_extension:"sentis"`, }, - "sana": { + "Sana": { prettyLabel: "Sana", repoName: "Sana", repoUrl: "https://github.com/NVlabs/Sana", From a86fa665c5d78c0c4b8f55d581e470715d07a976 Mon Sep 17 00:00:00 2001 From: lawrence-cj Date: Wed, 4 Dec 2024 23:26:39 +0800 Subject: [PATCH 05/11] reduce the amount of snippet of Sana --- packages/tasks/src/model-libraries-snippets.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 61a8bc6a3..28fd849be 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -991,24 +991,17 @@ import torch from app.sana_pipeline import SanaPipeline from torchvision.utils import save_image -device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") -generator = torch.Generator(device=device).manual_seed(42) - sana = SanaPipeline("configs/sana_config/1024ms/Sana_1600M_img1024.yaml") -sana.from_pretrained("hf:/${model.id}") -prompt = 'a cyberpunk cat with a neon sign that says "Sana"' +sana.from_pretrained("hf://${model.id}") image = sana( - prompt=prompt, + prompt='a cyberpunk cat with a neon sign that says "Sana"', height=1024, width=1024, guidance_scale=5.0, pag_guidance_scale=2.0, num_inference_steps=18, - generator=generator, -) -save_image(image, 'output/sana.png', nrow=1, normalize=True, value_range=(-1, 1)) - `, +) `, ]; export const vfimamba = (model: ModelData): string[] => [ From a845ca076be0b2641c6e23c31b5d6d3d49fb6a16 Mon Sep 17 00:00:00 2001 From: Junsong Chen Date: Wed, 4 Dec 2024 23:43:48 +0800 Subject: [PATCH 06/11] Update packages/tasks/src/model-libraries.ts Co-authored-by: vb --- packages/tasks/src/model-libraries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index ef10591f8..5c9cd09d7 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -787,7 +787,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { filter: true, countDownloads: `path_extension:"sentis"`, }, - "Sana": { + "sana": { prettyLabel: "Sana", repoName: "Sana", repoUrl: "https://github.com/NVlabs/Sana", From 306b58afef27c0d1bc485485a4f7be192de85d6e Mon Sep 17 00:00:00 2001 From: Junsong Chen Date: Thu, 5 Dec 2024 01:30:33 +0800 Subject: [PATCH 07/11] Update packages/tasks/src/model-libraries-snippets.ts Co-authored-by: Lucain --- packages/tasks/src/model-libraries-snippets.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 28fd849be..4f61651b1 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -984,8 +984,6 @@ IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); export const sana = (model: ModelData): string[] => [ ` -# Install from https://github.com/NVlabs/Sana - # Load the model and infer image from text import torch from app.sana_pipeline import SanaPipeline From 1794bd874a804391f75f711ef15e8e80dd32de4b Mon Sep 17 00:00:00 2001 From: Junsong Chen Date: Thu, 5 Dec 2024 01:33:47 +0800 Subject: [PATCH 08/11] Update packages/tasks/src/model-libraries.ts Co-authored-by: Lucain --- packages/tasks/src/model-libraries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index 5c9cd09d7..cbb15f02d 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -791,7 +791,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { prettyLabel: "Sana", repoName: "Sana", repoUrl: "https://github.com/NVlabs/Sana", - countDownloads: `path_extension:"pth" OR path_extension:"json"`, + countDownloads: `path_extension:"pth"`, snippets: snippets.sana, }, "vfi-mamba": { From 3cfc5d42257e445b47887fbc7e135750cc6260ab Mon Sep 17 00:00:00 2001 From: Lucain Date: Thu, 5 Dec 2024 10:20:59 +0100 Subject: [PATCH 09/11] Apply suggestions from code review --- packages/tasks/src/model-libraries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries.ts b/packages/tasks/src/model-libraries.ts index cbb15f02d..14f54aef1 100644 --- a/packages/tasks/src/model-libraries.ts +++ b/packages/tasks/src/model-libraries.ts @@ -787,7 +787,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = { filter: true, countDownloads: `path_extension:"sentis"`, }, - "sana": { + sana: { prettyLabel: "Sana", repoName: "Sana", repoUrl: "https://github.com/NVlabs/Sana", From a90aaad5a87af22113625cc86441da3cb46a4f55 Mon Sep 17 00:00:00 2001 From: Lucain Date: Thu, 5 Dec 2024 10:27:30 +0100 Subject: [PATCH 10/11] Update packages/tasks/src/model-libraries-snippets.ts --- packages/tasks/src/model-libraries-snippets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 4f61651b1..9d92a19a3 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -982,7 +982,7 @@ IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); `, ]; -export const sana = (model: ModelData): string[] => [ +export const sana = (model: ModelData): string[] => [ ` # Load the model and infer image from text import torch From a025dd6f7f060b55a6f37a9c17f8e23809277530 Mon Sep 17 00:00:00 2001 From: Lucain Date: Thu, 5 Dec 2024 10:32:15 +0100 Subject: [PATCH 11/11] Update packages/tasks/src/model-libraries-snippets.ts --- packages/tasks/src/model-libraries-snippets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/model-libraries-snippets.ts b/packages/tasks/src/model-libraries-snippets.ts index 9d92a19a3..91ff1baae 100644 --- a/packages/tasks/src/model-libraries-snippets.ts +++ b/packages/tasks/src/model-libraries-snippets.ts @@ -983,7 +983,7 @@ IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); ]; export const sana = (model: ModelData): string[] => [ - ` + ` # Load the model and infer image from text import torch from app.sana_pipeline import SanaPipeline