Skip to content

Add Sana .pth files into download counting in huggingface repo #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
22 changes: 22 additions & 0 deletions packages/tasks/src/model-libraries-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,28 @@ 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

sana = SanaPipeline("configs/sana_config/1024ms/Sana_1600M_img1024.yaml")
sana.from_pretrained("hf://${model.id}")

image = sana(
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,
) `,
];

export const vfimamba = (model: ModelData): string[] => [
`from Trainer_finetune import Model

Expand Down
7 changes: 7 additions & 0 deletions packages/tasks/src/model-libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"`,
Copy link
Contributor

Choose a reason for hiding this comment

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

.pth file each time the pipeline is instantiated. Is that the case or not? And is the config.json ever loaded from script?

  1. If the script only loads the .pth file, then let's count only on .pth:
Suggested change
countDownloads: `path_extension:"pth" OR path_extension:"json"`,
countDownloads: `path_extension:"pth"`,
  1. If the script loads the config file as well, then it's even better and we should count these calls and only these calls. config.json is already tracked by default and that's why some count are already listed on the Hub (see https://huggingface.co/Efficient-Large-Model/Sana_1600M_512px). In that case, no need to add a countDownloads rule.
Suggested change
countDownloads: `path_extension:"pth" OR path_extension:"json"`,

I let you decide what's best for Sana library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, we didn't have a config.json file until yesterday. We want to recover it, so we add pth here. Is this reasonable?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, makes sense to track pth files then 👍

snippets: snippets.sana,
},
"vfi-mamba": {
prettyLabel: "VFIMamba",
repoName: "VFIMamba",
Expand Down