def params(): """Return a Params object describing constructor parameters.""" return Params().add("input_dim", "The new length of the shortest dimension", BoundedNumber(int, 0), 512).add("interpolation", "The interpolation type", InterpolationType, "INTER_LINEAR")
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "directory", "the directory to save images to", str, "", True).add( "clean_directory", "whether to forcibly ensure the output directory is empty", bool, True)
def test_missing_required_throws_exception(): def f(_a): pass params = Params().add("a", "", int, 0, True) with pytest.raises(ValueError): params.call_with_params(f, {})
def test_wrong_type_throws_exception(): def f(_a): pass params = Params().add("a", "", int, 0) with pytest.raises(ValueError): params.call_with_params(f, {"a": "hello"})
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "x_range", "normalized x range for coordinates that may be erased", NumericalRange(0.0, 1.0), (0.0, 1.0)).add( "y_range", "normalized y range for coordinates that may be erased", NumericalRange(0.0, 1.0), (0.0, 1.0))
def test_params_default_substitution_works(): def f(a, b): assert a == 1 assert b == 2 params = Params().add("a", "", int, 1).add("b", "", int, 2) params.call_with_params(f, {"a": 1})
def test_unrecognized_param_throws_exception(): def f(_a, _b): pass params = Params().add("a", "", int, 0).add("b", "", int, 0) with pytest.raises(ValueError): params.call_with_params(f, {"c": 3})
def params(): """Return a Params object describing constructor parameters.""" return Params().add("annotations_folder", "The folder where the annotations are stored", str, "", True).add("image_ext", "The file extension for loaded images", str, "jpg")
def params(): """Return a Params object describing constructor parameters.""" return Params().add("max_width", "Maximum width of cropped area (normalized)", BoundedNumber(float, 0, 1), 0.7).add( "max_height", "Maximum height of cropped area (normalized)", BoundedNumber(float, 0, 1), 0.7)
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "angle_range", "The range from which the random angle will be chosen", NumericalRange(-360.0, 360.0), (-10.0, 10.0), )
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "strength", "Compression strength", BoundedNumber(int, 0, 100), 1, )
def test_ensure_conditions_checked(): def f(_a): pass params = Params().add("a", "", int, 0).ensure(lambda params: params["a"] >= 0, "a >= 0") with pytest.raises(ValueError): params.call_with_params(f, {"a": -1})
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "annotations_folder", "the directory to save annotation files to", str, "", True).add( "database", "The name of the source database", str, "").add( "clean_directory", "whether to forcibly ensure the output directory is empty", bool, True)
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "kernel_size", "Specify the kernel size, greater the size, the more the motion", BoundedNumber(int, minimum=0, maximum=None), 10).add("direction", "direction in which the blur is pointer towards", Direction, 'DOWN')
def params(): """Return a Params object describing constructor parameters.""" return ( Params() .add("mean", "", NumericalRange(), (0.485, 0.456, 0.406)) .add("std", "", NumericalRange(), (0.229, 0.224, 0.225)) # Note to user, it will not make sense to tune max_pixel_value to a too small value. .add("max_pixel_value", "", NumericalRange(), (0.0, 255.0)) )
def params(): """Return a Params object describing constructor parameters.""" return Params().add("height", "The height of the resized image", BoundedNumber(int, 0), 512).add("width", "the width of the resized image", BoundedNumber(int, 0), 512).add("interpolation", "The interpolation type", InterpolationType, "INTER_LINEAR")
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "annotations_file", "The path to the CSV file to write the annotations to", str, "", True ).add( "normalized", "whether the bounding box coordinates should be normalized before " "saving", bool, True)
def params(): """Return a Params object describing constructor parameters.""" return Params().add("replace_probs", "", float, 0.1).add("pepper", "The color of the pepper", BoundedNumber(int, 0, 255), 0).add("salt", "The color of the salt", BoundedNumber(int, 0, 255), 255).add("noise_type", "The type of noise", NoiseType, "RGB")
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "annotations_file", "The path to the CSV file containing the annotations", str, "", True ).add( "normalized", "whether the bounding box coordinates are stored in a normalized " "format", bool, True)
def test_with_bound_type_cast_works(): def type_cast(_v): raise RuntimeError("Should not be called") def actual_type_cast(v): return int(v) def f(a): assert a == 1 params = Params().add("a", "", type_cast, 0) params.with_bound_type_cast(type_cast, actual_type_cast).call_with_params( f, {"a": "1"})
def params(): """Return a Params object describing constructor parameters.""" return Params().add("translate_range", "The translate range should be within 0 and 1", NumericalRange(0, 1), (0.2, 0.2))
def params(): """Return a Params object describing constructor parameters.""" return Params().add("augmentations", "", augmentation_list, [])
def params(): """Return a Params object describing constructor parameters.""" return Params()
def params(): """Return a Params object describing constructor parameters.""" return Params().add("annotations_folder", "The folder where the annotations are stored", str, "", True)
def params(): """Return a Params object describing constructor parameters.""" return Params().add("shear_factor", "", float, 0.2)
def params(): """Return a Params object describing constructor parameters.""" return Params().add("angle", "", float, 5)
def params(): """Return a Params object describing constructor parameters.""" return Params().add( "annotations_file", "The path to the JSON file containing the annotations", str, "", True)
def params(): """Return a Params object describing constructor parameters.""" return Params().add("scale_x", "", BoundedNumber(float, -1.0), 0.2).add("scale_y", "", BoundedNumber(float, -1.0), 0.2)
def params(): """Return a Params object describing constructor parameters.""" return Params().add("hue", "", NumericalRange(), (0.0, 0.0)).add( "saturation", "", NumericalRange(), (0.0, 0.0)).add("brightness", "", NumericalRange(), (0.0, 0.0))
def params(): """Return a Params object describing constructor parameters.""" return Params().add("mean", "", float, 0).add("variance", "", float, 0.01)