{"id":19023683,"url":"https://github.com/neuralmagic/optimum-deepsparse","last_synced_at":"2025-04-23T09:12:15.154Z","repository":{"id":177674094,"uuid":"659525341","full_name":"neuralmagic/optimum-deepsparse","owner":"neuralmagic","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-15T19:23:25.000Z","size":384,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-23T09:12:02.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neuralmagic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-28T03:01:00.000Z","updated_at":"2024-11-24T18:12:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca15be8d-6c79-48b7-9bba-2bd46c0f4f7a","html_url":"https://github.com/neuralmagic/optimum-deepsparse","commit_stats":null,"previous_names":["neuralmagic/optimum-deepsparse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralmagic%2Foptimum-deepsparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralmagic%2Foptimum-deepsparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralmagic%2Foptimum-deepsparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralmagic%2Foptimum-deepsparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neuralmagic","download_url":"https://codeload.github.com/neuralmagic/optimum-deepsparse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250403833,"owners_count":21424795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T20:32:01.238Z","updated_at":"2025-04-23T09:12:15.130Z","avatar_url":"https://github.com/neuralmagic.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# optimum-deepsparse\n\nAccelerated inference of 🤗 models on CPUs using the [DeepSparse Inference Runtime](https://github.com/neuralmagic/deepsparse).\n\n[![DeepSparse Modeling / Python - Test](https://github.com/neuralmagic/optimum-deepsparse/actions/workflows/test_check.yaml/badge.svg)](https://github.com/neuralmagic/optimum-deepsparse/actions/workflows/test_check.yaml)\n[![DeepSparse Modeling Nightly](https://github.com/neuralmagic/optimum-deepsparse/actions/workflows/test_nightly.yaml/badge.svg)](https://github.com/neuralmagic/optimum-deepsparse/actions/workflows/test_nightly.yaml)\n\n## Install\n\nThere is a PyPi package published at [optimum-deepsparse](https://pypi.org/project/optimum-deepsparse/) so you can simply:\n\n`pip install optimum-deepsparse`\n\nOptimum DeepSparse is a fast-moving project, and you may want to install from source.\n\n`pip install git+https://github.com/neuralmagic/optimum-deepsparse.git`\n\n### Installing in developer mode\n\nIf you are working on the `optimum-deepsparse` code then you should use an editable install by cloning and installing `optimum` and `optimum-deepsparse`:\n\n```\ngit clone https://github.com/huggingface/optimum\ngit clone https://github.com/neuralmagic/optimum-deepsparse\npip install -e optimum -e optimum-deepsparse\n```\n\nNow whenever you change the code, you'll be able to run with those changes instantly.\n\n\n## How to use it?\nTo load a model and run inference with DeepSparse, you can just replace your `AutoModelForXxx` class with the corresponding `DeepSparseModelForXxx` class. \n\n```diff\nimport requests\nfrom PIL import Image\n\n- from transformers import AutoModelForImageClassification\n+ from optimum.deepsparse import DeepSparseModelForImageClassification\nfrom transformers import AutoFeatureExtractor, pipeline\n\nurl = \"http://images.cocodataset.org/val2017/000000039769.jpg\"\nimage = Image.open(requests.get(url, stream=True).raw)\n\nmodel_id = \"microsoft/resnet-50\"\n- model = AutoModelForImageClassification.from_pretrained(model_id)\n+ model = DeepSparseModelForImageClassification.from_pretrained(model_id, export=True, input_shapes=\"[1,3,224,224]\")\nfeature_extractor = AutoFeatureExtractor.from_pretrained(model_id)\ncls_pipe = pipeline(\"image-classification\", model=model, feature_extractor=feature_extractor)\noutputs = cls_pipe(image)\n```\n\n| Supported Task                              | Model Class |\n| ------------------------------------------- | ------------- |\n| \"image-classification\"                      | DeepSparseModelForImageClassification  |\n| \"text-classification\"/\"sentiment-analysis\"  | DeepSparseModelForSequenceClassification  |\n| \"audio-classification\"                      | DeepSparseModelForAudioClassification  |\n| \"question-answering\"                        | DeepSparseModelForQuestionAnswering  |\n| \"image-segmentation\"                        | DeepSparseModelForSemanticSegmentation  |\n\nIf you find any issue while using those, please open an issue or a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuralmagic%2Foptimum-deepsparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuralmagic%2Foptimum-deepsparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuralmagic%2Foptimum-deepsparse/lists"}