optimum-furiosa 0.1.0
Legit HuggingFace Optimum NPU integration package
Calls glob for filename searchImports the Hugging Face Hub Python client
SHA-25613904bd5d45563e7d525478d07f7d2c4a1311a70091f1bb5058d2f2d19478e93
MaleculeH₅(Cm₄Db₄F₅Os₃)Md₃(In₇NePa₅)
Evidence
1# Copyright 2023 The HuggingFace Team. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from typing import TYPE_CHECKING
16
17from transformers.utils import OptionalDependencyNotAvailable, _LazyModule
18
19from .utils import FURIOSA_ENF_FILE_NAME
20
21
⋯19 lines
41# Direct imports for type-checking
42if TYPE_CHECKING:
43 from .configuration import FuriosaAIConfig, QuantizationConfig
44 from .modeling import (
45 FuriosaAIModelForImageClassification,
46 )
47 from .quantization import FuriosaAIQuantizer
48 from .utils import export_model_to_onnx
11:48… , either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import logging
16from typing import Callable, Dict, List, Optional, Union
17
18import numpy as np
19import torch
20import tqdm
21import transformers
22from datasets import Dataset
23from transformers import (
24 AutoConfig,
25 AutoModel,
26 AutoModelForImageClassification,
27 EvalPrediction,
28)
29from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
30from transformers.modeling_outputs import (
31 ImageClassifierOutput,
32)
33
34from .modeling_base import FuriosaAIBaseModel
35from .utils import FURIOSA_DTYPE_TO_NUMPY_DTYPE
36
37
⋯6 lines
119:7… has_labels = all(inputs.get(k) is not None for k in self.label_names)
120 if has_labels:
121 labels = tuple(np.array([inputs.get(name)]) for name in self.label_names)
122 if len(labels) == 1:
123 labels = labels[0]
124 …
154:45… n", model=model, feature_extractor=preprocessor)
155 >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
156 >>> outputs = pipe(url)
157 ```
158"""
159
160
161@add_start_docstrings(
162 """
163 FuriosaAI Model with a ImageClassifierOutput for image classification tasks.
164 """,
165 MODEL_START_DOCSTRING,
166)
167class FuriosaAIModelForI …
183:10… orward(
184 self,
185 pixel_values: Union[torch.Tensor, np.ndarray],
186 **kwargs,
187 ):
188 np_inputs = isinstance(pixel_values, np.ndarray)
189 if not np_inputs:
190 pixel …
Showing the top 5 files — 2 more files (22 regions) not shown.
No evidence locations were recorded for this file. Raw result