-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
149 lines (122 loc) · 4.39 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# FOLDERS
VENV := venv
PROJECT_NAME := ffdnet
# PROGRAMS AND FLAGS
PYTHON := python3
PYFLAGS :=
PIP := pip
# ======= TRAIN =========
TRAIN := -m ffdnet train
TRAIN_FLAGS := --filter wiener --gray --traindbf datasets/train_gray.h5 --valdbf datasets/val_gray.h5 --gpu_fraction 0.3
# ======= TEST =========
TEST := -m ffdnet test
TEST_FLAGS := images/lena.jpg weigths/best.pth ./images --device cuda
# ======= PRNU =========
PRNU := -m ffdnet prnu
PRNU_FLAGS := ../dataset_test_prnu/ experiments/wiener_1.8.1/best.pth --gray --output ../test2 --cut_dim 256 256 3
# ======= DOC =========
AUTHORS := --author "Matias Tassano, Simone Alghisi, Samuele Bortolotti, Massimo Rizzoli"
VERSION :=-r 0.1
LANGUAGE := --language en
SPHINX_EXTENSIONS := --extensions sphinx.ext.autodoc --extensions sphinx.ext.napoleon --extensions sphinx.ext.viewcode
DOC_FOLDER := docs
## Quickstart
SPHINX_QUICKSTART := sphinx-quickstart
SPHINX_QUICKSTART_FLAGS := --sep --no-batchfile --project ffdnet $(AUTHORS) $(VERSION) $(LANGUAGE) $(SPHINX_EXTENSIONS)
# Build
BUILDER := html
SPHINX_BUILD := make $(BUILDER)
SPHINX_API_DOC := sphinx-apidoc
SPHINX_API_DOC_FLAGS := -o $(DOC_FOLDER)/source .
SPHINX_THEME = sphinx_rtd_theme
DOC_INDEX := index.html
# INDEX.rst
define INDEX
.. ffdnet documentation master file, created by
sphinx-quickstart on Sat Nov 20 23:38:46 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. include:: ../../README.rst
.. toctree::
:maxdepth: 3
:caption: Contents:
modules
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
endef
export INDEX
# COLORS
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
NONE := \033[0m
# COMMANDS
ECHO := echo -e
MKDIR := mkdir -p
OPEN := xdg-open
SED := sed
# RULES
.PHONY: help env install install-mmlab install-dev train test prnu doc doc-layout
help:
@$(ECHO) '$(YELLOW)Makefile help$(NONE)'
@$(ECHO) " \
* env : generates the virtual environment using venv\n \
* install : install the requirements listed in requirements.txt\n \
* install-mmlab : install the requirements for the MMlab GPU listed in requirements.mmlabgpu.txt \n \
* install-dev : install the development requirements listed in requirements.dev.txt\n \
* doc-layout : generates the Sphinx documentation layout\n \
* doc : generates the documentation (requires an existing documentation layout)\n \
* open-doc : opens the documentation\n \
* train : train the FFDNet\n \
* test : test the FFDNet\n \
* prnu : test the FFDNet PRNU"
env:
@$(ECHO) '$(GREEN)Creating the virtual environment..$(NONE)'
@$(MKDIR) $(VENV)
@$(eval PYTHON_VERSION=$(shell $(PYTHON) --version | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | cut -f1,2 -d'.'))
@$(PYTHON_VERSION) -m venv $(VENV)/$(PROJECT_NAME)
@$(ECHO) '$(GREEN)Done$(NONE)'
install:
@$(ECHO) '$(GREEN)Installing requirements..$(NONE)'
@pip install -r requirements.txt
@$(ECHO) '$(GREEN)Done$(NONE)'
install-mmlab:
@$(ECHO) '$(GREEN)Installing requirements for MMlab GPU..$(NONE)'
@pip install -r requirements.mmlabgpu.txt
@$(ECHO) '$(GREEN)Done$(NONE)'
install-dev:
@$(ECHO) '$(GREEN)Installing requirements..$(NONE)'
@$(PIP) install -r requirements.dev.txt
@$(ECHO) '$(GREEN)Done$(NONE)'
doc-layout:
@$(ECHO) '$(BLUE)Generating the Sphinx layout..$(NONE)'
$(SPHINX_QUICKSTART) $(DOC_FOLDER) $(SPHINX_QUICKSTART_FLAGS)
@$(ECHO) "\nimport os\nimport sys\nsys.path.insert(0, os.path.abspath('../..'))" >> $(DOC_FOLDER)/source/conf.py
@$(ECHO) "$$INDEX" > $(DOC_FOLDER)/source/index.rst
@$(SED) -i -e "s/html_theme = 'alabaster'/html_theme = '$(SPHINX_THEME)'/g" $(DOC_FOLDER)/source/conf.py
@$(ECHO) '$(BLUE)Done$(NONE)'
doc:
@$(ECHO) '$(BLUE)Generating the documentation..$(NONE)'
$(SPHINX_API_DOC) $(SPHINX_API_DOC_FLAGS)
cd $(DOC_FOLDER); $(SPHINX_BUILD)
@$(ECHO) '$(BLUE)Done$(NONE)'
open-doc:
@$(ECHO) '$(BLUE)Open documentation..$(NONE)'
$(OPEN) $(DOC_FOLDER)/build/$(BUILDER)/$(DOC_INDEX)
@$(ECHO) '$(BLUE)Done$(NONE)'
train:
@$(ECHO) '$(BLUE)Training the FFDNet..$(NONE)'
@$(PYTHON) $(PYFLAGS) $(TRAIN) $(TRAIN_FLAGS)
@$(ECHO) '$(BLUE)Done$(NONE)'
test:
@$(ECHO) '$(BLUE)Testing the FFDNet..$(NONE)'
@$(PYTHON) $(PYFLAGS) $(TEST) $(TEST_FLAGS)
@$(ECHO) '$(BLUE)Done$(NONE)'
prnu:
@$(ECHO) '$(BLUE)Testing the FFDNet PRNU..$(NONE)'
@$(PYTHON) $(PYFLAGS) $(PRNU) $(PRNU_FLAGS)
@$(ECHO) '$(BLUE)Done$(NONE)'