Created
November 3, 2018 17:32
-
-
Save rcdilorenzo/97543dca1a5bebb17c70953c4fdccf95 to your computer and use it in GitHub Desktop.
Sample code from rcd.ai blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# resize-images.sh | |
# Preprocess Stanford Cars Dataset | |
# Stats for width | |
# ❯ ls cars_**/*.jpg | | |
# xargs -L1 identify -format "%w\n" | | |
# datamash min 1 max 1 mean 1 median 1 | |
# | |
# 78 7800 700.49255483472 640 | |
# | |
# Stats for height | |
# ❯ ls cars_**/*.jpg | | |
# xargs -L1 identify -format "%h\n" | | |
# datamash min 1 max 1 mean 1 median 1 | |
# | |
# 41 5400 483.24584491813 426 | |
function resize_images () { | |
mogrify -resize 640x480 \ # resize to this size | |
-background gray \ # fill with gray as needed | |
-gravity center \ # keep image centered | |
-extent 640x480 \ # set the image size | |
-format jpg \ # keep jpg format | |
-path resized \ # put images in a subfolder (no overwrite) | |
*.jpg # files to resize | |
} | |
# Make resize directories (if not exist) | |
mkdir -p cars_train/resized | |
mkdir -p cars_test/resized | |
# Resize train images | |
cd cars_train | |
resize_images | |
cd .. | |
# Resize test images | |
cd cars_test | |
resize_images | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment