Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into add_vfimamba
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsRogge committed Sep 5, 2024
2 parents 2ddf512 + 83a9cb6 commit aae2673
Show file tree
Hide file tree
Showing 46 changed files with 356 additions and 133 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/agents-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
pnpm --filter doc-internal run fix-cdn-versions
git add ../..
git commit -m "🔖 @hugginface/agents $BUMPED_VERSION"
git commit -m "🔖 @huggingface/agents $BUMPED_VERSION"
git tag "agents-v$BUMPED_VERSION"
- run: pnpm --filter agents... build && pnpm publish --no-git-checks .
env:
Expand All @@ -61,9 +61,10 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Update Doc"
uses: peter-evans/repository-dispatch@v2
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/gguf-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @hugginface/gguf $BUMPED_VERSION"
git commit . -m "🔖 @huggingface/gguf $BUMPED_VERSION"
git tag "gguf-v$BUMPED_VERSION"
- run: pnpm publish --no-git-checks .
env:
Expand All @@ -58,6 +58,7 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 5 additions & 4 deletions .github/workflows/hub-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
pnpm --filter doc-internal run fix-cdn-versions
git add ../..
git commit -m "🔖 @hugginface/hub $BUMPED_VERSION"
git commit -m "🔖 @huggingface/hub $BUMPED_VERSION"
git tag "hub-v$BUMPED_VERSION"
- name: Make sure that the latest version of @huggingface/tasks is consistent with the local version
Expand Down Expand Up @@ -99,9 +99,10 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Update Doc"
uses: peter-evans/repository-dispatch@v2
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/inference-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
pnpm --filter doc-internal run fix-cdn-versions
git add ../..
git commit -m "🔖 @hugginface/inference $BUMPED_VERSION"
git commit -m "🔖 @huggingface/inference $BUMPED_VERSION"
git tag "inference-v$BUMPED_VERSION"
- name: Make sure that the latest version of @huggingface/tasks is consistent with the local version
Expand Down Expand Up @@ -99,6 +99,7 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 5 additions & 4 deletions .github/workflows/jinja-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @hugginface/jinja $BUMPED_VERSION"
git commit . -m "🔖 @huggingface/jinja $BUMPED_VERSION"
git tag "jinja-v$BUMPED_VERSION"
- run: pnpm publish --no-git-checks .
env:
Expand All @@ -58,6 +58,7 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 5 additions & 4 deletions .github/workflows/languages-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @hugginface/languages $BUMPED_VERSION"
git commit . -m "🔖 @huggingface/languages $BUMPED_VERSION"
git tag "languages-v$BUMPED_VERSION"
- run: pnpm publish --no-git-checks .
env:
Expand All @@ -58,6 +58,7 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 5 additions & 4 deletions .github/workflows/space-header-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @hugginface/space-header $BUMPED_VERSION"
git commit . -m "🔖 @huggingface/space-header $BUMPED_VERSION"
git tag "space-header-v$BUMPED_VERSION"
- run: pnpm publish --no-git-checks .
env:
Expand All @@ -58,9 +58,10 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Update Doc"
uses: peter-evans/repository-dispatch@v2
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/tasks-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @hugginface/tasks $BUMPED_VERSION"
git commit . -m "🔖 @huggingface/tasks $BUMPED_VERSION"
git tag "tasks-v$BUMPED_VERSION"
- run: pnpm publish --no-git-checks .
env:
Expand All @@ -58,9 +58,10 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Update Doc"
uses: peter-evans/repository-dispatch@v2
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/widgets-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ jobs:
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
# - run: pnpm publish --no-git-checks .
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion packages/doc-internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This package generates `.md` files inside the [docs](../../docs) folder using [typedoc](https://typedoc.org/) and [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown).

The `.md` files are generated when releasing packages. They are then published to [hugginface.co](https://huggingface.co/docs/huggingface.js/index) through the [doc-builder](https://github.com/huggingface/doc-builder)'s github action.
The `.md` files are generated when releasing packages. They are then published to [huggingface.co](https://huggingface.co/docs/huggingface.js/index) through the [doc-builder](https://github.com/huggingface/doc-builder)'s github action.

We run a few scripts in between, [fix-md-links](./fix-md-links.ts) and [update-toc](./update-toc.ts) to preprocess the files for `doc-builder`.

Expand Down
8 changes: 3 additions & 5 deletions packages/hub/src/utils/WebBlob.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, expect, it, beforeAll } from "vitest";
import { WebBlob } from "./WebBlob";
import { base64FromBytes } from "./base64FromBytes";

describe("WebBlob", () => {
const resourceUrl = new URL("https://huggingface.co/spaces/aschen/push-model-from-web/raw/main/mobilenet/model.json");
Expand Down Expand Up @@ -51,15 +50,14 @@ describe("WebBlob", () => {

it("should lazy load a LFS file hosted on Hugging Face", async () => {
const stableDiffusionUrl =
"https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/39593d5650112b4cc580433f6b0435385882d819/v1-5-pruned.safetensors";
"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/unet/diffusion_pytorch_model.fp16.safetensors";
const url = new URL(stableDiffusionUrl);
const webBlob = await WebBlob.create(url);

expect(webBlob.size).toBe(7_703_324_286);
expect(webBlob.size).toBe(5_135_149_760);
expect(webBlob).toBeInstanceOf(WebBlob);
expect(webBlob).toMatchObject({ url });
expect(base64FromBytes(new Uint8Array(await webBlob.slice(6, 12).arrayBuffer()))).toBe("AAB7Il9f");
expect(base64FromBytes(new Uint8Array(await webBlob.slice(0, 12).arrayBuffer()))).toBe("ytIDAAAAAAB7Il9f");
expect(await webBlob.slice(10, 22).text()).toBe("__metadata__");
});

it("should create a slice on the file", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/space-header/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@huggingface/space-header",
"version": "1.0.3",
"version": "1.0.4",
"packageManager": "[email protected]",
"description": "Use the Space mini_header outside Hugging Face",
"repository": "https://github.com/huggingface/huggingface.js.git",
Expand Down
1 change: 0 additions & 1 deletion packages/space-header/src/utils/get_space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const get_space = async (space_id: string): Promise<Space | null> => {
try {
const response = await fetch(`https://huggingface.co/api/spaces/${space_id}`);
const data = await response.json();
console.log(data);
return data as Space;
} catch (error) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/tasks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@huggingface/tasks",
"packageManager": "[email protected]",
"version": "0.11.12",
"version": "0.12.1",
"description": "List of ML tasks for huggingface.co/tasks",
"repository": "https://github.com/huggingface/huggingface.js.git",
"publishConfig": {
Expand Down
77 changes: 75 additions & 2 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,30 @@ export type LocalApp = {
}
);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isGgufModel(model: ModelData) {
function isGgufModel(model: ModelData): boolean {
return model.tags.includes("gguf");
}

function isAwqModel(model: ModelData): boolean {
return model.config?.quantization_config?.quant_method === "awq";
}

function isGptqModel(model: ModelData): boolean {
return model.config?.quantization_config?.quant_method === "gptq";
}

function isAqlmModel(model: ModelData): boolean {
return model.config?.quantization_config?.quant_method === "aqlm";
}

function isMarlinModel(model: ModelData): boolean {
return model.config?.quantization_config?.quant_method === "marlin";
}

function isTransformersModel(model: ModelData): boolean {
return model.tags.includes("transformers");
}

function isLlamaCppGgufModel(model: ModelData) {
return !!model.gguf?.context_length;
}
Expand Down Expand Up @@ -127,6 +146,47 @@ const snippetLocalAI = (model: ModelData, filepath?: string): LocalAppSnippet[]
];
};

const snippetVllm = (model: ModelData): LocalAppSnippet[] => {
const runCommand = [
"",
"# Call the server using curl:",
`curl -X POST "http://localhost:8000/v1/chat/completions" \\ `,
` -H "Content-Type: application/json" \\ `,
` --data '{`,
` "model": "${model.id}"`,
` "messages": [`,
` {"role": "user", "content": "Hello!"}`,
` ]`,
` }'`,
];
return [
{
title: "Install from pip",
setup: ["# Install vLLM from pip:", "pip install vllm"].join("\n"),
content: ["# Load and run the model:", `vllm serve "${model.id}"`, ...runCommand].join("\n"),
},
{
title: "Use Docker images",
setup: [
"# Deploy with docker on Linux:",
`docker run --runtime nvidia --gpus all \\`,
` --name my_vllm_container \\`,
` -v ~/.cache/huggingface:/root/.cache/huggingface \\`,
` --env "HUGGING_FACE_HUB_TOKEN=<secret>" \\`,
` -p 8000:8000 \\`,
` --ipc=host \\`,
` vllm/vllm-openai:latest \\`,
` --model ${model.id}`,
].join("\n"),
content: [
"# Load and run the model:",
`docker exec -it my_vllm_container bash -c "vllm serve ${model.id}"`,
...runCommand,
].join("\n"),
},
];
};

/**
* Add your new local app here.
*
Expand All @@ -146,6 +206,19 @@ export const LOCAL_APPS = {
displayOnModelPage: isLlamaCppGgufModel,
snippet: snippetLlamacpp,
},
vllm: {
prettyLabel: "vLLM",
docsUrl: "https://docs.vllm.ai",
mainTask: "text-generation",
displayOnModelPage: (model: ModelData) =>
isAwqModel(model) ||
isGptqModel(model) ||
isAqlmModel(model) ||
isMarlinModel(model) ||
isGgufModel(model) ||
isTransformersModel(model),
snippet: snippetVllm,
},
lmstudio: {
prettyLabel: "LM Studio",
docsUrl: "https://lmstudio.ai",
Expand Down
4 changes: 4 additions & 0 deletions packages/tasks/src/model-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface ModelData {
bits?: number;
load_in_4bit?: boolean;
load_in_8bit?: boolean;
/**
* awq, gptq, aqlm, marlin, … Used by vLLM
*/
quant_method?: string;
};
tokenizer_config?: TokenizerConfig;
adapter_transformers?: {
Expand Down
9 changes: 9 additions & 0 deletions packages/tasks/src/model-libraries-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,15 @@ wavs = chat.infer(texts, )
torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000)`,
];

export const yolov10 = (model: ModelData): string[] => [
`from ultralytics import YOLOv10
model = YOLOv10.from_pretrained("${model.id}")
source = 'http://images.cocodataset.org/val2017/000000039769.jpg'
model.predict(source=source, save=True)
`,
];

export const birefnet = (model: ModelData): string[] => [
`# Option 1: use with transformers
Expand Down
14 changes: 14 additions & 0 deletions packages/tasks/src/model-libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
snippets: snippets.pyannote_audio,
filter: true,
},
"py-feat": {
prettyLabel: "Py-Feat",
repoName: "Py-Feat",
repoUrl: "https://github.com/cosanlab/py-feat",
docsUrl: "https://py-feat.org/",
filter: false,
},
pythae: {
prettyLabel: "pythae",
repoName: "pythae",
Expand Down Expand Up @@ -657,6 +664,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
docsUrl: "https://github.com/jasonppy/VoiceCraft",
snippets: snippets.voicecraft,
},
yolov10: {
prettyLabel: "YOLOv10",
repoName: "yolov10",
repoUrl: "https://github.com/THU-MIG/yolov10",
docsUrl: "https://github.com/THU-MIG/yolov10",
snippets: snippets.yolov10,
},
whisperkit: {
prettyLabel: "WhisperKit",
repoName: "WhisperKit",
Expand Down
Loading

0 comments on commit aae2673

Please sign in to comment.