• Stars
    star
    1,364
  • Rank 34,464 (Top 0.7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿง™ A web app to generate template code for machine learning

Traingenerator

๐Ÿง™ย  A web app to generate template code for machine learning โœจ

Code style: black



๐ŸŽ‰ Traingenerator is now live! ๐ŸŽ‰

Try it out:
https://traingenerator.streamlitapp.com/


Generate custom template code for PyTorch & sklearn, using a simple web UI built with streamlit. 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. The perfect tool to jumpstart your next machine learning project!


For updates, follow me on Twitter.




Adding new templates

You can add your own template in 4 easy steps (see below), without changing any code in the app itself. Your new template will be automatically discovered by Traingenerator and shown in the sidebar. That's it! ๐ŸŽˆ

Want to share your magic? ๐Ÿง™ PRs are welcome! Please have a look at CONTRIBUTING.md.

Some ideas for new templates: Keras/Tensorflow, Pytorch Lightning, object detection, segmentation, text classification, ...

  1. Create a folder under ./templates. The folder name should be the task that your template solves (e.g. Image classification). Optionally, you can add a framework name (e.g. Image classification_PyTorch). Both names are automatically shown in the first two dropdowns in the sidebar (see image). โœจ Tip: Copy the example template to get started more quickly.
  2. Add a file sidebar.py to the folder (see example). It needs to contain a method show(), which displays all template-specific streamlit components in the sidebar (i.e. everything below Task) and returns a dictionary of user inputs.
  3. Add a file code-template.py.jinja to the folder (see example). This Jinja2 template is used to generate the code. You can write normal Python code in it and modify it (through Jinja) based on the user inputs in the sidebar (e.g. insert a parameter value from the sidebar or show different code parts based on the user's selection).
  4. Optional: Add a file test-inputs.yml to the folder (see example). This simple YAML file should define a few possible user inputs that can be used for testing. If you run pytest (see below), it will automatically pick up this file, render the code template with its values, and check that the generated code runs without errors. This file is optional โ€“ but it's required if you want to contribute your template to this repo.

Installation

Note: You only need to install Traingenerator if you want to contribute or run it locally. If you just want to use it, go here.

git clone https://github.com/jrieke/traingenerator.git
cd traingenerator
pip install -r requirements.txt

Optional: For the "Open in Colab" button to work you need to set up a Github repo where the notebook files can be stored (Colab can only open public files if they are on Github). After setting up the repo, create a file .env with content:

GITHUB_TOKEN=<your-github-access-token>
REPO_NAME=<user/notebooks-repo>

If you don't set this up, the app will still work but the "Open in Colab" button will only show an error message.

Running locally

streamlit run app/main.py

Make sure to run always from the traingenerator dir (not from the app dir), otherwise the app will not be able to find the templates.

Deploying to Heroku

First, install heroku and login. To create a new deployment, run inside traingenerator:

heroku create
git push heroku main
heroku open

To update the deployed app, commit your changes and run:

git push heroku main

Optional: If you set up a Github repo to enable the "Open in Colab" button (see above), you also need to run:

heroku config:set GITHUB_TOKEN=<your-github-access-token>
heroku config:set REPO_NAME=<user/notebooks-repo>

Testing

First, install pytest and required plugins via:

pip install -r requirements-dev.txt

To run all tests:

pytest ./tests

Note that this only tests the code templates (i.e. it renders them with different input values and makes sure that the code executes without error). The streamlit app itself is not tested at the moment.

You can also test an individual template by passing the name of the template dir to --template, e.g.:

pytest ./tests --template "Image classification_scikit-learn"

The mage image used in Traingenerator is from Twitter's Twemoji library and released under Creative Commons Attribution 4.0 International Public License.

More Repositories

1

best-of-streamlit

๐Ÿ† A ranked gallery of awesome streamlit apps built by the community
1,139
star
2

awesome-machine-learning-startups-berlin

๐Ÿค– A curated list of machine learning & artificial intelligence startups in Berlin (Germany)
Python
275
star
3

streamlit-analytics

๐Ÿ‘€ Track & visualize user interactions with your streamlit app
Python
263
star
4

shape-detection

๐ŸŸฃ Object detection of abstract shapes with neural networks
Jupyter Notebook
218
star
5

cnn-interpretability

๐Ÿฅ Visualizing Convolutional Networks for MRI-based Diagnosis of Alzheimerโ€™s Disease
Jupyter Notebook
162
star
6

year-on-github

๐Ÿ™ Share your Github stats for 2020 on Twitter
Python
132
star
7

streamlit-image-select

๐Ÿ–ผ๏ธ An image select component for Streamlit
Python
103
star
8

components-hub

An automated hub of Streamlit components
Python
79
star
9

streamlit-pills

๐Ÿ’Š A Streamlit component to show clickable pills/badges
TypeScript
77
star
10

fastapi-csv

๐Ÿ—๏ธ Create APIs from CSV files within seconds, using fastapi
Python
77
star
11

streamlit-profiler

๐Ÿ„๐Ÿผ Runtime profiler for Streamlit, powered by pyinstrument
Python
39
star
12

streamlit-theme-generator

๐Ÿ‘ฉโ€๐ŸŽจ๏ธ Generate beautiful color themes for Streamlit, powered by colormind.io
Jupyter Notebook
16
star
13

timeseries-rnn

โฑ๏ธ char-rnn for time series data
Python
13
star
14

traintool

๐Ÿ”ง Train off-the-shelf machine learning models in one line of code
Python
12
star
15

readme-template

My template for Github readmes
10
star
16

streamlit-inspector

๐Ÿ•ต๏ธ Streamlit component to inspect Python objects during development
Python
8
star
17

reinforcement-maze

Solving a maze with reinforcement learning
Jupyter Notebook
7
star
18

DiffusionLimitedAggregation

Simulation of 3D cluster formation through diffusion using Cython, NumPy and VPython
Python
7
star
19

evolution-learning

๐Ÿฃ Code for my master thesis "Biologically Plausible Deep Learning through Neuroevolution"
Jupyter Notebook
6
star
20

awstrainer

๐Ÿ› ๏ธ Command line tool for machine learning on AWS
Python
4
star
21

airbnb-sanity

๐Ÿงณ Chrome extension to hide Airbnb listings you don't like
JavaScript
4
star
22

CrisisInYourCity

Web visualization of housing market data during the financial crisis
JavaScript
3
star
23

lstm-biology

Neural networks with LSTM to classify and predict biological cell movement
Jupyter Notebook
3
star
24

awesome-python-utils

โญ Python packages that make dev life easier
2
star
25

drosophila-dynamics

Investigation of a Drosophila motoneuron model for my bachelor thesis
Jupyter Notebook
1
star
26

streamlit-cache

Little exploration of what st.cache could look like
Python
1
star
27

jrieke.github.io

My personal website
CSS
1
star
28

lightshapes

Party lightshow where animations are projected on cardboard shapes
Python
1
star
29

machine-intelligence

Code for the class "Machine Intelligence 1" at TU Berlin
Jupyter Notebook
1
star
30

stcode

Python
1
star
31

NeuroSim

Simple neuron simulator using NumPy and Matplotlib
Python
1
star
32

ioiometer

Android app to measure voltages on the IOIO board
Java
1
star
33

webb-compare-streamlit

Reproducing the amazing WebbCompare app in Streamlit
Python
1
star