def test_main(self, tmpdir, test_image_url, test_image): images = {"test_image": data.DownloadableImage(test_image_url)} collection = data.DownloadableImageCollection(images,) collection.download(root=tmpdir) actual = collection["test_image"].read(root=tmpdir) desired = test_image ptu.assert_allclose(actual, desired)
def test_read(self, tmpdir, test_image_url, test_image): names = [str(idx) for idx in range(3)] collection = data.DownloadableImageCollection( {name: data.DownloadableImage(test_image_url) for name in names} ) images = collection.read(tmpdir) ptu.assert_allclose(images, dict(zip(names, [test_image] * len(names))))
def test_DownloadableImageCollection(self): with get_tmp_dir() as root: images = {"test_image": data.DownloadableImage(self.TEST_IMAGE_URL)} collection = data.DownloadableImageCollection(images,) collection.download(root=root) actual = collection["test_image"].read(root=root) desired = self.load_image() self.assertImagesAlmostEqual(actual, desired)
def images() -> data.DownloadableImageCollection: images_ = { "neckarfront": data.DownloadableImage( "https://upload.wikimedia.org/wikipedia/commons/0/00/Tuebingen_Neckarfront.jpg", title="Tübingen Neckarfront", author="Andreas Praefcke", license=data.CreativeCommonsLicense(("by",), version="3.0"), md5="dc9ad203263f34352e18bc29b03e1066", file="tuebingen_neckarfront__andreas_praefcke.jpg", ), "shipwreck": data.DownloadableImage( "https://blog-imgs-51.fc2.com/b/e/l/bell1976brain/800px-Shipwreck_turner.jpg", title="Shipwreck of the Minotaur", author="J. M. W. Turner", date="ca. 1810", license=data.ExpiredCopyrightLicense(1851), md5="4fb76d6f6fc1678cb74e858324d4d0cb", file="shipwreck_of_the_minotaur__turner.jpg", ), "starry_night": data.DownloadableImage( "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/1280px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg", title="Starry Night", author="Vincent van Gogh", date="ca. 1889", license=data.ExpiredCopyrightLicense(1890), md5="372e5bc438e3e8d0eb52cc6f7ef44760", ), "the_scream": data.DownloadableImage( "https://upload.wikimedia.org/wikipedia/commons/f/f4/The_Scream.jpg", title="The Scream", author="Edvard Munch", date="ca. 1893", license=data.ExpiredCopyrightLicense(1944), md5="46ef64eea5a7b2d13dbadd420b531249", ), "femme_nue_assise": data.DownloadableImage( "https://upload.wikimedia.org/wikipedia/en/8/8f/Pablo_Picasso%2C_1909-10%2C_Figure_dans_un_Fauteuil_%28Seated_Nude%2C_Femme_nue_assise%29%2C_oil_on_canvas%2C_92.1_x_73_cm%2C_Tate_Modern%2C_London.jpg", title="Figure dans un Fauteuil", author="Pablo Ruiz Picasso", date="ca. 1909", license=data.ExpiredCopyrightLicense(1973), md5="ba14b947b225d9e5c59520a814376944", ), "composition_vii": data.DownloadableImage( "https://upload.wikimedia.org/wikipedia/commons/b/b4/Vassily_Kandinsky%2C_1913_-_Composition_7.jpg", title="Composition VII", author="Wassily Kandinsky", date="1913", license=data.ExpiredCopyrightLicense(1944), md5="bfcbc420684bf27d2d8581fa8cc9522f", ), } return data.DownloadableImageCollection(images_)
def test_download_guides(self, tmpdir, test_image_url, test_image): guide = data.DownloadableImage( test_image_url, file="guide" + path.splitext(test_image_url)[1], ) image = data.DownloadableImage( test_image_url, guides=data.DownloadableImageCollection({"guide": guide}), ) image.download(tmpdir) actual = read_image(path.join(tmpdir, guide.file)) desired = test_image ptu.assert_allclose(actual, desired)
def test_DownloadableImage_download_guides(self): with get_tmp_dir() as root: guide = data.DownloadableImage( self.TEST_IMAGE_URL, file="guide" + path.splitext(self.TEST_IMAGE_URL)[1], ) image = data.DownloadableImage( self.TEST_IMAGE_URL, guides=data.DownloadableImageCollection({"guide": guide}), ) image.download(root) actual = self.load_image(file=path.join(root, guide.file)) desired = self.load_image() self.assertImagesAlmostEqual(actual, desired)
def test_DownloadableImageCollection_read(self): with get_tmp_dir() as root: names = [str(idx) for idx in range(3)] collection = data.DownloadableImageCollection( {name: data.DownloadableImage(self.TEST_IMAGE_URL) for name in names} ) images = collection.read(root) actual = images.keys() desired = names self.assertCountEqual(actual, desired) actuals = images.values() desired = self.load_image() for actual in actuals: self.assertImagesAlmostEqual(actual, desired)
def images() -> data.DownloadableImageCollection: return data.DownloadableImageCollection({ "house": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_content.jpg?raw=true", file="house_concept_tillamook.jpg", license=license( "https://associateddesigns.com/sites/default/files/plan_images/main/craftsman_house_plan_tillamook_30-519-picart.jpg" ), md5="5629bf7b24a7c98db2580ec2a8d784e9", guides=data.DownloadableImageCollection({ "building": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style1_nosky.jpg?raw=true", file="building.jpg", author="Gatys et al.", license=license(), md5="1fa945871244cf1cefc5e08f8da83fdf", ), "sky": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style1_sky.jpg?raw=true", file="sky.jpg", author="Gatys et al.", license=license(), md5="3c21f0d573cc73a6b58b9d559117805b", ), }), ), "watertown": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style1.jpg?raw=true", file="watertown.jpg", license=license("https://de.aliexpress.com/item/1705231003.html"), md5="4cc98a503da5ce6eab0649b09fd3cf77", guides=data.DownloadableImageCollection({ "building": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style1_nosky.jpg?raw=true", file="building.jpg", author="Gatys et al.", license=license(), md5="1fa945871244cf1cefc5e08f8da83fdf", ), "sky": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style1_sky.jpg?raw=true", file="sky.jpg", author="Gatys et al.", license=license(), md5="3c21f0d573cc73a6b58b9d559117805b", ), }), ), "wheat_field": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style2.jpg?raw=true", file="wheat_field.jpg", license=license( "https://upload.wikimedia.org/wikipedia/commons/thumb/c/ce/Wheat-Field-with-Cypresses-%281889%29-Vincent-van-Gogh-Met.jpg/1920px-Wheat-Field-with-Cypresses-%281889%29-Vincent-van-Gogh-Met.jpg" ), md5="4af9e64534c055bf7db5ee3ab7daf608", guides=data.DownloadableImageCollection({ "foreground": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style2_nosky.jpg?raw=true", file="foreground.jpg", author="Gatys et al.", license=license(), md5="67c6e653f4aa629140cb2fc53a3406d9", ), "sky": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig2_style2_nosky.jpg?raw=true", file="sky.jpg", author="Gatys et al.", license=license(), md5="67c6e653f4aa629140cb2fc53a3406d9", ), }), ), "schultenhof": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig3_content.jpg?raw=true", file="schultenhof.jpg", license=license( "https://upload.wikimedia.org/wikipedia/commons/8/82/Schultenhof_Mettingen_Bauerngarten_8.jpg" ), md5="23f75f148b7b94d932e599bf0c5e4c8e", ), "starry_night": data.DownloadableImage( "https://github.com/leongatys/NeuralImageSynthesis/blob/cced0b978fe603569033b2c7f04460839e4d82c4/Images/ControlPaper/fig3_style1.jpg?raw=true", file="starry_night_over_the_rhone.jpg", license=license( "https://upload.wikimedia.org/wikipedia/commons/9/94/Starry_Night_Over_the_Rhone.jpg" ), md5="e67c25e4aa6070cc4e5ab7f3ce91c218", ), })
def images() -> data.DownloadableImageCollection: images_ = { "emma": data.DownloadableImage( "https://live.staticflickr.com/1/2281680_656225393e_o_d.jpg", author="monsieuricon (mricon)", title="Emma", date="17.12.2004", transform=make_image_transform("emma"), license=data.CreativeCommonsLicense(("by", "sa"), "2.0"), note=image_note("https://www.flickr.com/photos/mricon/2281680/"), md5="e3befabfd0215357e580b07e7d0ed05a", ), "jenny": data.DownloadableImage( "https://live.staticflickr.com/8626/16426686859_f882b3d317_o_d.jpg", author="Vidar Schiefloe (lydhode)", title="Jenny", date="06.02.2015", license=data.CreativeCommonsLicense(("by", "sa"), "2.0"), transform=make_image_transform("jenny"), note=image_note( "https://www.flickr.com/photos/lydhode/16426686859/", mirror=True, ), md5="387eeb2d8cd1bf19d14c263e078bb0a1", ), "blue_bottle": data.DownloadableImage( "https://raw.githubusercontent.com/chuanli11/CNNMRF/master/data/content/potrait1.jpg", title="Blue Bottle", author="Christopher Michel (cmichel67)", date="02.09.2014", license="The image is part of a repository that is published under the MIT " "License (MIT) " "(https://github.com/chuanli11/CNNMRF/blob/fddcf4d01e2a6ce201059d8bc38597f74a09ba3f/License#L1)." "The original was probably downloaded from " "https://www.flickr.com/photos/cmichel67/15112861945. " "Proceed at your own risk.", note=image_note("https://www.flickr.com/photos/cmichel67/15112861945"), md5="cb29d11ef6e1be7e074aa58700110e4f", ), "self-portrait": data.DownloadableImage( "https://raw.githubusercontent.com/chuanli11/CNNMRF/master/data/style/picasso.jpg", title="Self-Portrait", author="Pablo Ruiz Picasso", date="1907", license=data.ExpiredCopyrightLicense(1973), note=image_note("https://www.pablo-ruiz-picasso.net/images/works/57.jpg"), md5="4bd9c963fd52feaa940083f07e259aea", ), "s": data.DownloadableImage( "https://live.staticflickr.com/7409/9270411440_cdc2ee9c35_o_d.jpg", author="theilr", title="S", date="18.09.2011", license=data.CreativeCommonsLicense(("by", "sa"), "2.0"), transform=make_image_transform("s"), note=image_note("https://www.flickr.com/photos/theilr/9270411440/"), md5="525550983f7fd36d3ec10fba735ad1ef", ), "composition_viii": data.DownloadableImage( "https://www.wassilykandinsky.net/images/works/50.jpg", title="Composition VIII", author="Wassily Kandinsky", date="1923", license=data.ExpiredCopyrightLicense(1944), md5="c39077aaa181fd40d7f2cd00c9c09619", ), } return data.DownloadableImageCollection(images_)