MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / is_tflite_model

Function is_tflite_model

python/scripts/utils/model_identification.py:26–49  ·  view source on GitHub ↗

Check if a model is of TFLite type Parameters: ---------- model_path: str Path to model Returns ---------- bool: True if given path is a valid TFLite model

(model_path)

Source from the content-addressed store, hash-verified

24
25
26def is_tflite_model(model_path):
27 """Check if a model is of TFLite type
28
29 Parameters:
30 ----------
31 model_path: str
32 Path to model
33
34 Returns
35 ----------
36 bool:
37 True if given path is a valid TFLite model
38 """
39
40 try:
41 with open(model_path, "rb") as f:
42 hdr_bytes = f.read(8)
43 hdr_str = hdr_bytes[4:].decode("utf-8")
44 if hdr_str == "TFL3":
45 return True
46 else:
47 return False
48 except:
49 return False
50
51
52def identify_model_type(model_path):

Callers 1

identify_model_typeFunction · 0.85

Calls 1

readMethod · 0.80

Tested by

no test coverage detected