-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Xu-Justin/initial_release
Initial release (0.1.0)
- Loading branch information
Showing
222 changed files
with
8,596 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[run] | ||
omit = | ||
*/site-packages/* | ||
*/dist-packages/* | ||
*/distutils/* | ||
tests/* | ||
patchmentation/dataset.py | ||
|
||
disable_warnings = couldnt-parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: docker ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**docker**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: jstnxu/patchmentation:env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python application | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
requirements=requirements/requirements-main.txt | ||
if [ -f $requirements ]; then pip install -r $requirements; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Run test | ||
run: | | ||
pytest -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*__pycache__* | ||
.pytest_cache/* | ||
|
||
.coverage | ||
htmlcov/* | ||
|
||
# development tools | ||
dev.ipynb | ||
.ipynb_checkpoints | ||
|
||
# deployment | ||
build/* | ||
dist/* | ||
*.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM python:3.10.8-slim-bullseye | ||
|
||
RUN apt-get update -qq && \ | ||
apt-get install -y zip unzip htop screen libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
COPY requirements/* /requirements/ | ||
RUN pip --no-cache-dir install -r /requirements/requirements-main.txt | ||
RUN pip --no-cache-dir install -r /requirements/requirements-test.txt | ||
RUN pip --no-cache-dir install -r /requirements/requirements-dev.txt | ||
RUN pip --no-cache-dir install -r /requirements/requirements-streamlit.txt | ||
|
||
WORKDIR /workspace | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
# patchmentation | ||
# patchmentation | ||
|
||
A python library to perform patch augmentation. | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install patchmentation | ||
``` | ||
|
||
THIS README will be updated soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import section | ||
from . import page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os, sys | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
||
import page | ||
|
||
import streamlit as st | ||
from streamlit_option_menu import option_menu | ||
|
||
def main(): | ||
MENU_DATASET = 'Dataset' | ||
MENU_PATCHMENTATION = 'Patchmentation' | ||
|
||
with st.sidebar: | ||
menu = option_menu( | ||
'Main Menu', | ||
[ | ||
MENU_DATASET, | ||
MENU_PATCHMENTATION | ||
], | ||
default_index=0 | ||
) | ||
|
||
if menu == MENU_DATASET: | ||
page.dataset() | ||
|
||
if menu == MENU_PATCHMENTATION: | ||
page.patchmentation() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os, sys | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
||
import section | ||
from patchmentation import patch_augmentation | ||
|
||
import streamlit as st | ||
import random | ||
|
||
def dataset(key: str = 'page-dataset'): | ||
dataset = section.dataset(key=f'{key}-dataset') | ||
section.display_dataset(dataset, key=f'{key}-display_dataset') | ||
|
||
def patchmentation(key: str = 'page-patchmentation'): | ||
dataset = section.dataset(key=f'{key}-dataset') | ||
shuffle = section.input_shuffle(key=f'{key}-shuffle') | ||
negative_patches = section.negative_patch(dataset, key=f'{key}-negative-patches') | ||
background_image = section.background_image(key=f'{key}-background_image') | ||
actions = section.input_actions(key=f'{key}-input_actions') | ||
conf = section.patchmentation_configuration(key=f'{key}-patchmentation_conf') | ||
|
||
if dataset is None: | ||
st.error(f'ERROR: Invalid dataset') | ||
return | ||
|
||
patches = negative_patches | ||
for image_patch in dataset.image_patches: | ||
for patch in image_patch.patches: | ||
patches.append(patch) | ||
|
||
if shuffle: | ||
random.shuffle(patches) | ||
|
||
result_image_patch = patch_augmentation(patches, background_image, conf.get('visibility_threshold', 0.5), actions, max_n_patches=conf.get('max_n_patches', 100)) | ||
section.display_image_patch(result_image_patch, key=f'{key}-display_result_image_patch') | ||
section.refresh_button(key=f'{key}-refresh') |
Oops, something went wrong.