{"id":15658204,"url":"https://github.com/pinto0309/tflite2json2tflite","last_synced_at":"2025-05-05T16:41:36.125Z","repository":{"id":97173267,"uuid":"497898677","full_name":"PINTO0309/tflite2json2tflite","owner":"PINTO0309","description":"Convert tflite to JSON and make it editable in the IDE. It also converts the edited JSON back to tflite binary.","archived":false,"fork":false,"pushed_at":"2023-02-21T01:38:07.000Z","size":5683,"stargazers_count":27,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-25T13:56:15.022Z","etag":null,"topics":["docker","json","model-converter","models","tensorflow","tflite"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PINTO0309.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-30T10:43:05.000Z","updated_at":"2024-10-15T03:37:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8a56ba4-9b29-40fa-adcd-62fabc583792","html_url":"https://github.com/PINTO0309/tflite2json2tflite","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Ftflite2json2tflite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Ftflite2json2tflite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Ftflite2json2tflite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Ftflite2json2tflite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PINTO0309","download_url":"https://codeload.github.com/PINTO0309/tflite2json2tflite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242756745,"owners_count":20180196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","json","model-converter","models","tensorflow","tflite"],"created_at":"2024-10-03T13:11:24.964Z","updated_at":"2025-03-09T21:31:05.014Z","avatar_url":"https://github.com/PINTO0309.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tflite2json2tflite\nConvert tflite to JSON and make it editable in the IDE. It also converts the edited JSON back to tflite binary.\n\n![GitHub](https://img.shields.io/github/license/PINTO0309/tflite2json2tflite?color=2BAF2B)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/33194443/170994316-3e3d541c-9a6d-43cb-8ea5-be0201343e03.png\" /\u003e\n\u003c/p\u003e\n\n# Usage sample\n\n## 1. Docker run\n```bash\ndocker run --rm -it -v `pwd`:/home/user/workdir ghcr.io/pinto0309/tflite2json2tflite:latest\n```\n## 2. tflite to JSON\n![image](https://user-images.githubusercontent.com/33194443/170987334-32f5631e-ff71-4e50-9ab6-9554fd3fa0fd.png)\n\n```bash\n./flatc -t \\\n--strict-json \\\n--defaults-json \\\n-o workdir \\\n./schema.fbs -- workdir/model_float32.tflite\n```\n## 3. JSON edit\n```bash\nsed -i -e 's/Placeholder/input/g' workdir/model_float32.json\nsed -i -e 's/fusion\\/fusion_3\\/BiasAdd/output/g' workdir/model_float32.json\n```\n## 4. JSON to tflite\n```bash\n./flatc \\\n-o workdir \\\n-b ./schema.fbs workdir/model_float32.json\n\nrm workdir/model_float32.json\n```\n![image](https://user-images.githubusercontent.com/33194443/170987592-186f7da4-065f-408a-bc0b-dfe91b19ab9b.png)\n\n## 5. flatbuffers (flatc)\nI have made my own modifications to the official flatbuffers(flatc) to preserve the accuracy of the quantization parameters output to JSON. For more information, please see this issue. [tflite to JSON to tflite quantization error #1](https://github.com/PINTO0309/tflite2json2tflite/issues/1)\n\nhttps://github.com/google/flatbuffers\n\n- `flatbuffers/include/flatbuffers/util.h`\n  - From:\n    ```cpp\n    template\u003c\u003e inline std::string NumToString\u003cdouble\u003e(double t) {\n      return FloatToString(t, 12);\n    }\n    template\u003c\u003e inline std::string NumToString\u003cfloat\u003e(float t) {\n      return FloatToString(t, 6);\n    }\n    ```\n  - To:\n    ```cpp\n    template\u003c\u003e inline std::string NumToString\u003cdouble\u003e(double t) {\n      return FloatToString(t, 12);\n    }\n    template\u003c\u003e inline std::string NumToString\u003cfloat\u003e(float t) {\n      return FloatToString(t, 17);\n    }\n    ```\n\n- build\n  ```bash\n  cd flatbuffers \u0026\u0026 mkdir build \u0026\u0026 cd build\n  cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release ..\n  make -j$(nproc)\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Ftflite2json2tflite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinto0309%2Ftflite2json2tflite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Ftflite2json2tflite/lists"}