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)
| 24 | |
| 25 | |
| 26 | def 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 | |
| 52 | def identify_model_type(model_path): |
no test coverage detected