Spaces:
Build error
Build error
| import numpy as np | |
| # ========================= | |
| # ๐ก ุชุญููู ู ูู .h ุฅูู model.tflite | |
| # ========================= | |
| def h_to_tflite_binary(): | |
| from mrk_model import mrk_model_data, mrk_model_data_len | |
| with open("model.tflite", "wb") as f: | |
| f.write(bytes(mrk_model_data[:mrk_model_data_len])) | |
| print("โ model.tflite created from .h") | |
| # ========================= | |
| # ๐ฆ ุชุญู ูู ุงูู ูุฏูู (ุจุฏูู TensorFlow) | |
| # ========================= | |
| def load_model(): | |
| try: | |
| with open("model.tflite", "rb") as f: | |
| data = f.read() | |
| print("โ model loaded, size:", len(data)) | |
| return data | |
| except: | |
| print("โ model.tflite not found, creating from .h...") | |
| h_to_tflite_binary() | |
| with open("model.tflite", "rb") as f: | |
| return f.read() | |
| # ========================= | |
| # ๐ MAIN | |
| # ========================= | |
| if __name__ == "__main__": | |
| model = load_model() | |
| # ุงุฎุชุจุงุฑ ุจุณูุท (ู ุด inference ุญูููู) | |
| print("First bytes:", model[:20]) |