{"id":14970775,"url":"https://github.com/xmartlabs/benderthon","last_synced_at":"2025-10-26T13:31:17.327Z","repository":{"id":57414628,"uuid":"93177301","full_name":"xmartlabs/benderthon","owner":"xmartlabs","description":"Set of utilities to work easier with Bender.","archived":false,"fork":false,"pushed_at":"2017-09-28T03:19:29.000Z","size":27,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-30T04:54:37.627Z","etag":null,"topics":["bender","caffe","machine-learning","neural-networks","tensorflow"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/xmartlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-02T15:07:24.000Z","updated_at":"2022-09-09T00:03:53.000Z","dependencies_parsed_at":"2022-09-12T12:10:27.851Z","dependency_job_id":null,"html_url":"https://github.com/xmartlabs/benderthon","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2Fbenderthon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2Fbenderthon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2Fbenderthon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2Fbenderthon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmartlabs","download_url":"https://codeload.github.com/xmartlabs/benderthon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238337347,"owners_count":19455293,"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":["bender","caffe","machine-learning","neural-networks","tensorflow"],"created_at":"2024-09-24T13:44:07.823Z","updated_at":"2025-10-26T13:31:16.911Z","avatar_url":"https://github.com/xmartlabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# benderthon\n\nSet of utilities to work easier with [Bender](https://github.com/xmartlabs/Bender).\n\nCurrently there's support for TensorFlow and Caffe, but we are working on more stuff!\n\nWorks on Python 2.7.+ and 3.+, with Tensorflow 1.2+.\n\nTo install:\n\n```bash\npip install benderthon\n```\n\nTensorFlow is required too. The simplest way to install it is:\n\n```bash\npip install tensorflow\n```\n\nThere are other ways, see [Installing Tensorflow](https://www.tensorflow.org/install/). Benderthon does not install it\nby default to let the usage of a custom installation.\n\n## tf-freeze\n\nUtility to convert **TensorFlow** checkpoints into minimal frozen **graphs**.\n\n### Usage\n\n#### From a checkpoint\n\nTo take the checkpoint `checkpoint_path.ckpt`, whose output is yielded by the node named `Tanh`, and save it to `graph_with_weights.pb`:\n\n```bash\nbenderthon tf-freeze checkpoint_path.ckpt graph_with_weights.pb Tanh\n```\n\n#### From code\n\nIf you don't have a checkpoint or prefer to run it from code, this is the way to go. This is the same example as above but from code:\n\n```python\nfrom benderthon import tf_freeze\n\n// …\n\nwith tf.Session() as sess:\n    // …\n\n    tf_freeze.freeze(sess, 'graph_with_weights.pb', ['Tanh'])\n```\n\n### Sample\n\nThe file `sample.py` contains a network example for MNIST dataset with 2 convolutional layers and 2 dense layers. If you run it, it will generate a minimal protobuf for with the weights frozen to run in Bender in `output/mnist.pb`:\n\n```bash\n./sample.py\n```\n\nThe generated file occupies **half** the original checkpoints (26MB to 13MB).\n\nThe script will also generate checkpoints files with prefix `checkpoints/mnist.ckpt`. So you could have generated the protobuf from it:\n\n```bash\nbenderthon tf-freeze checkpoints/mnist.ckpt output/mnist.pb Prediction\n```\n\nYou can also get only the graph, which occupies just **13kB**:\n\n```bash\nbenderthon tf-freeze --no-weights checkpoints/mnist.ckpt output/mnist_only_graph.pb Prediction\n```\n\nTo save the weights in a separate path for later processing:\n\n```bash\nbenderthon tf-freeze --only-weights checkpoints/mnist.ckpt weights/ Prediction\n```\n\n## caffe-freeze\n\nThis module cannot be accessed from the command line utility, it should be used from Python code, importing `benderthon.caffe_freeze`.\n\nYou need `caffeflow` package installed first:\n\n```bash\npip install -e git://github.com/xmartlabs/caffeflow.git@4618f89#egg=caffeflow\n```\n\n## Development\n\nThis utility is under development and the API **is not stable**. So, do not heavily rely on it.\n\nTo install locally you should do ```./setup.py install```, but first have [pandoc](http://pandoc.org/) and [pypandoc](https://github.com/bebraw/pypandoc) installed.\n\n## License\n\n```\nCopyright 2017 Xmartlabs SRL.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmartlabs%2Fbenderthon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmartlabs%2Fbenderthon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmartlabs%2Fbenderthon/lists"}