hosted_inference_api 0.1.1 copy "hosted_inference_api: ^0.1.1" to clipboard
hosted_inference_api: ^0.1.1 copied to clipboard

Test and evaluate, for free, over 150,000 machine learning models with fast inference hosted on Hugging Face shared infrastructure.

Hugging Face Hosted Inference API #

Test and evaluate, for free, over 150,000 publicly accessible machine learning models, or your own private models, via simple HTTP requests, with fast inference hosted on Hugging Face shared infrastructure.

A wrapper package around HuggingFace's free Hosted Inference API.

This package is not affiliated or endorsed by HuggingFace, nor any of the models it hosts. Always check the license of the model you're using.

Features #

This package supports text-to-text, text-to-image, image-to-image, and possibly other types of models. If you encounter a model that doesn't work, please open an issue.

Usage #

GPT-2 (text-to-text) #

Hugging Face's example is using gpt2, and this is its analogue in this package:

final api = HFApi(
  model: 'gpt2',
  outputType: HFOutputType.string,
  apiToken: 'hf_xxxxx',
);
final result = await api.run<String>('Can you please let us know more details about your ');

Cartoonizer (image-to-image) #

final api = HFApi(
  model: 'instruction-tuning-sd/cartoonizer',
  outputType: HFOutputType.bytes,
  apiToken: 'hf_xxxxx',
);
final inputImage = await File('input.jpg').readAsBytes();
final result = await api.run<Uint8List>(inputImage);
await File('output.jpg').writeAsBytes(result);

Note that some models seem to require the input to be a jpeg (i.e. not a png). Otherwise, you'll get a HuggingFaceUnknownError with a message like {"error":"cannot identify image file <_io.BytesIO object at 0x7f416c25bdb0>"}.

0
likes
160
pub points
0%
popularity

Publisher

verified publisheradil.hanney.org

Test and evaluate, for free, over 150,000 machine learning models with fast inference hosted on Hugging Face shared infrastructure.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http, meta

More

Packages that depend on hosted_inference_api