Optimum-furiosa

Latest version: v0.1.0

Safety actively analyzes 687918 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.1.0

FuriosaAIModelForImageClassification

`FuriosaAIModelForImageClassification` allows inference for models with an image classification head on the Furiosa Warboy NPU. The class exports the model to the ONNX format, load ONNX models, and compile them for inference on the hardware.

python
import requests
from PIL import Image

from optimum.furiosa import FuriosaAIModelForImageClassification
from transformers import AutoFeatureExtractor, pipeline

image = Image.open(requests.get("http://images.cocodataset.org/val2017/000000039769.jpg", stream=True).raw)
feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")

model = FuriosaAIModelForImageClassification.from_pretrained("microsoft/resnet-50", export=True, input_shape_dict={"pixel_values": [1, 3, 224, 224]}, output_shape_dict={"logits": [1, 1000]},)

cls_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor)
output = cls_pipe(image)


* Support for image classification by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/1

Quantisation Support

Furiosa AI quantization can also be applied on a model by using the `FuriosaAIQuantizer` class. In order to create an instance of `FuriosaAIQuantizer`, the user needs to provide an configuration objects, defining the calibration and quantisation informations, such as the calibration approach (minmax, sqnr etc). Then quantization can be applied by calling the `FuriosaAIQuantizer.fit` method.

* Add quantization by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/4

Load and push model to Hugging Face Hub

The Hub support allows you to save and push the compiled model to the Hugging Face Hub, making it easier for others to access and use the precompiled model without going through the compilation process again. This is especially useful for reducing the inference time during model deployment as the precompiled model can be directly fetched from the Hub.

python
from optimum.furiosa import FuriosaAIModelForImageClassification
model = FuriosaAIModelForImageClassification.from_pretrained("microsoft/resnet-50", export=True, input_shape_dict{"pixel_values": [1, 3, 224, 224]}, output_shape_dict={"logits": [1, 1000]},)

model.save_pretrained("a_local_path_for_compiled_model")
model.push_to_hub( "a_local_path_for_compiled_model", repository_id="my-furiosa-repo", use_auth_token=True)


* Add caching support by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/10

What's Changed
* Update compile method by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/2
* Update furiosa sdk installation link to latest by furiosamg in https://github.com/huggingface/optimum-furiosa/pull/3
* Add modelling tests by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/5
* Add documentation by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/7
* Add formatting checks and unit tests in CI by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/6
* Add PIL installation for testing by mht-sharma in https://github.com/huggingface/optimum-furiosa/pull/9

New Contributors
* mht-sharma made their first contribution in https://github.com/huggingface/optimum-furiosa/pull/1
* furiosamg made their first contribution in https://github.com/huggingface/optimum-furiosa/pull/3

**Full Changelog**: https://github.com/huggingface/optimum-furiosa/commits/v0.1.0

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.