{"id":13411899,"url":"https://github.com/jrieke/traingenerator","last_synced_at":"2025-05-16T04:06:27.114Z","repository":{"id":37539135,"uuid":"318258852","full_name":"jrieke/traingenerator","owner":"jrieke","description":"🧙 A web app to generate template code for machine learning","archived":false,"fork":false,"pushed_at":"2023-08-23T08:35:09.000Z","size":10335,"stargazers_count":1369,"open_issues_count":12,"forks_count":185,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-04-01T13:03:57.910Z","etag":null,"topics":["deep-learning","machine-learning","machine-learning-tutorials","pytorch","pytorch-ignite","pytorch-lightning","scikit-learn","sklearn","streamlit","template","tensorflow","webapp","website"],"latest_commit_sha":null,"homepage":"https://traingenerator.jrieke.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jrieke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":"jrieke"}},"created_at":"2020-12-03T16:47:16.000Z","updated_at":"2025-03-19T01:44:45.000Z","dependencies_parsed_at":"2024-01-06T18:31:52.525Z","dependency_job_id":null,"html_url":"https://github.com/jrieke/traingenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrieke%2Ftraingenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrieke%2Ftraingenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrieke%2Ftraingenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrieke%2Ftraingenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jrieke","download_url":"https://codeload.github.com/jrieke/traingenerator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856544,"owners_count":21007621,"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":["deep-learning","machine-learning","machine-learning-tutorials","pytorch","pytorch-ignite","pytorch-lightning","scikit-learn","sklearn","streamlit","template","tensorflow","webapp","website"],"created_at":"2024-07-30T20:01:18.223Z","updated_at":"2025-04-08T14:11:03.837Z","avatar_url":"https://github.com/jrieke.png","language":"Python","funding_links":["https://github.com/sponsors/jrieke","https://www.buymeacoffee.com/jrieke"],"categories":["Python","Deep Learning Framework","Simplification Tools"],"sub_categories":["Anomaly Detection \u0026 Others"],"readme":"\u003ch1 align=\"center\"\u003e\n    Traingenerator\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003e🧙\u0026nbsp; A web app to generate template code for machine learning ✨\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003c!-- \u003ca href=\"https://twitter.com/jrieke\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/jrieke?color=blue\u0026label=Follow%20%40jrieke\u0026logo=twitter\u0026style=plastic\"\u003e\u003c/a\u003e --\u003e\n    \u003ca href=\"https://traingenerator.streamlitapp.com/\"\u003e\u003cimg src=\"https://static.streamlit.io/badges/streamlit_badge_black_white.svg\"\u003e\u003c/a\u003e\n    \u003c!-- \u003ca href=\"https://www.buymeacoffee.com/jrieke\"\u003e\u003cimg src=\"https://img.shields.io/badge/Buy%20me%20a-coffee-orange.svg?logo=buy-me-a-coffee\u0026logoColor=orange\"\u003e\u003c/a\u003e --\u003e\n    \u003c!-- \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/jrieke/traingenerator.svg\"\u003e\u003c/a\u003e --\u003e\n    \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg src=\"https://img.shields.io/badge/code%20style-black-000000.svg\" alt=\"Code style: black\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/demo.gif\" width=600\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n\u003ch3 align=\"center\"\u003e\n    🎉 Traingenerator is now live! 🎉\n    \u003cbr\u003e\u003cbr\u003e\n    Try it out: \u003cbr\u003e\n    \u003ca href=\"https://traingenerator.streamlitapp.com/\"\u003ehttps://traingenerator.streamlitapp.com/\u003c/a\u003e\n\u003c/h3\u003e\n\n\u003c!--\n\u003cp align=\"center\"\u003e\u003cstrong\u003e\n    Try it out: \u003cbr\u003e\n    \u003e\u003e\u003e \u003ca href=\"https://traingenerator.streamlitapp.com/\"\u003ehttps://traingenerator.streamlitapp.com/\u003c/a\u003e \u003c\u003c\u003c\u003c/strong\u003e\n\u003c/p\u003e\n--\u003e\n\n\u003cbr\u003e\n\nGenerate custom template code for PyTorch \u0026 sklearn, using a simple web UI built with [streamlit](https://www.streamlit.io/). Traingenerator offers multiple options for preprocessing, model setup, training, and visualization (using Tensorboard or comet.ml). It exports to .py, Jupyter Notebook, or  [Google Colab](https://colab.research.google.com/). The perfect tool to jumpstart your next machine learning project!\n\n\u003cbr\u003e\n\n*For updates, [follow me on Twitter](https://twitter.com/jrieke).*\n\n\u003cbr\u003e\n\n---\n\n\u003cbr\u003e\n\n## Adding new templates\n\nYou can add your own template in 4 easy steps (see below), without changing any code \nin the app itself. Your new template will be automatically discovered by Traingenerator \nand shown in the sidebar. That's it! 🎈\n\n**Want to share your magic?** 🧙 PRs are welcome! Please have a look \nat [CONTRIBUTING.md](CONTRIBUTING.md). \n\n**Some ideas for new templates:** Keras/Tensorflow, Pytorch Lightning, object detection, \nsegmentation, text classification, ...\n\n\u003cimg align=\"right\" src=\"docs/assets/dropdowns.png\" width=160\u003e\n\n1. **Create a folder under `./templates`.** \nThe folder name should be the task that your template solves (e.g. \n`Image classification`). Optionally, you can add a framework name (e.g. \n`Image classification_PyTorch`). Both names are automatically shown in the first two \ndropdowns in the sidebar (see image). \n✨ *Tip: Copy the [example template](templates/example) to get started more quickly.* \n1. **Add a file `sidebar.py` to the folder ([see example](templates/example/sidebar.py)).** \nIt needs to contain a method `show()`, which displays all template-specific streamlit \ncomponents in the sidebar (i.e. everything below *Task*) and returns a dictionary of \nuser inputs.\n3. **Add a file `code-template.py.jinja` to the folder ([see example](templates/example/code-template.py.jinja)).** \nThis [Jinja2 template](https://jinja.palletsprojects.com/en/2.11.x/templates/) is used \nto generate the code. You can write normal Python code in it and modify it \n(through Jinja) based on the user inputs in the sidebar (e.g. insert a parameter \nvalue from the sidebar or show different code parts based on the user's selection). \n4. **Optional: Add a file `test-inputs.yml` to the folder ([see example](templates/example/test-inputs.yml)).** \nThis simple YAML file should define a few possible user inputs that can be used for \ntesting. If you run pytest (see below), it will automatically pick up this file, render \nthe code template with its values, and check that the generated code runs without \nerrors. This file is optional – but it's required if you want to contribute your \ntemplate to this repo. \n\n\n## Installation\n\n**Note: You only need to install Traingenerator if you want to contribute or run it \nlocally. If you just want to use it, go [here](https://traingenerator.streamlitapp.com/).**\n\n```bash\ngit clone https://github.com/jrieke/traingenerator.git\ncd traingenerator\npip install -r requirements.txt\n```\n\n*Optional: For the \"Open in Colab\" button to work you need to set up a Github repo \nwhere the notebook files can be stored (Colab can only open public files if \nthey are on Github). After setting up the repo, create a file `.env` with content:*\n\n```bash\nGITHUB_TOKEN=\u003cyour-github-access-token\u003e\nREPO_NAME=\u003cuser/notebooks-repo\u003e\n```\n\n*If you don't set this up, the app will still work but the \"Open in Colab\" button \nwill only show an error message.*\n\n\n## Running locally\n\n```bash\nstreamlit run app/main.py\n```\n\nMake sure to run always from the `traingenerator` dir (not from the `app` dir), \notherwise the app will not be able to find the templates.\n\n## Deploying to Heroku\n\nFirst, [install heroku and login](https://devcenter.heroku.com/articles/getting-started-with-python#set-up). \nTo create a new deployment, run inside `traingenerator`:\n\n```\nheroku create\ngit push heroku main\nheroku open\n```\n\nTo update the deployed app, commit your changes and run:\n\n```\ngit push heroku main\n```\n\n*Optional: If you set up a Github repo to enable the \"Open in Colab\" button (see above),\nyou also need to run:*\n\n```\nheroku config:set GITHUB_TOKEN=\u003cyour-github-access-token\u003e\nheroku config:set REPO_NAME=\u003cuser/notebooks-repo\u003e\n```\n\n## Testing\n\nFirst, install pytest and required plugins via:\n\n```bash\npip install -r requirements-dev.txt\n```\n\nTo run all tests: \n\n```bash\npytest ./tests\n```\n\nNote that this only tests the code templates (i.e. it renders them with different \ninput values and makes sure that the code executes without error). The streamlit app \nitself is not tested at the moment.\n\nYou can also test an individual template by passing the name of the template dir to \n`--template`, e.g.:\n\n```bash\npytest ./tests --template \"Image classification_scikit-learn\"\n```\n\n---\n\nThe mage image used in Traingenerator is from \n[Twitter's Twemoji library](https://github.com/twitter/twemoji) and \nreleased under Creative Commons Attribution 4.0 International Public License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrieke%2Ftraingenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjrieke%2Ftraingenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrieke%2Ftraingenerator/lists"}