Last active
February 16, 2018 15:56
-
-
Save AruniRC/ee4ebb1ffbf31f7ce64d78f203f3d5b2 to your computer and use it in GitHub Desktop.
Skeleton code for visualizing multiple images in a nested-folder-structure as an HTML page.
This file contains hidden or 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
# Displays a set of images in a particular format in an HTML page | |
# Can be easily modified for custom use-cases, especially visualizing experiment results. | |
# | |
# Consider image existing in the following folder structure: | |
# DATA_PATH | |
# image01.jpg | |
# im_det0.jpg | |
# im_det1.jpg | |
# im_det2.jpg ... | |
# image02.jpg | |
# im_det0.jpg | |
# im_det1.jpg ... | |
# | |
# Example use-case | |
# ---------------- | |
# The file 'image01.jpg' may depict an image on which we run a face detector. | |
# Each detected face in 'image01.jpg' is then cropped out and saved as | |
# image01/im_det0.jpg, image01/im_det1.jpg, ... and so on. | |
# | |
# The generated HTML page will show the original image and the detected crops | |
# underneathe, put a horizontal-rule and then move on to the next image+crops set. | |
# >>>>>> Set paths here <<<<<< | |
EXPT_DIR=WIDER-shift-factor-0.20-heatmap-errimg | |
DATA_PATH=./output/${EXPT_DIR} | |
HTML_PATH=./output/${EXPT_DIR}.html | |
touch ${HTML_PATH} | |
rm -rf ${HTML_PATH} | |
touch ${HTML_PATH} | |
echo '<html>' >> ${HTML_PATH} | |
echo '<head>' >> ${HTML_PATH} | |
echo '<title>'${EXPT_DIR}'</title>' >> ${HTML_PATH} | |
echo '</head>' >> ${HTML_PATH} | |
echo '<body>' >> ${HTML_PATH} | |
for folder in `ls ${DATA_PATH}`; do | |
if [[ -d ${DATA_PATH}/${folder} ]]; then | |
echo "$folder" | |
# show the original image | |
echo "<img src='"${EXPT_DIR}"/"${folder}".jpg'></br>" >> ${HTML_PATH} | |
for imfile in `ls ${DATA_PATH}/${folder}`; do | |
# show the crops from original image underneathe | |
echo "<img src='"${EXPT_DIR}"/"${folder}"/"${imfile}"'height=150> " >> ${HTML_PATH} | |
done | |
echo "</br><hr></br>" >> ${HTML_PATH} | |
fi | |
done | |
echo '</body>' >> ${HTML_PATH} | |
echo '</html>' >> ${HTML_PATH} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment