@huggingface/tasks 0.19.2 → 0.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/gguf.d.ts +48 -4
- package/dist/commonjs/gguf.d.ts.map +1 -1
- package/dist/commonjs/gguf.js +138 -8
- package/dist/commonjs/model-libraries-snippets.d.ts +4 -1
- package/dist/commonjs/model-libraries-snippets.d.ts.map +1 -1
- package/dist/commonjs/model-libraries-snippets.js +101 -10
- package/dist/commonjs/model-libraries.d.ts +24 -1
- package/dist/commonjs/model-libraries.d.ts.map +1 -1
- package/dist/commonjs/model-libraries.js +23 -0
- package/dist/commonjs/tasks/index.js +1 -1
- package/dist/esm/gguf.d.ts +48 -4
- package/dist/esm/gguf.d.ts.map +1 -1
- package/dist/esm/gguf.js +136 -7
- package/dist/esm/model-libraries-snippets.d.ts +4 -1
- package/dist/esm/model-libraries-snippets.d.ts.map +1 -1
- package/dist/esm/model-libraries-snippets.js +95 -7
- package/dist/esm/model-libraries.d.ts +24 -1
- package/dist/esm/model-libraries.d.ts.map +1 -1
- package/dist/esm/model-libraries.js +23 -0
- package/dist/esm/tasks/index.js +1 -1
- package/package.json +1 -2
- package/src/gguf.ts +154 -9
- package/src/model-libraries-snippets.ts +103 -7
- package/src/model-libraries.ts +23 -0
- package/src/tasks/index.ts +1 -1
- package/src/tasks/reinforcement-learning/about.md +1 -1
|
@@ -237,6 +237,20 @@ output = model.generate(text)
|
|
|
237
237
|
sf.write("simple.mp3", output, 44100)`,
|
|
238
238
|
];
|
|
239
239
|
|
|
240
|
+
export const describe_anything = (model: ModelData): string[] => [
|
|
241
|
+
`# pip install git+https://github.com/NVlabs/describe-anything
|
|
242
|
+
from huggingface_hub import snapshot_download
|
|
243
|
+
from dam import DescribeAnythingModel
|
|
244
|
+
|
|
245
|
+
snapshot_download(${model.id}, local_dir="checkpoints")
|
|
246
|
+
|
|
247
|
+
dam = DescribeAnythingModel(
|
|
248
|
+
model_path="checkpoints",
|
|
249
|
+
conv_mode="v1",
|
|
250
|
+
prompt_mode="focal_prompt",
|
|
251
|
+
)`,
|
|
252
|
+
];
|
|
253
|
+
|
|
240
254
|
const diffusersDefaultPrompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k";
|
|
241
255
|
|
|
242
256
|
const diffusers_default = (model: ModelData) => [
|
|
@@ -727,6 +741,17 @@ model = pe.VisionTransformer.from_config("${model.id}", pretrained=True)`;
|
|
|
727
741
|
return [vision_encoder];
|
|
728
742
|
}
|
|
729
743
|
};
|
|
744
|
+
export const phantom_wan = (model: ModelData): string[] => [
|
|
745
|
+
`from huggingface_hub import snapshot_download
|
|
746
|
+
from phantom_wan import WANI2V, configs
|
|
747
|
+
|
|
748
|
+
checkpoint_dir = snapshot_download("${model.id}")
|
|
749
|
+
wan_i2v = WanI2V(
|
|
750
|
+
config=configs.WAN_CONFIGS['i2v-14B'],
|
|
751
|
+
checkpoint_dir=checkpoint_dir,
|
|
752
|
+
)
|
|
753
|
+
video = wan_i2v.generate(text_prompt, image_prompt)`,
|
|
754
|
+
];
|
|
730
755
|
|
|
731
756
|
export const pyannote_audio_pipeline = (model: ModelData): string[] => [
|
|
732
757
|
`from pyannote.audio import Pipeline
|
|
@@ -1117,13 +1142,31 @@ export const transformers = (model: ModelData): string[] => {
|
|
|
1117
1142
|
}
|
|
1118
1143
|
|
|
1119
1144
|
if (model.pipeline_tag && LIBRARY_TASK_MAPPING.transformers?.includes(model.pipeline_tag)) {
|
|
1120
|
-
const pipelineSnippet = [
|
|
1145
|
+
const pipelineSnippet = [
|
|
1146
|
+
"# Use a pipeline as a high-level helper",
|
|
1147
|
+
"from transformers import pipeline",
|
|
1148
|
+
"",
|
|
1149
|
+
`pipe = pipeline("${model.pipeline_tag}", model="${model.id}"` + remote_code_snippet + ")",
|
|
1150
|
+
];
|
|
1121
1151
|
|
|
1122
|
-
if (model.tags.includes("conversational")
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1152
|
+
if (model.tags.includes("conversational")) {
|
|
1153
|
+
if (model.tags.includes("image-text-to-text")) {
|
|
1154
|
+
pipelineSnippet.push(
|
|
1155
|
+
"messages = [",
|
|
1156
|
+
[
|
|
1157
|
+
" {",
|
|
1158
|
+
' "role": "user",',
|
|
1159
|
+
' "content": [',
|
|
1160
|
+
' {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},',
|
|
1161
|
+
' {"type": "text", "text": "What animal is on the candy?"}',
|
|
1162
|
+
" ]",
|
|
1163
|
+
" },",
|
|
1164
|
+
].join("\n"),
|
|
1165
|
+
"]"
|
|
1166
|
+
);
|
|
1167
|
+
} else {
|
|
1168
|
+
pipelineSnippet.push("messages = [", ' {"role": "user", "content": "Who are you?"},', "]");
|
|
1169
|
+
}
|
|
1127
1170
|
pipelineSnippet.push("pipe(messages)");
|
|
1128
1171
|
}
|
|
1129
1172
|
|
|
@@ -1309,19 +1352,53 @@ model = SwarmFormerModel.from_pretrained("${model.id}")
|
|
|
1309
1352
|
`,
|
|
1310
1353
|
];
|
|
1311
1354
|
|
|
1312
|
-
|
|
1355
|
+
const mlx_unknown = (model: ModelData): string[] => [
|
|
1313
1356
|
`pip install huggingface_hub hf_transfer
|
|
1314
1357
|
|
|
1315
1358
|
export HF_HUB_ENABLE_HF_TRANSFER=1
|
|
1316
1359
|
huggingface-cli download --local-dir ${nameWithoutNamespace(model.id)} ${model.id}`,
|
|
1317
1360
|
];
|
|
1318
1361
|
|
|
1362
|
+
const mlxlm = (model: ModelData): string[] => [
|
|
1363
|
+
`pip install --upgrade mlx-lm
|
|
1364
|
+
|
|
1365
|
+
mlx_lm.generate --model ${model.id} --prompt "Hello"`,
|
|
1366
|
+
];
|
|
1367
|
+
|
|
1368
|
+
const mlxchat = (model: ModelData): string[] => [
|
|
1369
|
+
`pip install --upgrade mlx-lm
|
|
1370
|
+
|
|
1371
|
+
mlx_lm.chat --model ${model.id}`,
|
|
1372
|
+
];
|
|
1373
|
+
|
|
1374
|
+
const mlxvlm = (model: ModelData): string[] => [
|
|
1375
|
+
`pip install --upgrade mlx-vlm
|
|
1376
|
+
|
|
1377
|
+
mlx_vlm.generate --model ${model.id} \\
|
|
1378
|
+
--prompt "Describe this image." \\
|
|
1379
|
+
--image "https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg"`,
|
|
1380
|
+
];
|
|
1381
|
+
|
|
1319
1382
|
export const mlxim = (model: ModelData): string[] => [
|
|
1320
1383
|
`from mlxim.model import create_model
|
|
1321
1384
|
|
|
1322
1385
|
model = create_model(${model.id})`,
|
|
1323
1386
|
];
|
|
1324
1387
|
|
|
1388
|
+
export const mlx = (model: ModelData): string[] => {
|
|
1389
|
+
if (model.tags.includes("image-text-to-text")) {
|
|
1390
|
+
return mlxvlm(model);
|
|
1391
|
+
}
|
|
1392
|
+
if (model.tags.includes("conversational")) {
|
|
1393
|
+
if (model.config?.tokenizer_config?.chat_template) {
|
|
1394
|
+
return mlxchat(model);
|
|
1395
|
+
} else {
|
|
1396
|
+
return mlxlm(model);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return mlx_unknown(model);
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1325
1402
|
export const model2vec = (model: ModelData): string[] => [
|
|
1326
1403
|
`from model2vec import StaticModel
|
|
1327
1404
|
|
|
@@ -1448,4 +1525,23 @@ export const hezar = (model: ModelData): string[] => [
|
|
|
1448
1525
|
|
|
1449
1526
|
model = Model.load("${model.id}")`,
|
|
1450
1527
|
];
|
|
1528
|
+
|
|
1529
|
+
export const zonos = (model: ModelData): string[] => [
|
|
1530
|
+
`# pip install git+https://github.com/Zyphra/Zonos.git
|
|
1531
|
+
import torchaudio
|
|
1532
|
+
from zonos.model import Zonos
|
|
1533
|
+
from zonos.conditioning import make_cond_dict
|
|
1534
|
+
|
|
1535
|
+
model = Zonos.from_pretrained("${model.id}", device="cuda")
|
|
1536
|
+
|
|
1537
|
+
wav, sr = torchaudio.load("speaker.wav") # 5-10s reference clip
|
|
1538
|
+
speaker = model.make_speaker_embedding(wav, sr)
|
|
1539
|
+
|
|
1540
|
+
cond = make_cond_dict(text="Hello, world!", speaker=speaker, language="en-us")
|
|
1541
|
+
codes = model.generate(model.prepare_conditioning(cond))
|
|
1542
|
+
|
|
1543
|
+
audio = model.autoencoder.decode(codes)[0].cpu()
|
|
1544
|
+
torchaudio.save("sample.wav", audio, model.autoencoder.sampling_rate)
|
|
1545
|
+
`,
|
|
1546
|
+
];
|
|
1451
1547
|
//#endregion
|
package/src/model-libraries.ts
CHANGED
|
@@ -230,6 +230,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
230
230
|
filter: false,
|
|
231
231
|
countDownloads: `path:"scin_dataset_precomputed_embeddings.npz" OR path:"saved_model.pb"`,
|
|
232
232
|
},
|
|
233
|
+
"describe-anything": {
|
|
234
|
+
prettyLabel: "Describe Anything",
|
|
235
|
+
repoName: "Describe Anything",
|
|
236
|
+
repoUrl: "https://github.com/NVlabs/describe-anything",
|
|
237
|
+
snippets: snippets.describe_anything,
|
|
238
|
+
filter: false,
|
|
239
|
+
},
|
|
233
240
|
"dia-tts": {
|
|
234
241
|
prettyLabel: "Dia",
|
|
235
242
|
repoName: "Dia",
|
|
@@ -662,6 +669,14 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
662
669
|
snippets: snippets.perception_encoder,
|
|
663
670
|
countDownloads: `path_extension:"pt"`,
|
|
664
671
|
},
|
|
672
|
+
"phantom-wan": {
|
|
673
|
+
prettyLabel: "Phantom",
|
|
674
|
+
repoName: "Phantom",
|
|
675
|
+
repoUrl: "https://github.com/Phantom-video/Phantom",
|
|
676
|
+
snippets: snippets.phantom_wan,
|
|
677
|
+
filter: false,
|
|
678
|
+
countDownloads: `path_extension:"pth"`,
|
|
679
|
+
},
|
|
665
680
|
pxia: {
|
|
666
681
|
prettyLabel: "pxia",
|
|
667
682
|
repoName: "pxia",
|
|
@@ -1009,6 +1024,14 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
1009
1024
|
countDownloads: `path_extension:"pt" OR path_extension:"safetensors"`,
|
|
1010
1025
|
snippets: snippets.ultralytics,
|
|
1011
1026
|
},
|
|
1027
|
+
zonos: {
|
|
1028
|
+
prettyLabel: "Zonos",
|
|
1029
|
+
repoName: "Zonos",
|
|
1030
|
+
repoUrl: "https://github.com/Zyphra/Zonos",
|
|
1031
|
+
docsUrl: "https://github.com/Zyphra/Zonos",
|
|
1032
|
+
snippets: snippets.zonos,
|
|
1033
|
+
filter: false,
|
|
1034
|
+
},
|
|
1012
1035
|
"3dtopia-xl": {
|
|
1013
1036
|
prettyLabel: "3DTopia-XL",
|
|
1014
1037
|
repoName: "3DTopia-XL",
|
package/src/tasks/index.ts
CHANGED
|
@@ -184,7 +184,7 @@ export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
|
|
|
184
184
|
/**
|
|
185
185
|
* Return the whole TaskData object for a certain task.
|
|
186
186
|
* If the partialTaskData argument is left undefined,
|
|
187
|
-
* the default
|
|
187
|
+
* the default placeholder data will be used.
|
|
188
188
|
*/
|
|
189
189
|
function getData(type: PipelineType, partialTaskData: TaskDataCustom = placeholder): TaskData {
|
|
190
190
|
return {
|
|
@@ -111,7 +111,7 @@ env = gym.make("LunarLander-v2")
|
|
|
111
111
|
# Loading the saved model
|
|
112
112
|
model = PPO.load("PPO-LunarLander-v2",env=env)
|
|
113
113
|
|
|
114
|
-
#
|
|
114
|
+
# Initializing the evaluation environment
|
|
115
115
|
eval_env = gym.make("LunarLander-v2")
|
|
116
116
|
|
|
117
117
|
# Running the trained agent on eval_env for 10 time steps and getting the mean reward
|