diff --git a/.DS_Store b/.DS_Store index aac5204febf3bcd78dcae180ae50b836f5e40066..87b56ad1c0caa0cd8b0aa4497cbd4d095b75bc27 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.flaskenv b/.flaskenv index 09578f2480a1770be7f1d24ae4fef69e0ea89628..adfe7a48941f238a842cacea32c5d17cf4d9c60e 100644 --- a/.flaskenv +++ b/.flaskenv @@ -1 +1 @@ -FLASK_APP=autoaugmentation \ No newline at end of file +FLASK_APP=auto_augmentation \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8b297e4d01f488181c1de2ae66b7ce67092e0c96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,152 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..b125750ccc15f94f11db68afd39ebf0c9d898803 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +build-job: + stage: build + script: + - echo "Hello, I'm Building" + - pip install pytest + - pip install flask + - pip install pandoc # for pdf making + - pip install weasyprint # for pdf making + +test-job: + stage: test + script: + - echo "Now I'm Testing!" + - python3 -m tests.test_query_processor + +deploy-job: + stage: deploy + script: + - echo "Now I'm Deploying to VM!" + - python3 -m venv venv + - . venv/bin/activate + - pip install -r requirements.txt + - flask run & + - echo "Now I'm Deploying to Heroku!" + - dpl --provider=heroku --app=metarl --api-key=5ccc3ae7-725e-4f9f-b441-0c9a28ebdc1b diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3ee025e601252084a1b6fcad8a6f72b1030a4d2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3 + +RUN pip3 install virtualenv + +RUN python3 -m venv venvs + +COPY requirements.txt requirements.txt + +RUN pip3 install -r requirements.txt + +COPY . . + +CMD ["flask", "run"] \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..05b126a4f3af13308397226e5c9cd881e2913083 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: flask run --host=0.0.0.0 --port=$PORT diff --git a/auto_augmentation/.DS_Store b/auto_augmentation/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d425cd4dcb0261152a0f748a0c6c05c35c554588 Binary files /dev/null and b/auto_augmentation/.DS_Store differ diff --git a/auto_augmentation/__init__.py b/auto_augmentation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..da6ac6a46769c882614ff0940d1535877c4728d7 --- /dev/null +++ b/auto_augmentation/__init__.py @@ -0,0 +1,32 @@ +import os + +from flask import Flask, render_template, request, flash + +from auto_augmentation import home, progress,result + +def create_app(test_config=None): + # create and configure the app + app = Flask(__name__, instance_relative_config=True) + app.config.from_mapping( + SECRET_KEY='dev', + ) + + if test_config is None: + # load the instance config, if it exists, when not testing + app.config.from_pyfile('config.py', silent=True) + else: + # load the test config if passed in + app.config.from_mapping(test_config) + + # ensure the instance folder exists + os.makedirs(app.instance_path, exist_ok=True) + + from auto_augmentation import download_file + + app.register_blueprint(home.bp) + app.register_blueprint(progress.bp) + app.register_blueprint(result.bp) + app.register_blueprint(download_file.bp) + + + return app diff --git a/auto_augmentation/download_file.py b/auto_augmentation/download_file.py new file mode 100644 index 0000000000000000000000000000000000000000..35b9f5a9fdb8b37351cffdc8ccf8d7f51cb131ba --- /dev/null +++ b/auto_augmentation/download_file.py @@ -0,0 +1,12 @@ +from flask import Blueprint, request, render_template, flash, send_file + +bp = Blueprint("download_file", __name__) + +@bp.route("/download_file", methods=["GET"]) +@bp.route("/download", methods=["GET", "POST"]) +def download(): + # Setup for the 'return send_file()' function call at the end of this function + path = 'templates/CNN.zip' # e.g. 'templates/download.markdown' + + return send_file(path, + as_attachment=True) diff --git a/autoaugmentation/app.py b/auto_augmentation/home.py similarity index 95% rename from autoaugmentation/app.py rename to auto_augmentation/home.py index 18442d5a956d4ab26794b553c03538c0f64b58a4..7b14acb5ecee2aea47d184117701959714d10894 100644 --- a/autoaugmentation/app.py +++ b/auto_augmentation/home.py @@ -1,7 +1,7 @@ -from flask import Blueprint, render_template - -bp = Blueprint("home", __name__) - -@bp.route("/") -def index(): - return render_template("home.html") +from flask import Blueprint, render_template + +bp = Blueprint("home", __name__) + +@bp.route("/") +def index(): + return render_template("home.html") diff --git a/auto_augmentation/progress.py b/auto_augmentation/progress.py new file mode 100644 index 0000000000000000000000000000000000000000..b95acdc19ded31e44c9a66dc922bc4eade7ecac6 --- /dev/null +++ b/auto_augmentation/progress.py @@ -0,0 +1,9 @@ +from flask import Blueprint, request, render_template, flash, send_file +import subprocess + +bp = Blueprint("progress", __name__) + +@bp.route("/user_input", methods=["GET", "POST"]) +def response(): + + return render_template("progress.html") \ No newline at end of file diff --git a/auto_augmentation/result.py b/auto_augmentation/result.py new file mode 100644 index 0000000000000000000000000000000000000000..965af5a298f5c22b51b2562a25a25769a0a2d96c --- /dev/null +++ b/auto_augmentation/result.py @@ -0,0 +1,9 @@ +from flask import Blueprint, request, render_template, flash, send_file +import subprocess + +bp = Blueprint("result", __name__) + +@bp.route("/show_result", methods=["GET", "POST"]) +def response(): + + return render_template("result.html") \ No newline at end of file diff --git a/autoaugmentation/.DS_Store b/auto_augmentation/static/.DS_Store similarity index 91% rename from autoaugmentation/.DS_Store rename to auto_augmentation/static/.DS_Store index ce806c27eaa94d0cd9fa3bab974cc9efa760e6f0..cbf9ce2f5606f2ec8e9da4a923b1306d7d64d602 100644 Binary files a/autoaugmentation/.DS_Store and b/auto_augmentation/static/.DS_Store differ diff --git a/autoaugmentation/static/image/data_augment_cat.jpeg b/auto_augmentation/static/image/data_augment_cat.jpeg similarity index 100% rename from autoaugmentation/static/image/data_augment_cat.jpeg rename to auto_augmentation/static/image/data_augment_cat.jpeg diff --git a/auto_augmentation/static/image/training_plot.png b/auto_augmentation/static/image/training_plot.png new file mode 100644 index 0000000000000000000000000000000000000000..1128a55103c47d7ec36b43bb83a1698ae01c44b3 Binary files /dev/null and b/auto_augmentation/static/image/training_plot.png differ diff --git a/auto_augmentation/templates/basic.html b/auto_augmentation/templates/basic.html new file mode 100644 index 0000000000000000000000000000000000000000..db609ea5f49ca101d3394b2e1219c1488160908b --- /dev/null +++ b/auto_augmentation/templates/basic.html @@ -0,0 +1,12 @@ +<!doctype html> +<html> + <head> + {% block head %} + <title>{% block title %}{% endblock %} - Meta Reinforcement Learning for Data Augmentation</title> + {% endblock %} + </head> + <body> + {% block body %}{% endblock %} + </body> +</html> + diff --git a/auto_augmentation/templates/home.html b/auto_augmentation/templates/home.html new file mode 100644 index 0000000000000000000000000000000000000000..a1e7d3d03070c13fc055656ee64443424fb85609 --- /dev/null +++ b/auto_augmentation/templates/home.html @@ -0,0 +1,42 @@ +{% extends "basic.html" %} +{% block title%}Home{% endblock %} +{% block body %} +<h1>Meta Reinforcement Learning for Data Augmentation</h1> + + +<form action="/user_input"> + <!-- upload dataset --> + <label for="dataset">Please upload your dataset here:</label> + <input type="file" name="dataset" class="upload"><br><br> + + <!-- radio button --> + What task is your dataset used for?<br> + <input type="radio" id="outputtype1" + name="output" value="binary_cls"> + <label for="outputtype1">Binary Classification</label><br> + + <input type="radio" id="outputtype2" + name="output" value="multi_cls"> + <label for="outputtype2">Multi-classification</label><br> + + <input type="radio" id="outputtype3" + name="output" value="regression"> + <label for="outputtype3">Linear Regression</label><br><br> + + <label for="data_aug_method">Which data augmentation method you would like exclude?</label> + <select id="data_aug_method" name="data_aug_method"> + <option value="Translate">Translate</option> + <option value="Rotate">Rotate</option> + <option value="AutoContrast">AutoContrast</option> + <option value="Equalize">Equalize</option> + <option value="Solarize">Solarize</option> + <option value="Posterize">Posterize</option> + <option value="Contrast">Contrast</option> + <option value="Brightness">Brightness</option> + + </select><br><br> + + <input type="submit"> +</form> + +{% endblock %} diff --git a/auto_augmentation/templates/progress.html b/auto_augmentation/templates/progress.html new file mode 100644 index 0000000000000000000000000000000000000000..ea4c33d713224bd889f147ddcb5f8d2e6fb0b6f7 --- /dev/null +++ b/auto_augmentation/templates/progress.html @@ -0,0 +1,14 @@ +{% extends "basic.html" %} +{% block title%}Progress{% endblock %} +{% block body %} +Training the model... + +<div> + <img src="{{url_for('static', filename='image/training_plot.png')}}" class="img-thumbnail" /> + <form action="/show_result"> + <input type="submit" value='Show Result'> + </form> + +</div> + +{% endblock %} \ No newline at end of file diff --git a/auto_augmentation/templates/result.html b/auto_augmentation/templates/result.html new file mode 100644 index 0000000000000000000000000000000000000000..6e127fdb1ed52f2abefc166f23dc7b8d25062f48 --- /dev/null +++ b/auto_augmentation/templates/result.html @@ -0,0 +1,18 @@ +{% extends "basic.html" %} +{% block title %}Result{% endblock %} +{% block body %} + +<div> + <b>Accuracy before data augmentation is: 64.6%</b><br> + <b>Accuracy after data augmentation is: 79.3%</b> + +</div> + +<div> + <form action="/download"> + <input type="submit" value='Download CNN'> + </form> +</div> + +{% endblock %} + diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a254e2e411577dcc5abec859535d28502c75e38 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile # path to your Dockerfile diff --git a/autoaugmentation/templates/home.html b/old_templates/home.html similarity index 100% rename from autoaugmentation/templates/home.html rename to old_templates/home.html diff --git a/autoaugmentation/templates/layout.html b/old_templates/layout.html similarity index 100% rename from autoaugmentation/templates/layout.html rename to old_templates/layout.html diff --git a/autoaugmentation/templates/result.html b/old_templates/result.html similarity index 100% rename from autoaugmentation/templates/result.html rename to old_templates/result.html diff --git a/autoaugmentation/templates/progress.html b/progress.html similarity index 100% rename from autoaugmentation/templates/progress.html rename to progress.html diff --git a/stdout.txt b/stdout.txt new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391