Git Product home page Git Product logo

optimum-furiosa's Introduction

optimum-furiosa

Accelerated inference of ๐Ÿค— models using FuriosaAI NPU chips.

Furiosa SDK setup

A Furiosa SDK environment needs to be enabled to use this library. Please refer to Furiosa's Installation guide.

Install

Optimum Furiosa is a fast-moving project, and you may want to install from source.

pip install git+https://github.com/huggingface/optimum-furiosa.git

Installing in developer mode

If you are working on the optimum-furiosa code then you should use an editable install by cloning and installing optimum and optimum-furiosa:

git clone https://github.com/huggingface/optimum
git clone https://github.com/huggingface/optimum-furiosa
pip install -e optimum -e optimum-furiosa

Now whenever you change the code, you'll be able to run with those changes instantly.

How to use it?

To load a model and run inference with Furiosa NPU, you can just replace your AutoModelForXxx class with the corresponding FuriosaAIModelForXxx class.

import requests
from PIL import Image

- from transformers import AutoModelForImageClassification
+ from optimum.furiosa import FuriosaAIModelForImageClassification
from transformers import AutoFeatureExtractor, pipeline

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

model_id = "microsoft/resnet-50"
- model = AutoModelForImageClassification.from_pretrained(model_id)
+ model = FuriosaAIModelForImageClassification.from_pretrained(model_id, export=True, input_shape_dict={"pixel_values": [1, 3, 224, 224]}, output_shape_dict={"logits": [1, 1000]},)
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
cls_pipe = pipeline("image-classification", model=model, feature_extractor=feature_extractor)
outputs = cls_pipe(image)

If you find any issue while using those, please open an issue or a pull request.

optimum-furiosa's People

Contributors

mht-sharma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.