Skip to content
Snippets Groups Projects

Remove DPIAdjusting transform

Merged Manon Blanco requested to merge remove-dpi into main
All threads resolved!
2 files
+ 1
56
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 1
48
@@ -20,22 +20,6 @@ from torchvision.transforms import (
from torchvision.transforms.functional import InterpolationMode
class DPIAdjusting:
"""
Resolution modification
"""
def __init__(self, factor):
self.factor = factor
def __call__(self, x):
w, h = x.size
return x.resize(
(int(np.ceil(w * self.factor)), int(np.ceil(h * self.factor))),
Image.BILINEAR,
)
class Dilation:
"""
OCR: stroke width increasing
@@ -175,33 +159,8 @@ def get_list_augmenters(img, aug_configs, fill_value):
for aug_config in aug_configs:
if rand((1,)) > aug_config["proba"]:
continue
if aug_config["type"] == "dpi":
valid_factor = False
while not valid_factor:
factor = Uniform(
aug_config["min_factor"], aug_config["max_factor"]
).sample()
valid_factor = not (
(
"max_width" in aug_config
and factor * img.size[0] > aug_config["max_width"]
)
or (
"max_height" in aug_config
and factor * img.size[1] > aug_config["max_height"]
)
or (
"min_width" in aug_config
and factor * img.size[0] < aug_config["min_width"]
)
or (
"min_height" in aug_config
and factor * img.size[1] < aug_config["min_height"]
)
)
augmenters.append(DPIAdjusting(factor))
elif aug_config["type"] == "zoom_ratio":
if aug_config["type"] == "zoom_ratio":
ratio_h = Uniform(
aug_config["min_ratio_h"], aug_config["max_ratio_h"]
).sample()
@@ -340,12 +299,6 @@ def aug_config(proba_use_da, p):
"order": "random",
"proba": proba_use_da,
"augmentations": [
{
"type": "dpi",
"proba": p,
"min_factor": 0.75,
"max_factor": 1,
},
{
"type": "perspective",
"proba": p,
Loading