mirror of
https://github.com/Laurent2916/REVA-QCAV.git
synced 2024-11-09 23:12:05 +00:00
309 lines
3.2 MiB
Plaintext
309 lines
3.2 MiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/home/laurent_fainsin/Documents/unet/.venv/lib/python3.8/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
||
|
" from .autonotebook import tqdm as notebook_tqdm\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from PIL import Image\n",
|
||
|
"import numpy as np\n",
|
||
|
"\n",
|
||
|
"import albumentations as A\n",
|
||
|
"\n",
|
||
|
"%config InlineBackend.figure_formats = ['svg']\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"\n",
|
||
|
"from utils import RandomPaste"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Drafts"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1044.8875pt\" height=\"491.194526pt\" viewBox=\"0 0 1044.8875 491.194526\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-08-26T10:49:29.478173</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.3, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 491.194526 \nL 1044.8875 491.194526 \nL 1044.8875 0 \nL 0 0 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 467.316401 \nL 489.832955 467.316401 \nL 489.832955 10.770946 \nL 33.2875 10.770946 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g clip-path=\"url(#p4d4f423724)\">\n <image xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAnsAAAJ7CAYAAACbNFeXAAEAAElEQVR4nOy92YLsOo4dCkbu020/XLv85P//PNvt7nJ1TWfYwfsgkQTAhYEKRWZkplC1T4Y4gCBFAovgoPI//vufKhWiSidSaQxP5XrRl6NCH9ZH6l78RR9MR15EJk+UpvW7RzrBo51oPX+lSuXMjlvrpq+/JX2g/nmEXk53Jdrx5WRmVMo2DhrVPewz9g1IlWot9KMUovvpvL9KI130XPrAfvKqiufb0ZEXkckTpTmjAzzKYz3/qUCP6BsDPaJPa8xf7pUl2vHlZGak8Uoh+rR9A1KhUohupwO9iy666KKLLrroootehm4fLcBFF1100UUXXXTRRc+jC+xddNFFF1100UUXfWG6wN5FF1100UUXXXTRF6YL7F100UUXXXTRRR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
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# paste_img = Image.open(\"/media/disk1/lfainsin/SPHERES/real/2022_SM/Face/2/DSC_0200.jpg\").convert(\"RGBA\")\n",
|
||
|
"# paste_mask = Image.open(\"/media/disk1/lfainsin/SPHERES/real/2022_SM/Face/2/MASK.PNG\").convert(\"LA\")\n",
|
||
|
"\n",
|
||
|
"paste_img = Image.open(\"/media/disk1/lfainsin/SPHERES/synth/void_specular/0035.png\").convert(\"RGBA\")\n",
|
||
|
"paste_mask = Image.open(\"/media/disk1/lfainsin/SPHERES/synth/void_specular/MASK.PNG\").convert(\"LA\")\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(18, 10))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.imshow(paste_img)\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.imshow(paste_mask)\n",
|
||
|
"\n",
|
||
|
"ax = plt.gca()\n",
|
||
|
"ax.set_facecolor('xkcd:salmon')\n",
|
||
|
"\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1044.8875pt\" height=\"490.34604pt\" viewBox=\"0 0 1044.8875 490.34604\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-08-26T10:49:30.071623</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.3, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 490.34604 \nL 1044.8875 490.34604 \nL 1044.8875 0 \nL 0 0 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 466.467915 \nL 489.832955 466.467915 \nL 489.832955 9.922461 \nL 33.2875 9.922461 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g clip-path=\"url(#pb7ffae7021)\">\n <image xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAnsAAAJ7CAYAAACbNFeXAAEAAElEQVR4nOz96ZfjOnImDgcoZWbVreXe26u72+7FdveM54t/Hv//333OnDPu9uulx333rZbMyj21i3w/UCADIAIIkCBFSfHUyRIEBQJBcMHDCCzq008+LQooQHDEUKpOFx3OdSI9CukputjTAYrIT2ZNqjYXtIPCSXS9YZlE50UR51rOegTwDRnZcJyi8eqVM0ldMx3MHxSp7DTvqTEfMQHjnsU/HOCxMJHt2wCBQCAQCAQCQX+YHiQrF8QhlWcpkZ59efMMG3qvYP/HeNIocLLfczGG6/ng0aEJOUXj1RfOZDr9+0EqOw+eN5zgPSuePYFAIBAIBIJDADUGKYBpWisEnXAoAz8EAoFAkAz60S+PfYEfaneRxF8pQvbGBLnTBQKB4OQgj34BDwW0de1JGFcgEAgEAoHgINDu1UA8e4LxQ8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
"text/plain": [
|
||
|
"<Figure size 1800x1000 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"resampler = Image.Resampling.LANCZOS\n",
|
||
|
"\n",
|
||
|
"paste_image_resized = paste_img.resize((212, 212), resample=resampler)\n",
|
||
|
"paste_mask_resized = paste_mask.resize((212, 212), resample=resampler)\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(18, 10))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.imshow(paste_image_resized)\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.imshow(paste_mask_resized)\n",
|
||
|
"\n",
|
||
|
"ax = plt.gca()\n",
|
||
|
"ax.set_facecolor('xkcd:salmon')\n",
|
||
|
"\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1038.525pt\" height=\"487.62358pt\" viewBox=\"0 0 1038.525 487.62358\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-08-26T10:49:30.612374</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.3, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 487.62358 \nL 1038.525 487.62358 \nL 1038.525 0 \nL 0 0 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 26.925 463.745455 \nL 483.470455 463.745455 \nL 483.470455 7.2 \nL 26.925 7.2 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g clip-path=\"url(#p7f5eee2f98)\">\n <image xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAnsAAAJ7CAYAAACbNFeXAAAgWUlEQVR4nO3dsa4kaZUn8MjIzFu3qqhL3UZggLAQD8ATtDOLNGAgoRXj8wy4WDs+jzDrIWEgYeyAsSPNYgNvgYOEWjTVTVfdm5Fr9DozrPM/6ns29tTvZ8fR+b4vIiP/mc453N/fX5fQ9ZqVHA6HtEXco2Kv66oobGXZtnwv67pG11fOa6/3Za/r6pLuv7b1nuelQ8ez3/V87XVdHbo+93mfvEfltuz13qfH1bH3z/vs89nPvrkBAPj/irAHADCYsAcAMJiwBwAwmLAHADCYsAcAMJiwBwAwmLAHADCYsAcAMJiwBwAwmLAHADCYsAcAMNipUrTXwcgd9jp0vaKylY57Oel56bBWhnUX+uz1vux1XR1D1Cs9Sp/77enXVXooD1lR5VHper467n3lkDvWVTvjtM8+3xNd/LMHADCYsAcAMJiwBwAwmLAHADCYsAcAMJiwBwAwmLAHADCYsAcAMJiwBwAwmLAHADCYsAcAMNipY+5f36y8SdL998zs3ets4Pf5edkKe6+cV8e9f5/v47J0zZ5+8halt1Hl8QpH9r739vr+7ljXnnNIurbKuvyzB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m2Lrl/X/D+ktMey7PhzXyhJ91JZl3/2AAAGE/YAAAYT9gAABhP2AAAGE/YAAAYT9gAABhP2AAAGE/YAAAYT9gAABhP2AAAGE/YAAAY7VYo65rh1qMzWK80W7Nh/PlqwNiey4943zBbs0vLst41t7ZiPmm8mntfc9azsdO54Zf97fYfHSq+jfc5rrui4j6U5t2vhmdyGPJMFlefLP3sAAIMJewAAgwl7AACDCXsAAIMJewAAgwl7AACDCXsAAIMJewAAgwl7AACDCXsAAIMJewAAgwl7AACDnSpFex2KnQ4HruyisvdrYTB0rDRIujCwOh3AXBkIvtPnq+u5j5/jwroqg7T3+rlPVXbRdV4d977lLhY+9odCUccz2fZZSV+tlUPeqetWOa9s/5XT6nrndfTxzx4AwGDCHgDAYMIeAMBgwh4AwGDCHgDAYMIeAMBgwh4AwGDCHgDAYMIeAMBgwh4AwGDCHgDAYMIeAMBgp//XC/gipcOE9zwMPt5LoUdl/7Gdnteedexlr+fV8pksDanP11XaS9wkblHaf8u7oiBd116f+2VZlkN4Myt76biPbetK+zR9his6sot/9gAABhP2AAAGE/YAAAYT9gAABhP2AAAGE/YAAAYT9gAABhP2AAAGE/YAAAYT9gAABhP2AAAGOxWmMbbomEm3bduT96ja6yzKSfOH9yo9sknH1XHva+Nkdzrvc6eule+V0sjifc567eiz1++IvaqcVyUj7PW++GcPAGAwYQ8AYDBhDwBgMGEPAGAwYQ8AYDBhDwBgMGEPAGAwYQ8AYDBhDwBgMGEPAGAwYQ8AYDBhDwBgsFNlLPhO5/zGO6kMLO4aip1qG9QeKp1XwwD5yt5L51WoWcOayrqOx2Nck+oaCJ726frcd9WkKsPd05rrlu9jW/J1dZj0PbFXHefV
|
||
|
"text/plain": [
|
||
|
"<Figure size 1800x1000 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import cv2\n",
|
||
|
"\n",
|
||
|
"# transform = A.Compose([A.RandomScale((-0.95, -0.25), interpolation=cv2.INTER_LANCZOS4)])\n",
|
||
|
"transform = A.Compose([A.Resize(width=50, height=50, interpolation=cv2.INTER_LANCZOS4)])\n",
|
||
|
"\n",
|
||
|
"augmentations = transform(image=np.asarray(paste_img), mask=np.asarray(paste_mask))\n",
|
||
|
"paste_image_resized2 = augmentations[\"image\"]\n",
|
||
|
"paste_mask_resized2 = augmentations[\"mask\"]\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(18, 10))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.imshow(Image.fromarray(paste_image_resized2))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.imshow(Image.fromarray(paste_mask_resized2))\n",
|
||
|
"\n",
|
||
|
"ax = plt.gca()\n",
|
||
|
"ax.set_facecolor('xkcd:salmon')\n",
|
||
|
"\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1038.525pt\" height=\"487.62358pt\" viewBox=\"0 0 1038.525 487.62358\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-08-26T10:49:31.129178</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.3, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 487.62358 \nL 1038.525 487.62358 \nL 1038.525 0 \nL 0 0 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 26.925 463.745455 \nL 483.470455 463.745455 \nL 483.470455 7.2 \nL 26.925 7.2 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g clip-path=\"url(#pb24e389b77)\">\n <image xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAnsAAAJ7CAYAAACbNFeXAAAdJ0lEQVR4nO3dT6hkd7Uv8F+d2lXd55z+c066O32jJk9vEq8Q4uBOFOGJCN7BAyGoIwfiwKk4eyJmIPhyL9yx0CKKDgRnQUTe5IUQhAwSFDRRUYTEqEm6Y3fSne7zt6p2vYHeUQY3a9G1u1z9+YzXl7XrnNOpb/ZkjVpry8bdKvO73w/OX0/seCuRuRqcv5LYcXmgzBvB+ehnby33M74enL+Z2LGXyBwG548SO+aJTJ/IANx2G3f6AQAAWB1lDwCgMGUPAKAwZQ8AoDBlDwCgMGUPAKAwZQ8AoDBlDwCgMGUPAKAwZQ8AoDBlDwCgMGUPAKCwUWtteacfAgrL/PtaBOdniR1HicxBcH4vseNmInMjOH89seNaIvPXATJXEzveTGTeCs6/ndhxK5HZD85H/4Zba+04kcn8m+yD8767ede82QMAKEzZAwAoTNkDAChM2QMAKEzZAwAoTNkDAChM2QMAKEzZAwAoTNkDAChM2QMAKEzZAwAozG1cgPUR/e9x9J5qa63NE5nofdjDxI7ondvW4vd0Mzd7rycymfvD0TvHQ9xeb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
|
],
|
||
|
"source": [
|
||
|
"import torchvision.transforms as T\n",
|
||
|
"\n",
|
||
|
"transform = T.Compose(\n",
|
||
|
" [\n",
|
||
|
" T.RandomAffine(0, shear=(-20, 20, -20, 20), interpolation=T.InterpolationMode.BILINEAR),\n",
|
||
|
" T.Resize((50, 50), T.InterpolationMode.BILINEAR),\n",
|
||
|
" ]\n",
|
||
|
")\n",
|
||
|
"\n",
|
||
|
"paste_image_resized3 = paste_img\n",
|
||
|
"paste_image_resized3 = T.functional.adjust_brightness(paste_image_resized3, 1.2)\n",
|
||
|
"paste_image_resized3 = T.functional.adjust_contrast(paste_image_resized3, 1.2)\n",
|
||
|
"paste_image_resized3 = T.functional.affine(paste_image_resized3, angle=0, translate=(0, 0), scale=0.95, shear=(5, 5), interpolation=T.InterpolationMode.BILINEAR)\n",
|
||
|
"paste_image_resized3 = T.functional.resize(paste_image_resized3, (50, 50), interpolation=T.InterpolationMode.BILINEAR)\n",
|
||
|
"\n",
|
||
|
"paste_mask_resized3 = paste_mask\n",
|
||
|
"paste_mask_resized3 = T.functional.affine(paste_mask_resized3, angle=0, translate=(0, 0), scale=0.95, shear=(5, 5), interpolation=T.InterpolationMode.BILINEAR)\n",
|
||
|
"paste_mask_resized3 = T.functional.resize(paste_mask_resized3, (50, 50), interpolation=T.InterpolationMode.BILINEAR)\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(18, 10))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.imshow(paste_image_resized3)\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.imshow(paste_mask_resized3)\n",
|
||
|
"\n",
|
||
|
"ax = plt.gca()\n",
|
||
|
"ax.set_facecolor(\"xkcd:salmon\")\n",
|
||
|
"\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1355.796591pt\" height=\"588.722944pt\" viewBox=\"0 0 1355.796591 588.722944\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-08-26T10:49:31.548167</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.3, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M -0 588.722944 \nL 1355.796591 588.722944 \nL 1355.796591 0 \nL -0 0 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 564.844819 \nL 587.6875 564.844819 \nL 587.6875 10.444819 \nL 33.2875 10.444819 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g clip-path=\"url(#p5e6fea08fa)\">\n <image xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAwMAAAMDCAYAAAD+IskjAAEAAElEQVR4nMz9W5MkO44mCH4gqWpm7hHnlllZfV3pnceV/f//Zh9Xpnemqzo780S4m6mSmAdcCFL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jt1OMJAbaT9jpDCLQrfFEEjcnWo7CPC6tBZaq22cQVoXGgbcz96/2Z28Qnz/WudOXF5HCvt7/jQrvL5zAsI2A1izQDYTeEQWZaB9Tqk8PYn4zn9HmmbyLqoGXulysvRhOhjxOjO4jubu4UoalDTUrXkcc4KFEAE/HuMBcnbZ/76nIeozLgvIrDylHBnpKOAcSS5ookdUENtl2esEti75PseKSUHPw0tGGN6qi4ha9Sdctwztn7tO2MwdAgHXSOKcKKuvIS1p5RUAqfGzMSRf5KaDBAM/LwkhfUZtbfvjsxrpKR3wiIzcO8
|
||
|
"text/plain": [
|
||
|
"<Figure size 2500x1000 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"target_img = Image.open(\"/home/laurent_fainsin/Images/bg.jpg\").convert(\"RGBA\").resize((500, 500))\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(25, 10))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.imshow(target_img)\n",
|
||
|
"\n",
|
||
|
"target_img.paste(paste_image_resized3, (100, 100), paste_mask_resized3)\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.imshow(target_img)\n",
|
||
|
"\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Albumentations custom DualTransform"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"1114.560966pt\" height=\"588.844219pt\" viewBox=\"0 0 1114.560966 588.844219\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-08-26T10:57:38.535920</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.3, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 588.844219 \nL 1114.560966 588.844219 \nL 1114.560966 0 \nL 0 0 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 33.2875 564.966094 \nL 344.27125 564.966094 \nL 344.27125 10.566094 \nL 33.2875 10.566094 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g clip-path=\"url(#pec2cede66d)\">\n <image xlink:href=\"data:image/png;base64,\niVBORw0KGgoAAAANSUhEUgAAAbAAAAMDCAYAAADDj0DYAAEAAElEQVR4nIz9WZNk+Zbdh/32/g/nuHtEDjXcvrdnQAAaDQjdoEQjRRlJGUWYDCDNJJES9aonfkJJ7/gQNBIgCLCb3XeuysrMCHc/5z/srYftERWZVQ3Qy8IqwzPC0/0Me1h7rbXlv/l//Vfe28SsYQ5uhdkbywFSOjGnYGPi3ditk2tiKZk5Om00xnAOy4FjKnwYj9hQxJScnNdfv+WbDw2sw9ioIrxe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P7x/Yrzu9d4bNiI2aWNeF47pwPCycXt1zd/8GdWXMgWE4ggwBdZaaInE7KAkhk+qC2WD6xGwy52AMQ1NCNaF6K85UEDGyY1FZWwZRkMm0Ky5H3BxNiqrjNlBzoDJFMHMwJwmkYdwd77jsF/rYI+DfuiiznYSQJOPAHEazhO0bmhNIRjUxpuFF
|
||
|
"text/plain": [
|
||
|
"<Figure size 2500x1000 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"target_img = Image.open(\"/media/disk1/lfainsin/BACKGROUND/coco/000000000723.jpg\").convert(\"RGBA\")\n",
|
||
|
"target_img = np.asarray(target_img, dtype=np.uint8)\n",
|
||
|
"\n",
|
||
|
"target_mask = np.zeros((*target_img.shape[:2], 4), dtype=np.uint8)\n",
|
||
|
"\n",
|
||
|
"transforms = A.Compose([\n",
|
||
|
" RandomPaste(25, \"/media/disk1/lfainsin/SPHERES/\"),\n",
|
||
|
"])\n",
|
||
|
"\n",
|
||
|
"aug = transforms(image=target_img, mask=target_mask)\n",
|
||
|
"aug_image = aug[\"image\"]\n",
|
||
|
"aug_mask = aug[\"mask\"]\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(25, 10))\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.imshow(aug_image)\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.imshow(aug_mask)\n",
|
||
|
"\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3.8.0 ('.venv': poetry)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.8.0"
|
||
|
},
|
||
|
"orig_nbformat": 4,
|
||
|
"vscode": {
|
||
|
"interpreter": {
|
||
|
"hash": "dc80d2c03865715c8671359a6bf138f6c8ae4e26ae025f2543e0980b8db0ed7e"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|