{"id":19646173,"url":"https://github.com/yoctol/serving-utils","last_synced_at":"2025-08-07T18:06:35.012Z","repository":{"id":52702494,"uuid":"140409195","full_name":"Yoctol/serving-utils","owner":"Yoctol","description":"Some utilities for tensorflow serving","archived":false,"fork":false,"pushed_at":"2022-09-23T22:24:26.000Z","size":200,"stargazers_count":8,"open_issues_count":6,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-28T15:39:47.027Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yoctol.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}},"created_at":"2018-07-10T09:28:27.000Z","updated_at":"2024-02-05T23:00:32.000Z","dependencies_parsed_at":"2022-08-22T08:51:03.659Z","dependency_job_id":null,"html_url":"https://github.com/Yoctol/serving-utils","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/Yoctol/serving-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoctol%2Fserving-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoctol%2Fserving-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoctol%2Fserving-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoctol%2Fserving-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yoctol","download_url":"https://codeload.github.com/Yoctol/serving-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoctol%2Fserving-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269300921,"owners_count":24394066,"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","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-11T14:37:11.013Z","updated_at":"2025-08-07T18:06:34.973Z","avatar_url":"https://github.com/Yoctol.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serving-utils\n\n[![travis][travis-image]][travis-url]\n[![pypi][pypi-image]][pypi-url]\n![release][release-image]\n\n[travis-image]: https://travis-ci.org/Yoctol/serving-utils.svg?branch=master\n[travis-url]: https://travis-ci.org/Yoctol/serving-utils\n[pypi-image]: https://img.shields.io/pypi/v/serving-utils.svg?style=flat\n[pypi-url]: https://pypi.python.org/pypi/serving-utils\n[release-image]: https://img.shields.io/github/release/Yoctol/serving-utils.svg\n\n\nSome python utilities when using tensorflow-serving.\n\n\n## Installation\n\nPrepare an environment with python version \u003e= 3.6\n\nFrom PYPI:\n1. Manually install tensorflow CPU or GPU version.\n2. `pip install serving-utils`\n\nFrom Github repository:\n1. `git clone git@github.com:Yoctol/serving-utils.git`\n2. Manually install tensorflow CPU or GPU version.\n3. `make install`\n\n\n## Usage\n\n1. Saver and Loader\n```python\nimport tensorflow as tf\n\nfrom serving_utils.saver import Saver\nfrom serving_utils.loader import Loader\n\nsaver = Saver(\n    session=tf.Session(graph=your_graph),\n    output_dir='/path/to/serving',\n    signature_def_map={\n        'predict': tf.saved_model.signature_def_utils.predict_signature_def(\n            inputs={'input': tf.Tensor...},\n            outputs={'output': tf.Tensor...},\n        )\n    },\n    freeze=True,  # (default: True) Frozen graph will be saved if True.\n)\nsaver.save()\n\nloader = Loader(\n    path='/path/to/serving',\n    # version=1,  # if not specified, use the latest version\n)\nnew_sess = tf.Session()\n\nloader.load(new_sess)  # load the saved model into new session\n```\n\n2. Client\n```python\nfrom serving_utils import Client\nclient = Client(host=\"localhost\", port=8500, n_trys=3)\nclient.predict(\n    {'input': np.ones(1, 10)},\n    output_names=['output'],\n    model_signature_name='predict',\n)\n\n# or async\nawait client.async_predict(...)\n```\n\n3. Freeze graph\n```python\nfrom serving_utils.freeze_graph import freeze_graph, create_session_from_graphdef\n\nfrozen_graph_def = freeze_graph(session, output_op_names)\nnew_session = create_session_from_graphdef(frozen_graph_def)\n```\n\n\n## Test\n\nRun the following commands:\n```\nmake lint\nmake test\n```\n\n\n## Dev\n\n```\nmake install-dev\n```\n\n### Protos\n\n```\npython -m grpc_tools.protoc -I. --python_out=. --python_grpc_out=. --grpc_python_out=. serving_utils/protos/*.proto\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoctol%2Fserving-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoctol%2Fserving-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoctol%2Fserving-utils/lists"}