Skip to content

Commit

Permalink
feature: make it easy to install and use
Browse files Browse the repository at this point in the history
feature: make it easy to install and use
  • Loading branch information
brycedrennan authored May 4, 2023
2 parents fe2b9f1 + 495334d commit 550fd98
Show file tree
Hide file tree
Showing 39 changed files with 825 additions and 3,105 deletions.
18 changes: 18 additions & 0 deletions .github/pylama_matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "lint-error",
"severity": "error",
"pattern": [
{
"regexp": "^\\s*([^:]*):(\\d+):(\\d+): ([A-Z]{1,3}\\d\\d\\d) (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
71 changes: 71 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Python Checks
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --disable-pip-version-check wheel pip-tools
pip-sync requirements-dev.txt
python -m pip install --disable-pip-version-check --no-deps .
- name: Lint
run: |
echo "::add-matcher::.github/pylama_matcher.json"
pylama --options tox.ini
autoformat:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --disable-pip-version-check black==23.1.0 isort==5.12.0
- name: Autoformatter
run: |
black --diff .
isort --atomic --profile black --check-only .
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install --disable-pip-version-check -r requirements-dev.txt
python -m pip install --disable-pip-version-check .
- name: Get current date
id: date
run: echo "::set-output name=curmonth::$(date +'%Y-%m')"
- name: Cache Model Files
id: cache-model-files
uses: actions/cache@v3
with:
path: |
~/.cache/huggingface
key: ${{ steps.date.outputs.curmonth }}-b
- name: Test with pytest
timeout-minutes: 20
run: |
pytest --durations=50 -v
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.idea
.vscode
.DS_Store
__pycache__
outputs/*
coverage
downloads
.coverage
.coveragerc
build
dist
**/*.ckpt
**/*.egg-info
.python-version
._.DS_Store
.unison*
*.kgrind
*.pyprof
**/.polyscope.ini
**/imgui.ini
**/.eggs
.pytest_cache
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 Gwangbin Bae
Copyright (c) 2023 Bryce Drennan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
SHELL := /bin/bash
python_version = 3.10.11
venv_prefix = baenorm
venv_name = $(venv_prefix)-$(python_version)
pyenv_instructions=https://github.com/pyenv/pyenv#installation
pyenv_virt_instructions=https://github.com/pyenv/pyenv-virtualenv#pyenv-virtualenv


init: require_pyenv ## Setup a dev environment for local development.
@pyenv install $(python_version) -s
@echo -e "\033[0;32m ✔️ 🐍 $(python_version) installed \033[0m"
@if ! [ -d "$$(pyenv root)/versions/$(venv_name)" ]; then\
pyenv virtualenv $(python_version) $(venv_name);\
fi;
@pyenv local $(venv_name)
@echo -e "\033[0;32m ✔️ 🐍 $(venv_name) virtualenv activated \033[0m"
pip install --upgrade pip pip-tools
pip-sync requirements-dev.txt
pip install -e . --no-deps
# the compiled requirements don't included OS specific subdependencies so we trigger those this way
pip install `pip freeze | grep "^torch=="`
@echo -e "\nEnvironment setup! ✨ 🍰 ✨ 🐍 \n\nCopy this path to tell PyCharm where your virtualenv is. You may have to click the refresh button in the pycharm file explorer.\n"
@echo -e "\033[0;32m"
@pyenv which python
@echo -e "\n\033[0m"
@echo -e "The following commands are available to run in the Makefile\n"
@make -s help

af: autoformat ## Alias for `autoformat`
autoformat: ## Run the autoformatter.
@pycln . --all --quiet --extend-exclude __init__\.py
@# ERA,T201
@-ruff --extend-ignore ANN,ARG001,C90,DTZ,D100,D101,D102,D103,D202,D203,D212,D415,E501,RET504,S101,UP006,UP007 --extend-select C,D400,I,W --unfixable T,ERA --fix-only .
@black .
@isort --atomic --profile black .

test: ## Run the tests.
@pytest
@echo -e "The tests pass! ✨ 🍰 ✨"

lint: ## Run the code linter.
@pylama
@echo -e "No linting errors - well done! ✨ 🍰 ✨"

deploy: ## Deploy the package to pypi.org
pip install twine wheel
-git tag $$(python setup.py -V)
git push --tags
rm -rf dist
python setup.py bdist_wheel
#python setup.py sdist
@echo 'pypi.org Username: '
@read username && twine upload --verbose dist/* -u $$username;
rm -rf build
rm -rf dist
@echo "Deploy successful! ✨ 🍰 ✨"

requirements: ## Freeze the requirements.txt file
pip-compile setup.py requirements-dev.in --output-file=requirements-dev.txt --upgrade --resolver=backtracking

require_pyenv:
@if ! [ -x "$$(command -v pyenv)" ]; then\
echo -e '\n\033[0;31m ❌ pyenv is not installed. Follow instructions here: $(pyenv_instructions)\n\033[0m';\
exit 1;\
else\
echo -e "\033[0;32m ✔️ pyenv installed\033[0m";\
fi
@if ! [[ "$$(pyenv virtualenv --version)" == *"pyenv-virtualenv"* ]]; then\
echo -e '\n\033[0;31m ❌ pyenv virtualenv is not installed. Follow instructions here: $(pyenv_virt_instructions) \n\033[0m';\
exit 1;\
else\
echo -e "\033[0;32m ✔️ pyenv-virtualenv installed\033[0m";\
fi

help: ## Show this help message.
@## https://gist.github.com/prwhite/8168133#gistcomment-1716694
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" | sort
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Image-to-Normal-Map
**Create normal maps from images (using AI)**

[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/estimating-and-exploiting-the-aleatoric/surface-normals-estimation-on-nyu-depth-v2-1)](https://paperswithcode.com/sota/surface-normals-estimation-on-nyu-depth-v2-1?p=estimating-and-exploiting-the-aleatoric)
[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/estimating-and-exploiting-the-aleatoric/surface-normals-estimation-on-scannetv2)](https://paperswithcode.com/sota/surface-normals-estimation-on-scannetv2?p=estimating-and-exploiting-the-aleatoric)

<img width=45% src="tests/oval-office-large.jpg"><img width=45% src="tests/oval-office-large-normal.jpg">

**Quick Start**
```bash
pip install imaginairy-normal-map
```

```python
from PIL import Image
from imaginairy_normal_map.model import create_normal_map_pil_img

img = Image.open("oval-office-large.jpg")
normal_img = create_normal_map_pil_img(img)
normal_img.save("oval-office-large-normal.jpg")
```


**This project was made to support the AI image generation project, [imaginAIry](https://github.com/brycedrennan/imaginAIry).**




**Credit to Gwangbin Bae, Ignas Budvytis, and Roberto Cipolla for creation of
the [original algorithm and code](https://github.com/baegwangbin/surface_normal_uncertainty).**




<img width=70% src="https://github.com/baegwangbin/surface_normal_uncertainty/blob/main/figs/readme_scannet.png?raw=true">
<img width=100% src="https://github.com/baegwangbin/surface_normal_uncertainty/blob/main/figs/readme_generalize.png?raw=true">


102 changes: 0 additions & 102 deletions ReadMe.md

This file was deleted.

44 changes: 0 additions & 44 deletions data/dataloader_custom.py

This file was deleted.

Loading

0 comments on commit 550fd98

Please sign in to comment.