{"nbformat": 4, "metadata": {"language_info": {"codemirror_mode": "r", "file_extension": ".r", "pygments_lexer": "r", "version": "3.4.2", "name": "R", "mimetype": "text/x-r-source"}, "kernelspec": {"language": "R", "display_name": "R", "name": "ir"}}, "nbformat_minor": 1, "cells": [{"metadata": {}, "cell_type": "markdown", "source": ["### What can I do in 3 hours with thousands of dog images?"]}, {"source": ["list.files(\"../input\")\n", "list.files(\"../input/dog-breed-identification\")\n", "list.files(\"../input/audio-cats-and-dogs\")"], "metadata": {"_cell_guid": "a110faf0-d8fd-412d-884e-8c8798c628c4", "_uuid": "b309203f181836747043508d6abda304f766aeed"}, "outputs": [], "cell_type": "code", "execution_count": 35}, {"metadata": {}, "cell_type": "markdown", "source": ["### Creating 1 fps 120 seconds GIF animation"]}, {"source": ["library(readr)\n", "library(magick)\n", "\n", "labels <- read_csv(\"../input/dog-breed-identification/labels.csv\")\n", "doggies <- labels[[1]][sample.int(nrow(labels), size = 120)]\n", "\n", "dog_imgs <- image_read(path = paste0(\"../input/dog-breed-identification/train/\", doggies, \".jpg\"))\n", "dog_imgs <- image_scale(dog_imgs, \"480x360\") # 16:9 for YouTube\n", "animation <- image_animate(dog_imgs, fps = 1)\n", "\n", "image_write(animation, \"doggies.gif\")"], "metadata": {"_cell_guid": "10c57db4-af0e-465f-a995-ab93ff890a39", "_uuid": "d1ff6cf701c8bd8fad8b49b61bd865bd80bfdf42"}, "outputs": [], "cell_type": "code", "execution_count": 36}, {"metadata": {}, "cell_type": "markdown", "source": ["### Creating 120 seconds long dog barking"]}, {"source": ["library(tuneR)\n", "\n", "dog_bark_files <- list.files(\"../input/audio-cats-and-dogs/cats_dogs/\", pattern = \"dog_barking*\")\n", "dog_barks <- lapply(paste0(\"../input/audio-cats-and-dogs/cats_dogs/\", dog_bark_files), readWave)\n", "\n", "# Some randomization\n", "dog_barks <- dog_barks[sample.int(length(dog_barks))]\n", "long_bark <- dog_barks[[1]]\n", "for(i in 2:length(dog_barks)) {\n", "    long_bark <- bind(long_bark, dog_barks[[i]])\n", "}\n", "long_bark <- extractWave(long_bark, from = 1, to = 120, xunit = \"time\")\n", "\n", "writeWave(long_bark, filename = \"barking_doggies.wav\")"], "metadata": {"_cell_guid": "c31dbba4-5f78-4bda-966a-84116dadb00f", "_uuid": "68d663cfa247210b1de9e67d52c767f605b13676"}, "outputs": [], "cell_type": "code", "execution_count": 39}, {"source": ["list.files(\".\", pattern = \"[wav|gif]$\")"], "metadata": {}, "outputs": [], "cell_type": "code", "execution_count": 40}, {"metadata": {}, "cell_type": "markdown", "source": ["![Nice doggies](doggies.gif)\n", "\n", "![Download The Audio](barking_doggies.wav)"]}, {"metadata": {}, "cell_type": "markdown", "source": ["At least we have 120 seconds of GIF and Audio\n", "\n", "This is the YouTube link\n", "\n", "https://youtu.be/qlXUA3e2Tr8"]}]}