Views
No views yet
| File | Purpose | Format |
|---|---|---|
model.onnx | Downloadable converted model | ONNX |
source/model.pb | Original model | TensorFlow GraphDef |
graphs/netron.png | ONNX graph visualization | PNG |
mlir/onnx.mlir | ONNX-MLIR import result | MLIR text |
| Item | Value |
|---|---|
| Precision | FP32 |
| ONNX file size | 0.07 MiB |
| Initializer tensors | 10 |
| Stored initializer elements | 16,662 |
| External weight files | None |
| Original format | TensorFlow GraphDef |
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 tensorflow1import io
2import wave
3import numpy as np
4import tensorflow as tf
5from huggingface_hub import hf_hub_download
6
7repo_id = "ketiswp/tensorflow-Micro-Speech-TinyConv-SpeechCommands-fp32-onnx"
8model_path = hf_hub_download(repo_id=repo_id, filename="source/model.pb")
9graph_def = tf.compat.v1.GraphDef()
10graph_def.ParseFromString(open(model_path, "rb").read())
11graph = tf.Graph()
12with graph.as_default():
13 tf.import_graph_def(graph_def, name="")
14
15input_tensor = graph.get_tensor_by_name("wav_data:0")
16output_tensor = graph.get_tensor_by_name("labels_softmax:0")
17buffer = io.BytesIO()
18with wave.open(buffer, "wb") as writer:
19 writer.setnchannels(1)
20 writer.setsampwidth(2)
21 writer.setframerate(16000)
22 writer.writeframes(np.zeros(16000, dtype=np.int16).tobytes())
23input_value = buffer.getvalue()
24
25config = tf.compat.v1.ConfigProto(
26 intra_op_parallelism_threads=1,
27 inter_op_parallelism_threads=1,
28 device_count={"GPU": 0},
29)
30with tf.compat.v1.Session(graph=graph, config=config) as session:
31 output = session.run(output_tensor, feed_dict={input_tensor: input_value})
32print(output.shape, output.dtype)pip install huggingface_hub numpy onnxruntime1import numpy as np
2import onnxruntime as ort
3from huggingface_hub import hf_hub_download
4
5repo_id = "ketiswp/tensorflow-Micro-Speech-TinyConv-SpeechCommands-fp32-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)])