{"id":14970724,"url":"https://github.com/netrack/tensorcraft","last_synced_at":"2025-10-26T13:31:12.973Z","repository":{"id":34978231,"uuid":"188099434","full_name":"netrack/tensorcraft","owner":"netrack","description":"TensorCraft is an AIO server for Keras models","archived":false,"fork":false,"pushed_at":"2023-03-25T01:37:44.000Z","size":1632,"stargazers_count":12,"open_issues_count":11,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T19:12:12.483Z","etag":null,"topics":["aio","keras","keras-models","machine-learning","python3","tensorflow"],"latest_commit_sha":null,"homepage":"","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/netrack.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-22T19:16:26.000Z","updated_at":"2024-02-16T10:39:54.000Z","dependencies_parsed_at":"2024-09-27T13:40:23.246Z","dependency_job_id":null,"html_url":"https://github.com/netrack/tensorcraft","commit_stats":{"total_commits":90,"total_committers":4,"mean_commits":22.5,"dds":0.1777777777777778,"last_synced_commit":"15e0c54b795f4ce527cc5e2c46bbb7da434ac036"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netrack%2Ftensorcraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netrack%2Ftensorcraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netrack%2Ftensorcraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netrack%2Ftensorcraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netrack","download_url":"https://codeload.github.com/netrack/tensorcraft/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238337313,"owners_count":19455288,"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":["aio","keras","keras-models","machine-learning","python3","tensorflow"],"created_at":"2024-09-24T13:44:02.948Z","updated_at":"2025-10-26T13:31:12.649Z","avatar_url":"https://github.com/netrack.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TensorCraft\n\n[![Build Status][BuildStatus]](https://travis-ci.org/netrack/tensorcraft)\n[![tensorcraft][SnapCraft]](https://snapcraft.io/tensorcraft)\n\nThe TensorCraft is a HTTP server that serves [Keras](https://github.com/keras-team/keras)\nmodels using TensorFlow runtime.\n\n_Currently TensorCraft is in beta, client and server API may change in the\nfuture versions_.\n\nThis server solves such problems as:\n\n* Versioning of models.\n* Warehousing of models.\n* Enabling CI/CD for machine-learning models.\n\n## Installation\n\n### Installation Using Snap\n\nThis is the recommended way to install `tensorcraft`. Simply run the following\ncommand:\n```bash\nsnap install tensorcraft --devmode --edge\nsnap start tensorcraft\n```\n\n### Installation Using Docker\n\nTensorCraft can be used as a Docker container. The major note on this approach is\nthat `tensorflow` library that is installed into the Docker image is not compiled\nwith support of AVX instructions or GPU.\n```bash\ndocker pull netrack/tensorcraft:latest\n```\n\nIn order to start the container, run the following command:\n```bash\ndocker run -it -p 5678:5678/tcp netrack/tensorcraft\n```\n\nYou can optinally specify volume to persist models between restarts of conatiner:\n```bash\ndocker run -it -p 5678:5678/tcp -v tensorcraft:/var/run/tensorcraft netrack/tensorcraft\n```\n\n### Installation Using PyPi\n\nInstall latest version from pypi repository.\n```bash\npip install tensorcraft\n```\n\n## Using TensorCraft\n\n### Keras Requirements\n\nOne of the possible ways of using `tensorcraft` is publising model snapshots to\nthe server on each epoch end.\n```py\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Activation\nfrom tensorcraft.callbacks import ModelCheckpoint\n\nmodel = keras.Sequential()\nmodel.add(Dense(32, input_dim=784))\nmodel.add(Activation('relu'))\n\nmodel.compile(optimizer='sgd', loss='binary_crossentropy')\nmodel.fit(x_train, y_train, callbacks=[ModelCheckpoint(verbose=1)], epochs=100)\n```\n\nCurrently, `tensorcraft` supports only models in the TensorFlow Saved Model, therefore\nin order to publish Keras model, it must be saved as Saved Model at first.\n\nConsidering the following Keras model:\n```py\nfrom tensorflow import keras\nfrom tensorflow.keras import layers\n\ninputs = keras.Input(shape=(8,), name='digits')\nx = layers.Dense(4, activation='relu', name='dense_1')(inputs)\nx = layers.Dense(4, activation='relu', name='dense_2')(x)\noutputs = layers.Dense(2, activation='softmax', name='predictions')(x)\n\nmodel = keras.Model(inputs=inputs, outputs=outputs, name='3_layer_mlp')\n```\n\nSave it using the `export_saved_model` function from the 2.0 TensorFlow API:\n```py\nkeras.experimental.export_saved_model(model, \"3_layer_mlp\")\n```\n\n### Starting Server\n\nTo start server run `server` command:\n```sh\nsudo tensorcraft server\n```\n\nBy default it starts listening _unsecured_ port on localhost at `http://localhost:5678`.\n\nDefault configuration saves models to `/var/lib/tensorcraft` directory. Apart of\nthat server requires access to `/var/run` directory in order to save pid file\nthere.\n\n### Pushing New Model\n\nNote, both client and server of `tensorcraft` application share the same code\nbase. This implies the need to install a lot of server dependencies for a\nclient. This will be improved in uncoming versions.\n\nOnce model saved in directory, pack it using `tar` utility. For instance, this\nis how it will look like for `3_layer_mlp` model from the previous example:\n```sh\ntar -cf 3_layer_mlp.tar 3_layer_mlp\n```\n\nNow the model packed into the archive can be pushed to the server under the\narbitrary tag:\n```sh\ntensorcraft push --name 3_layer_mlp --tag 0.0.1 3_layer_mlp.tar\n```\n\n### Listing Available Models\n\nYou can list all available models on the server using the following command:\n```sh\ntensorcraft list\n```\n\nAfter the execution of `list` command you'll see to available models:\n```sh\n3_layer_mlp:0.0.1\n3_layer_mlp:latest\n```\n\nThis is the features of `tensorcraft` server, each published model name results in\ncreation of _model group_. Each model group has it's `latest` tag, that references\nthe _latest pushed model_.\n\n### Removing Model\n\nRemove of the unused model can be performed in using `remove` command:\n```sh\ntensorcraft remove --name 3_layer_mlp --tag 0.0.1\n```\n\nExecution of `remove` commands results in the remove of the model itself, and\nthe model group, when is is the last model in the group.\n\n### Using Model\n\nIn order to use the pushed model, `tensorcraft` exposes REST API. An example query\nto the server looks like this:\n```sh\ncurl -X POST https://localhost:5678/models/3_layer_mlp/0.0.1/predict -d \\\n    '{\"x\": [[1.0, 2.1, 1.43, 4.43, 12.1, 3.2, 1.44, 2.3]]}'\n```\n\n# License\n\nThe code and docs are released under the [Apache 2.0 license](LICENSE).\n\n[BuildStatus]:   https://travis-ci.org/netrack/tensorcraft.svg?branch=master\n[SnapCraft]:     https://snapcraft.io/tensorcraft/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetrack%2Ftensorcraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetrack%2Ftensorcraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetrack%2Ftensorcraft/lists"}