0.2.4
Huggingface api for deno + wasm tokenizers
Attributes
Includes Deno configuration
Repository
Current version released
3 years ago
Versions
Huggingface deno
Huggingface api for deno + wasm tokenizers
Usage
Basic
import { AutoModel } from "https://deno.land/x/huggingface/mod.ts";
const model = new AutoModel({
model: "EleutherAI/gpt-neo-2.7B",
token: Deno.env.get("HUGGINGFACE_TOKEN")!,
});
const output = await model.run("The meaning of life is");
console.log(output[0].generated_text);With Tokenizer
import { AutoModel } from "https://deno.land/x/huggingface/mod.ts";
import { AutoTokenizer } from "https://deno.land/x/huggingface/tokenizers/mod.ts";
const tokenizer = await AutoTokenizer.fromPretrained("t5-base");
const model = new AutoModel({
model: "t5-base",
token: Deno.env.get("HUGGINGFACE_TOKEN")!,
});
const output = await model.run({
inputs: tokenizer.encode("Hello, How are you?").tokens,
options: {
wait_for_model: true,
},
});
console.log(output);Stable diffusion
import { Text2ImageModel } from "https://deno.land/x/huggingface/mod.ts";
const model = new Text2ImageModel({
model: "CompVis/stable-diffusion-v1-4",
token: Deno.env.get("HUGGINGFACE_TOKEN")!,
});
const output: Blob = await model.run({
inputs: "a photo of an astronaut riding a horse on mars",
options: {
wait_for_model: true,
},
});
Deno.writeFileSync("stable-diffusion.jpeg", new Uint8Array(await output.arrayBuffer()));
Maintainers
- Dean Srebnik (@load1n9)
Contribution
Pull request, issues and feedback are very welcome. Code style is formatted with
deno fmt and commit messages are done following Conventional Commits spec.
Licence
Copyright 2023, Dean Srebnik. All rights reserved. MIT license.