Views
No views yet
| File | Purpose | Format |
|---|---|---|
model.onnx | Downloadable converted model | ONNX |
source/model.tflite | Original model | TensorFlow Lite |
graphs/netron.png | ONNX graph visualization | PNG |
mlir/onnx.mlir | ONNX-MLIR import result | MLIR text |
| Item | Value |
|---|---|
| Precision | INT8/UINT8 |
| ONNX file size | 4.91 MiB |
| Initializer tensors | 290 |
| Stored initializer elements | 4,682,839 |
| External weight files | None |
| Original format | TensorFlow Lite |
Stored initializer elements includes weights, biases, quantization scales,
zero-points, and other constant tensors. It is not a trainable-parameter count.pip install huggingface_hub numpy ai-edge-litert1import numpy as np
2from ai_edge_litert.interpreter import Interpreter
3from huggingface_hub import hf_hub_download
4
5repo_id = "ketiswp/mediapipe-EfficientNet-Lite0-ImageNet-224-int8-uint8-onnx"
6model_path = hf_hub_download(repo_id=repo_id, filename="source/model.tflite")
7interpreter = Interpreter(model_path=model_path, num_threads=1)
8
9for item in interpreter.get_input_details():
10 signature = [int(value) for value in item.get("shape_signature", item["shape"])]
11 shape = [value if value > 0 else 1 for value in signature]
12 if shape != [int(value) for value in item["shape"]]:
13 interpreter.resize_tensor_input(int(item["index"]), shape, strict=False)
14
15interpreter.allocate_tensors()
16for item in interpreter.get_input_details():
17 value = np.zeros(tuple(int(dim) for dim in item["shape"]), dtype=item["dtype"])
18 interpreter.set_tensor(int(item["index"]), value)
19
20interpreter.invoke()
21outputs = [interpreter.get_tensor(int(item["index"]))
22 for item in interpreter.get_output_details()]
23print([(value.shape, str(value.dtype)) for value in outputs])pip install huggingface_hub numpy onnxruntime1import numpy as np
2import onnxruntime as ort
3from huggingface_hub import hf_hub_download
4
5repo_id = "ketiswp/mediapipe-EfficientNet-Lite0-ImageNet-224-int8-uint8-onnx"
6model_path = hf_hub_download(repo_id=repo_id, filename="model.onnx")
7
8options = ort.SessionOptions()
9options.intra_op_num_threads = 1
10options.inter_op_num_threads = 1
11options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
12options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
13session = ort.InferenceSession(
14 model_path,
15 sess_options=options,
16 providers=["CPUExecutionProvider"],
17)
18
19dtype_by_ort_type = {
20 "tensor(float)": np.float32,
21 "tensor(double)": np.float64,
22 "tensor(float16)": np.float16,
23 "tensor(int64)": np.int64,
24 "tensor(int32)": np.int32,
25 "tensor(int16)": np.int16,
26 "tensor(int8)": np.int8,
27 "tensor(uint8)": np.uint8,
28 "tensor(bool)": np.bool_,
29}
30feeds = {}
31for item in session.get_inputs():
32 shape = [dim if isinstance(dim, int) and dim > 0 else 1 for dim in item.shape]
33 feeds[item.name] = np.zeros(shape, dtype=dtype_by_ort_type[item.type])
34
35outputs = session.run(None, feeds)
36print([(item.name, value.shape, str(value.dtype))
37 for item, value in zip(session.get_outputs(), outputs)])