Simple detection script for website images

Just for fun, here's a script that pulls down images from a target website using wget and runs them through one of our SDK samples (static_image_bounding_box.py).

Here's what the output looks like when you run "./wget-and-detect.sh www.xnor.ai":
 


 

wget-and-detect.sh:

#!/bin/bash

# Download JPGs from target website, run them through an Xnor detection
# model using the static image bounding box sample, and make a convenient
# html file to view the results.
#
# Usage:  ./wget-and-detect.sh TARGET_URL

OUT_DIR="./output-dir"
TMP_DIR=$OUT_DIR"/tmp"
HTML_FILE=index.html

BBOX=static_image_bounding_box.py

function usage() {
    echo -e "\nUsage:\n"$0 "TARGET_URL\n"
}

if [ $# -le 0 ]
then
    usage
    exit 1
fi

# clear output directory
rm -rf $OUT_DIR

mkdir $OUT_DIR 2> /dev/null
mkdir $TMP_DIR 2> /dev/null

# copy target website images -> tmp
echo "[Downloading images from $@]"

wget -q -l1 -erobots=off -H -p -r --user-agent="Mozilla/5.0" -nd --accept jpg -P $TMP_DIR "$@"

# classify and output
cd $TMP_DIR

find . -name "*jpg" -exec echo "[Analyzing: "{}"]" \; -exec python3 ../../$BBOX {} ../{}  2> /dev/null \;

cd ..
rm -rf tmp

# make simple html file
echo "[Building "$OUT_DIR"/"$HTML_FILE"]"
echo "<HTML><BODY>" > $HTML_FILE

find . -name "*jpg" -exec echo "<BR>"{}":<BR><IMG SRC="{}"><BR>" >> $HTML_FILE \;

echo "</BODY>\n</HTML>\n" >> $HTML_FILE
Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like6 Follow
  • 6 Likes
  • 7 mths agoLast active
  • 150Views
  • 2 Following