{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<img src=\"https://i.postimg.cc/zG1WTGCs/logo.png\" height=\"300\" width=\"300\" style=\"display: block;margin-left: auto;margin-right: auto;\">\n\n<h1 style = \"text-align :center; font-family:verdana; color:black; background-image: url(https://i.pinimg.com/originals/dd/f9/97/ddf997d65d8b92a3d7e085d6bf1cc484.jpg); \">AugLy</h1>\n\n**AugLy** is a data augmentations library that supports 4 modalities now (`audio`, `image`, `text`, `video`). AugLy is a great library to utilize for augmenting your data in model training, or to evaluate the robustness gaps of your model. **There are many specific data augmentations that users perform in real life on internet platforms.**\n\n> ### This notebook shows some of examples of **AugLy** image augmentations.\n\n<h2 style = \"text-align :center; font-family:verdana; color:red; background-image: url(https://hookagency.com/wp-content/uploads/2015/11/miracle-grow-light-green-gradient.jpg); \">Sample Image Augmentations</h2>\n\n<img src=\"https://scontent.fmaa1-4.fna.fbcdn.net/v/t39.2365-6/200504953_2969472556657674_7143283902624496813_n.png?_nc_cat=109&ccb=1-3&_nc_sid=ad8a9d&_nc_ohc=2slz1wN5BJoAX9nBH2m&_nc_ht=scontent.fmaa1-4.fna&oh=16187eff83027c036f78ebf76b4762f5&oe=60F0255E\" height=\"600\" width=\"600\" style=\"display: block;margin-left: auto;margin-right: auto;\">\n\n<a href = \"https://ai.facebook.com/blog/augly-a-new-data-augmentation-library-to-help-build-more-robust-ai-models/\" style=\"font-weight:'bold'; color:blue; font-family:monospace; text-align :center;\"><h3>Go to Blog post for more details</h3></a>\n\n<a href = \"https://github.com/facebookresearch/AugLy\" style=\"font-weight:'bold'; color:blue; font-family:monospace; text-align :center;\"><h3>Get the code here</h3></a> \n\n**Credits to all images : Facebook AI Research**","metadata":{}},{"cell_type":"code","source":"##------------------\n#installling library\n##------------------\n\n!pip install -U augly\n!conda install -c conda-forge python-magic -y","metadata":{"_kg_hide-output":true,"scrolled":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##------------------\n#import dependencies\n##------------------\nimport torchvision.transforms as transforms\n\nimport augly.image as imaugs\nimport augly.utils as utils\n\nfrom PIL import Image\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nimport os\nimport requests","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2021-06-20T07:11:28.520585Z","iopub.execute_input":"2021-06-20T07:11:28.521031Z","iopub.status.idle":"2021-06-20T07:11:29.020672Z","shell.execute_reply.started":"2021-06-20T07:11:28.520970Z","shell.execute_reply":"2021-06-20T07:11:29.019533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##--------------------\n#Download sample image\n##--------------------\n\nURL = \"https://upload.wikimedia.org/wikipedia/en/thumb/7/7d/Lenna_%28test_image%29.png/330px-Lenna_%28test_image%29.png\"\nIMPATH = \"./lena.jpg\"\nresponse = requests.get(URL)\n\nfile = open(\"lena.jpg\",\"wb\")\nfile.write(response.content)\nfile.close()","metadata":{"execution":{"iopub.status.busy":"2021-06-20T07:11:29.025272Z","iopub.execute_input":"2021-06-20T07:11:29.025734Z","iopub.status.idle":"2021-06-20T07:11:29.525697Z","shell.execute_reply.started":"2021-06-20T07:11:29.025697Z","shell.execute_reply":"2021-06-20T07:11:29.524333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"font-weight:'bold'; color:blue; font-family:monospace; text-align :center;\"> List of Augmentations</h1>\n\n<img src=\"https://i.postimg.cc/Ghd2J7gp/carbon.png\" height=\"600\" width=\"600\" style=\"display: block;margin-left: auto;margin-right: auto;\">","metadata":{}},{"cell_type":"code","source":"orig = Image.open(IMPATH)\naug1 = imaugs.blur(orig)\naug2 = imaugs.color_jitter(orig)\naug3 = imaugs.contrast(orig)\naug4 = imaugs.hflip(orig)\naug5 = imaugs.vflip(orig)\naug6 = imaugs.rotate(orig)\naug7 = imaugs.sharpen(orig)\naug8 = imaugs.shuffle_pixels(orig)\n\nimg_ls = [orig,aug1,aug2,aug3,aug4,aug5,aug6,aug7,aug8]\ntitles = [\"original\",\"blur\",\"color jitter\",\"contrast\",\"horizontal flip\",\"vertical flip\",\"rotation\",\"sharpen\",\"shuffle pixels\"]","metadata":{"execution":{"iopub.status.busy":"2021-06-20T07:11:30.004305Z","iopub.execute_input":"2021-06-20T07:11:30.004727Z","iopub.status.idle":"2021-06-20T07:11:30.232982Z","shell.execute_reply.started":"2021-06-20T07:11:30.004687Z","shell.execute_reply":"2021-06-20T07:11:30.231921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##---------------------------------------------\n#let's view results with standard Lenna image :)\n##---------------------------------------------\n\nplt.figure(figsize=(20,20))\n\nfor i in range(9):\n    plt.subplot(3,3,i+1)\n    plt.imshow(img_ls[i])\n    plt.axis(\"off\")\n    plt.title(titles[i])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-06-20T07:11:32.412232Z","iopub.execute_input":"2021-06-20T07:11:32.412771Z","iopub.status.idle":"2021-06-20T07:11:33.987384Z","shell.execute_reply.started":"2021-06-20T07:11:32.412738Z","shell.execute_reply":"2021-06-20T07:11:33.986287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<h1 style=\"font-weight:'bold'; color:blue; font-family:monospace; text-align :center;\">TO BE UPDATED</h1>","metadata":{}}]}