Skip to content

Commit

Permalink
Merge pull request #91 from bertsky/pix2pixhd-as-pkg
Browse files Browse the repository at this point in the history
build with proper pix2pixhd pkg
  • Loading branch information
kba authored Mar 25, 2022
2 parents 8d712b0 + 8e0128a commit 2accbec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ help:
@echo ""
@echo " deps Install python deps via pip"
@echo " install Install"
@echo " patch-pix2pixhd Patch pix2pixhd to trick it into thinking it was part of this mess"
@echo " ocrd_anybaseocr/pix2pixhd Checkout pix2pixhd submodule"
@echo " repo/assets Clone OCR-D/assets to ./repo/assets"
@echo " assets-clean Remove assets"
@echo " assets Setup test assets"
Expand All @@ -53,23 +53,11 @@ deps:
$(PIP_INSTALL) -r requirements.txt

# Install
install: patch-pix2pixhd
install: ocrd_anybaseocr/pix2pixhd
$(PIP_INSTALL) .
.PHONY: patch-pix2pixhd

# Patch pix2pixhd to trick it into thinking it was part of this mess
PIX2PIX_FILES = ocrd_anybaseocr/pix2pixhd/*/*.py ocrd_anybaseocr/pix2pixhd/*.py
patch-pix2pixhd: pix2pixhd
touch ocrd_anybaseocr/pix2pixhd/__init__.py
sed -i 's,^from util,from ..util,' $(PIX2PIX_FILES)
sed -i 's,^import util,import ..util,' $(PIX2PIX_FILES)
sed -i 's,^\(\s*\)from data,\1from .data,' ocrd_anybaseocr/pix2pixhd/*.py
sed -i 's,^\(\s*\)from data,\1from ..data,' ocrd_anybaseocr/pix2pixhd/*/*.py
# string exceptions, srsly y
sed -i "s,raise('\([^']*\)',raise(Exception('\1')," $(PIX2PIX_FILES)

pix2pixhd:
git submodule update --init

ocrd_anybaseocr/pix2pixhd:
git submodule update --init $@

#
# Assets
Expand Down
2 changes: 1 addition & 1 deletion ocrd_anybaseocr/cli/ocrd_anybaseocr_dewarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _process_segment(self, dataset, segment, coords, orig_img_size, input_file):
dewarped = np.mean(dewarped, axis=2) > ocrolib.midrange(dewarped)
dewarped = Image.fromarray(dewarped)
coords['features'] += ',dewarped'
file_id = make_file_id(input_file, self.output_file_grp) + '.IMG-DEW'
file_id = make_file_id(input_file, self.output_file_grp) + '_' + segment.id + '.IMG-DEW'
file_path = self.workspace.save_image_file(dewarped,
file_id,
page_id=input_file.pageId,
Expand Down
2 changes: 1 addition & 1 deletion ocrd_anybaseocr/pix2pixhd
Submodule pix2pixhd updated 47 files
+49 −0 .pylintrc
+148 −144 README.md
+0 −54 encode_features.py
+0 −0 pix2pixhd/__init__.py
+0 −0 pix2pixhd/data/__init__.py
+17 −17 pix2pixhd/data/aligned_dataset.py
+3 −4 pix2pixhd/data/base_data_loader.py
+11 −11 pix2pixhd/data/base_dataset.py
+2 −2 pix2pixhd/data/custom_dataset_data_loader.py
+1 −1 pix2pixhd/data/data_loader.py
+2 −2 pix2pixhd/data/image_folder.py
+60 −0 pix2pixhd/encode_features.py
+0 −0 pix2pixhd/models/__init__.py
+11 −11 pix2pixhd/models/base_model.py
+2 −2 pix2pixhd/models/models.py
+73 −73 pix2pixhd/models/networks.py
+65 −63 pix2pixhd/models/pix2pixHD_model.py
+100 −101 pix2pixhd/models/ui_model.py
+0 −0 pix2pixhd/options/__init__.py
+20 −20 pix2pixhd/options/base_options.py
+2 −2 pix2pixhd/options/test_options.py
+5 −5 pix2pixhd/options/train_options.py
+39 −0 pix2pixhd/precompute_feature_maps.py
+7 −9 pix2pixhd/run_engine.py
+19 −13 pix2pixhd/test.py
+35 −28 pix2pixhd/train.py
+0 −0 pix2pixhd/util/__init__.py
+0 −0 pix2pixhd/util/html.py
+0 −0 pix2pixhd/util/image_pool.py
+4 −4 pix2pixhd/util/util.py
+3 −5 pix2pixhd/util/visualizer.py
+0 −33 precompute_feature_maps.py
+6 −0 requirements.txt
+1 −1 scripts/test_1024p.sh
+5 −5 scripts/test_1024p_feat.sh
+4 −3 scripts/test_512p.sh
+6 −5 scripts/test_512p_feat.sh
+5 −4 scripts/train_1024p_12G.sh
+5 −4 scripts/train_1024p_24G.sh
+7 −6 scripts/train_1024p_feat_12G.sh
+7 −6 scripts/train_1024p_feat_24G.sh
+3 −2 scripts/train_512p.sh
+3 −2 scripts/train_512p_feat.sh
+3 −2 scripts/train_512p_fp16.sh
+3 −2 scripts/train_512p_fp16_multigpu.sh
+3 −2 scripts/train_512p_multigpu.sh
+34 −0 setup.py
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ shapely
tensorflow
torch>=1.1.0
torchvision >= 0.6.1
pix2pixhd # @ ./ocrd_anybaseocr/pix2pixhd

0 comments on commit 2accbec

Please sign in to comment.