-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
92 lines (79 loc) · 3.26 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
SHELL = /bin/bash
PYTHON ?= python
PIP ?= pip
DOCKER_BASE_IMAGE ?= docker.io/ocrd/core-cuda:v2.69.0
DOCKER_TAG ?= ocrd/keraslm
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
@echo " deps pip install -r requirements.txt"
@echo " install pip install ."
@echo " deps-test pip install -r requirements_test.txt"
@echo " test python -m pytest test"
@echo " test/assets prepare test assets"
@echo " docker build Docker image"
@echo ""
@echo " Variables"
@echo " PYTHON name of the Python binary. Default: $(PYTHON)"
@echo " PIP name of the Python packager. Default: $(PIP)"
@echo " TAG name of the Docker image. Default: $(TAG)"
@echo " PYTEST_ARGS pytest args. Set to '-s' to see log output during test execution, '--verbose' to see individual tests. Default: '$(PYTEST_ARGS)'"
@echo ""
# END-EVAL
deps:
$(PIP) install -r requirements.txt
DEU_FRAK_URL = https://github.com/tesseract-ocr/tessdata/raw/4.1.0/deu_frak.traineddata
deps-test:
$(PIP) install -r requirements_test.txt
ocrd resmgr download -n $(DEU_FRAK_URL) ocrd-tesserocr-recognize deu-frak.traineddata
nvidia-tensorflow:
if $(PYTHON) -c 'import sys; print("%u.%u" % (sys.version_info.major, sys.version_info.minor))' | fgrep 3.8 && \
! pip show -q tensorflow-gpu; then \
pip install nvidia-pyindex && \
pushd $$(mktemp -d) && \
pip download --no-deps nvidia-tensorflow && \
for name in nvidia_tensorflow-*.whl; do name=$${name%.whl}; done && \
$(PYTHON) -m wheel unpack $$name.whl && \
for name in nvidia_tensorflow-*/; do name=$${name%/}; done && \
newname=$${name/nvidia_tensorflow/tensorflow_gpu} &&\
sed -i s/nvidia_tensorflow/tensorflow_gpu/g $$name/$$name.dist-info/METADATA && \
sed -i s/nvidia_tensorflow/tensorflow_gpu/g $$name/$$name.dist-info/RECORD && \
sed -i s/nvidia_tensorflow/tensorflow_gpu/g $$name/tensorflow_core/tools/pip_package/setup.py && \
pushd $$name && for path in $$name*; do mv $$path $${path/$$name/$$newname}; done && popd && \
$(PYTHON) -m wheel pack $$name && \
pip install $$newname*.whl && popd && rm -fr $$OLDPWD; \
fi
install:
$(PIP) install .
docker:
docker build \
-t $(DOCKER_TAG) \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") .
export TF_CPP_MIN_LOG_LEVEL = 1
test: test/assets
ifeq ($(TEST_TRAINING),)
test: export OCRD_KERASLM_MODEL = model_dta_full.h5
test:
ocrd resmgr download ocrd-keraslm-rate $(OCRD_KERASLM_MODEL)
else
test: export OCRD_KERASLM_MODEL = $(CURDIR)/model_dta_test.h5
test:
test -f $(OCRD_KERASLM_MODEL) || keraslm-rate train -m $(OCRD_KERASLM_MODEL) test/assets/*.txt
keraslm-rate test -m $(OCRD_KERASLM_MODEL) test/assets/*.txt
endif
$(PYTHON) -m pytest test $(PYTEST_ARGS)
# prepare test assets
test/assets: repo/assets
mkdir -p $@
ocrd workspace -d $@/kant_aufklaerung_1784 clone --download $</data/kant_aufklaerung_1784/data/mets.xml
bash test/prepare_gt.bash $@
repo/assets: always-update
git submodule sync $@
git submodule update --init $@
clean:
$(RM) -r test/assets model_dta_test.h5
.PHONY: help deps deps-test install test clean docker always-update nvidia-tensorflow