diff --git a/.DS_Store b/.DS_Store index 720cf3ab50cbd4bb4f33acbbc3cb3516e7778732..dc6600646c5fa4ef00941aabeef5bfd0226c9111 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.flaskenv b/.flaskenv new file mode 100644 index 0000000000000000000000000000000000000000..adfe7a48941f238a842cacea32c5d17cf4d9c60e --- /dev/null +++ b/.flaskenv @@ -0,0 +1 @@ +FLASK_APP=auto_augmentation \ No newline at end of file diff --git a/.gitignore copy b/.gitignore copy new file mode 100644 index 0000000000000000000000000000000000000000..6dc91d8183037294b495ac1607c0f4e4e248edcc --- /dev/null +++ b/.gitignore copy @@ -0,0 +1,157 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +**/__pycache__/ +**/datasets/ +*.py[cod] +*$py.class +*.pyc +*.pyo + +# 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/ +MetaAugment/__pycache__/main.cpython-38.pyc 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/MetaAugment/.DS_Store b/MetaAugment/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a48940a7b5f1285196b9a33f1f3f865b9ff7c9e3 Binary files /dev/null and b/MetaAugment/.DS_Store differ diff --git a/MetaAugment/MetaAugment/.DS_Store b/MetaAugment/MetaAugment/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4b90b228742be4ba376510897baf809e1b98e924 Binary files /dev/null and b/MetaAugment/MetaAugment/.DS_Store differ 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/README copy.md b/README copy.md new file mode 100644 index 0000000000000000000000000000000000000000..4ac558d8dde23924ff0433b28acf1ec667cdb117 --- /dev/null +++ b/README copy.md @@ -0,0 +1,2 @@ +# MetaRL + diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..35d7b5048a516dfdb97a81166359b33f9594272b --- /dev/null +++ b/app.py @@ -0,0 +1,12 @@ +from flask import Flask +from auto_augmentation import create_app +import os +app = create_app() +port = int(os.environ.get("PORT", 5000)) + + +# if __name__ == '__main__': +# app.run(host='0.0.0.0',port=port) + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/auto_augmentation/.DS_Store b/auto_augmentation/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..423820404538e588d0dd42d7334bc8603eccb1b8 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/auto_augmentation/home.py b/auto_augmentation/home.py new file mode 100644 index 0000000000000000000000000000000000000000..7b14acb5ecee2aea47d184117701959714d10894 --- /dev/null +++ b/auto_augmentation/home.py @@ -0,0 +1,7 @@ +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/auto_augmentation/static/.DS_Store b/auto_augmentation/static/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..cbf9ce2f5606f2ec8e9da4a923b1306d7d64d602 Binary files /dev/null and b/auto_augmentation/static/.DS_Store differ diff --git a/auto_augmentation/static/image/data_augment_cat.jpeg b/auto_augmentation/static/image/data_augment_cat.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..900b738c8375325e26d21c43eb3a5ccf3b3c2827 Binary files /dev/null and b/auto_augmentation/static/image/data_augment_cat.jpeg differ 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..a45d6065a4dd65691dac04733d1bd3ff924839c2 --- /dev/null +++ b/auto_augmentation/templates/home.html @@ -0,0 +1,130 @@ +{% extends "basic.html" %} +{% block title%}Home{% endblock %} +{% block body %} +<h1>Meta Reinforcement Learning for Data Augmentation</h1> + +<h3>Choose your dataset</h3> +<form action="/user_input"> + <!-- upload dataset --> + <label for="dataset_upload">You can upload your dataset here:</label> + <input type="file" name="dataset_upload" class="upload"><br><br> + + <!-- dataset radio button --> + Or you can select a dataset from our database: <br> + <input type="radio" id="dataset1" + name="dataset_selection" value="MINIST"> + <label for="dataset1">MINIST dataset</label><br> + + <input type="radio" id="dataset2" + name="dataset_selection" value="IMGNET"> + <label for="dataset2">IMGNET dataset</label><br> + + <input type="radio" id="dataset3" + name="dataset_selection" value="dataset3"> + <label for="dataset3">dataset3</label><br><br> + +<!-- --------------------------------------------------------------- --> + + + <h3>Choose the network which the dataset is trained on</h3> + <!-- upload network --> + <label for="network_upload">Please upload your network here:</label> + <input type="file" name="network_upload" class="upload"><br><br> + + + <!-- network selection --> + Or you can select a dataset from our database: <br> + <input type="radio" id="network1" + name="network_selection" value="EasyNet"> + <label for="dataset1">EasyNet</label><br> + + <input type="radio" id="network2" + name="network_selection" value="LeNet"> + <label for="dataset2">LeNet</label><br> + + <input type="radio" id="network3" + name="network_selection" value="AlexNet"> + <label for="dataset3">AlexNet</label><br><br> + + + + <h3>Advanced Search</h3> + <!-- action(data augmentation) space --> + Which data augmentation method you would like exclude? <br> + <input type="radio" id="ShearX" + name="action_space" value="ShearX"> + <label for="ShearX">ShearX</label><br> + + <input type="radio" id="ShearY" + name="action_space" value="ShearY"> + <label for="ShearY">ShearY</label><br> + + <input type="radio" id="TranslateX" + name="action_space" value="TranslateX"> + <label for="TranslateX">TranslateX</label><br> + + <input type="radio" id="TranslateY" + name="action_space" value="TranslateY"> + <label for="TranslateY">TranslateY</label><br> + + <input type="radio" id="Rotate" + name="Rotate" value="Rotate"> + <label for="Rotate">Rotate</label><br> + + <input type="radio" id="Brightness" + name="action_space" value="Brightness"> + <label for="Brightness">Brightness</label><br> + + <input type="radio" id="Color" + name="action_space" value="Color"> + <label for="Color">Color</label><br> + + <input type="radio" id="Contrast" + name="action_space" value="Contrast"> + <label for="Contrast">Contrast</label><br> + + <input type="radio" id="Sharpness" + name="action_space" value="Sharpness"> + <label for="Sharpness">Sharpness</label><br> + + <input type="radio" id="Posterize" + name="action_space" value="Posterize"> + <label for="Posterize">Posterize</label><br> + + <input type="radio" id="Solarize" + name="action_space" value="Solarize"> + <label for="Solarize">Solarize</label><br> + + <input type="radio" id="AutoContrast" + name="action_space" value="AutoContrast"> + <label for="AutoContrast">AutoContrast</label><br> + + <input type="radio" id="Equalize" + name="action_space" value="Equalize"> + <label for="Equalize">Equalize</label><br> + + <input type="radio" id="Invert" + name="action_space" value="Invert"> + <label for="Invert">Invert</label><br><br><br> + + + + <!-- action space --> + <!-- <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/progress.html b/progress.html new file mode 100644 index 0000000000000000000000000000000000000000..9bad71aadb77c26e3887dfddaa00e38e25d0336a --- /dev/null +++ b/progress.html @@ -0,0 +1,8 @@ +{% extends "structure.html" %} +{% block title%}Home{% endblock %} +{% block body %} +<h1>Loading</h1> + <progress value = "65" max = "100"/> + +{% endblock %} + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..76b3ed54867825d4aadb3d219c376ee10576d1f3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,18 @@ +attrs +click==8.0.3 +Flask==2.0.2 +iniconfig==1.1.1 +itsdangerous==2.0.1 +Jinja2==3.0.3 +MarkupSafe==2.0.1 +packaging==21.3 +pandoc==2.0.1 +pdflatex +pluggy==1.0.0 +py==1.11.0 +pyparsing==3.0.6 +pytest +python-dotenv==0.19.2 +toml==0.10.2 +Werkzeug==2.0.2 +weasyprint==51 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..606849326a4002007fd42060b51e69a19c18675c --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup() diff --git a/stdout.txt b/stdout.txt new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391