@huggingface/tasks 0.15.7 → 0.15.8
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.
|
@@ -425,7 +425,7 @@ const _keras_hub_causal_lm = (modelId) => `
|
|
|
425
425
|
import keras_hub
|
|
426
426
|
|
|
427
427
|
# Load CausalLM model (optional: use half precision for inference)
|
|
428
|
-
causal_lm = keras_hub.models.CausalLM.from_preset("
|
|
428
|
+
causal_lm = keras_hub.models.CausalLM.from_preset("hf://${modelId}", dtype="bfloat16")
|
|
429
429
|
causal_lm.compile(sampler="greedy") # (optional) specify a sampler
|
|
430
430
|
|
|
431
431
|
# Generate text
|
|
@@ -435,7 +435,7 @@ const _keras_hub_text_to_image = (modelId) => `
|
|
|
435
435
|
import keras_hub
|
|
436
436
|
|
|
437
437
|
# Load TextToImage model (optional: use half precision for inference)
|
|
438
|
-
text_to_image = keras_hub.models.TextToImage.from_preset("
|
|
438
|
+
text_to_image = keras_hub.models.TextToImage.from_preset("hf://${modelId}", dtype="bfloat16")
|
|
439
439
|
|
|
440
440
|
# Generate images with a TextToImage model.
|
|
441
441
|
text_to_image.generate("Astronaut in a jungle")
|
|
@@ -445,7 +445,7 @@ import keras_hub
|
|
|
445
445
|
|
|
446
446
|
# Load TextClassifier model
|
|
447
447
|
text_classifier = keras_hub.models.TextClassifier.from_preset(
|
|
448
|
-
"
|
|
448
|
+
"hf://${modelId}",
|
|
449
449
|
num_classes=2,
|
|
450
450
|
)
|
|
451
451
|
# Fine-tune
|
|
@@ -459,7 +459,7 @@ import keras
|
|
|
459
459
|
|
|
460
460
|
# Load ImageClassifier model
|
|
461
461
|
image_classifier = keras_hub.models.ImageClassifier.from_preset(
|
|
462
|
-
"
|
|
462
|
+
"hf://${modelId}",
|
|
463
463
|
num_classes=2,
|
|
464
464
|
)
|
|
465
465
|
# Fine-tune
|
|
@@ -480,13 +480,13 @@ const _keras_hub_task_without_example = (task, modelId) => `
|
|
|
480
480
|
import keras_hub
|
|
481
481
|
|
|
482
482
|
# Create a ${task} model
|
|
483
|
-
task = keras_hub.models.${task}.from_preset("
|
|
483
|
+
task = keras_hub.models.${task}.from_preset("hf://${modelId}")
|
|
484
484
|
`;
|
|
485
485
|
const _keras_hub_generic_backbone = (modelId) => `
|
|
486
486
|
import keras_hub
|
|
487
487
|
|
|
488
488
|
# Create a Backbone model unspecialized for any task
|
|
489
|
-
backbone = keras_hub.models.Backbone.from_preset("
|
|
489
|
+
backbone = keras_hub.models.Backbone.from_preset("hf://${modelId}")
|
|
490
490
|
`;
|
|
491
491
|
const keras_hub = (model) => {
|
|
492
492
|
const modelId = model.id;
|
|
@@ -398,7 +398,7 @@ const _keras_hub_causal_lm = (modelId) => `
|
|
|
398
398
|
import keras_hub
|
|
399
399
|
|
|
400
400
|
# Load CausalLM model (optional: use half precision for inference)
|
|
401
|
-
causal_lm = keras_hub.models.CausalLM.from_preset("
|
|
401
|
+
causal_lm = keras_hub.models.CausalLM.from_preset("hf://${modelId}", dtype="bfloat16")
|
|
402
402
|
causal_lm.compile(sampler="greedy") # (optional) specify a sampler
|
|
403
403
|
|
|
404
404
|
# Generate text
|
|
@@ -408,7 +408,7 @@ const _keras_hub_text_to_image = (modelId) => `
|
|
|
408
408
|
import keras_hub
|
|
409
409
|
|
|
410
410
|
# Load TextToImage model (optional: use half precision for inference)
|
|
411
|
-
text_to_image = keras_hub.models.TextToImage.from_preset("
|
|
411
|
+
text_to_image = keras_hub.models.TextToImage.from_preset("hf://${modelId}", dtype="bfloat16")
|
|
412
412
|
|
|
413
413
|
# Generate images with a TextToImage model.
|
|
414
414
|
text_to_image.generate("Astronaut in a jungle")
|
|
@@ -418,7 +418,7 @@ import keras_hub
|
|
|
418
418
|
|
|
419
419
|
# Load TextClassifier model
|
|
420
420
|
text_classifier = keras_hub.models.TextClassifier.from_preset(
|
|
421
|
-
"
|
|
421
|
+
"hf://${modelId}",
|
|
422
422
|
num_classes=2,
|
|
423
423
|
)
|
|
424
424
|
# Fine-tune
|
|
@@ -432,7 +432,7 @@ import keras
|
|
|
432
432
|
|
|
433
433
|
# Load ImageClassifier model
|
|
434
434
|
image_classifier = keras_hub.models.ImageClassifier.from_preset(
|
|
435
|
-
"
|
|
435
|
+
"hf://${modelId}",
|
|
436
436
|
num_classes=2,
|
|
437
437
|
)
|
|
438
438
|
# Fine-tune
|
|
@@ -453,13 +453,13 @@ const _keras_hub_task_without_example = (task, modelId) => `
|
|
|
453
453
|
import keras_hub
|
|
454
454
|
|
|
455
455
|
# Create a ${task} model
|
|
456
|
-
task = keras_hub.models.${task}.from_preset("
|
|
456
|
+
task = keras_hub.models.${task}.from_preset("hf://${modelId}")
|
|
457
457
|
`;
|
|
458
458
|
const _keras_hub_generic_backbone = (modelId) => `
|
|
459
459
|
import keras_hub
|
|
460
460
|
|
|
461
461
|
# Create a Backbone model unspecialized for any task
|
|
462
|
-
backbone = keras_hub.models.Backbone.from_preset("
|
|
462
|
+
backbone = keras_hub.models.Backbone.from_preset("hf://${modelId}")
|
|
463
463
|
`;
|
|
464
464
|
export const keras_hub = (model) => {
|
|
465
465
|
const modelId = model.id;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/tasks",
|
|
3
3
|
"packageManager": "pnpm@8.10.5",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.8",
|
|
5
5
|
"description": "List of ML tasks for huggingface.co/tasks",
|
|
6
6
|
"repository": "https://github.com/huggingface/huggingface.js.git",
|
|
7
7
|
"publishConfig": {
|
|
@@ -443,7 +443,7 @@ const _keras_hub_causal_lm = (modelId: string): string => `
|
|
|
443
443
|
import keras_hub
|
|
444
444
|
|
|
445
445
|
# Load CausalLM model (optional: use half precision for inference)
|
|
446
|
-
causal_lm = keras_hub.models.CausalLM.from_preset("
|
|
446
|
+
causal_lm = keras_hub.models.CausalLM.from_preset("hf://${modelId}", dtype="bfloat16")
|
|
447
447
|
causal_lm.compile(sampler="greedy") # (optional) specify a sampler
|
|
448
448
|
|
|
449
449
|
# Generate text
|
|
@@ -454,7 +454,7 @@ const _keras_hub_text_to_image = (modelId: string): string => `
|
|
|
454
454
|
import keras_hub
|
|
455
455
|
|
|
456
456
|
# Load TextToImage model (optional: use half precision for inference)
|
|
457
|
-
text_to_image = keras_hub.models.TextToImage.from_preset("
|
|
457
|
+
text_to_image = keras_hub.models.TextToImage.from_preset("hf://${modelId}", dtype="bfloat16")
|
|
458
458
|
|
|
459
459
|
# Generate images with a TextToImage model.
|
|
460
460
|
text_to_image.generate("Astronaut in a jungle")
|
|
@@ -465,7 +465,7 @@ import keras_hub
|
|
|
465
465
|
|
|
466
466
|
# Load TextClassifier model
|
|
467
467
|
text_classifier = keras_hub.models.TextClassifier.from_preset(
|
|
468
|
-
"
|
|
468
|
+
"hf://${modelId}",
|
|
469
469
|
num_classes=2,
|
|
470
470
|
)
|
|
471
471
|
# Fine-tune
|
|
@@ -480,7 +480,7 @@ import keras
|
|
|
480
480
|
|
|
481
481
|
# Load ImageClassifier model
|
|
482
482
|
image_classifier = keras_hub.models.ImageClassifier.from_preset(
|
|
483
|
-
"
|
|
483
|
+
"hf://${modelId}",
|
|
484
484
|
num_classes=2,
|
|
485
485
|
)
|
|
486
486
|
# Fine-tune
|
|
@@ -503,14 +503,14 @@ const _keras_hub_task_without_example = (task: string, modelId: string): string
|
|
|
503
503
|
import keras_hub
|
|
504
504
|
|
|
505
505
|
# Create a ${task} model
|
|
506
|
-
task = keras_hub.models.${task}.from_preset("
|
|
506
|
+
task = keras_hub.models.${task}.from_preset("hf://${modelId}")
|
|
507
507
|
`;
|
|
508
508
|
|
|
509
509
|
const _keras_hub_generic_backbone = (modelId: string): string => `
|
|
510
510
|
import keras_hub
|
|
511
511
|
|
|
512
512
|
# Create a Backbone model unspecialized for any task
|
|
513
|
-
backbone = keras_hub.models.Backbone.from_preset("
|
|
513
|
+
backbone = keras_hub.models.Backbone.from_preset("hf://${modelId}")
|
|
514
514
|
`;
|
|
515
515
|
|
|
516
516
|
export const keras_hub = (model: ModelData): string[] => {
|