From 85a55fc8efa6e6cc35713f34da99826bdad95726 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Wed, 15 Jul 2015 22:09:45 -0600 Subject: [PATCH 1/3] Fix bash script handling of filenames with spaces; Allow nested dirs within inputs/ --- deepdream/process_images_once.sh | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/deepdream/process_images_once.sh b/deepdream/process_images_once.sh index 29d5724..37ff16a 100755 --- a/deepdream/process_images_once.sh +++ b/deepdream/process_images_once.sh @@ -4,23 +4,23 @@ # Copyright vision.ai, 2015 cd /opt/deepdream/inputs -find . -type f -not -path '*/\.*' -print0 | while read -d $'\0' f; -do - cd /opt/deepdream - if [ -e outputs/${f} ]; - then - echo "File ${f} already processed" +find . -type f -not -path '*/\.*' -print0 | while read -d $'\0' f; do + if [[ "$(basename $(pwd))" == *'inputs'* ]]; then + cd /opt/deepdream + fi + if [ -e "outputs/${f}" ]; then + echo "File ${f} already processed" else - echo "Deepdream" ${f} - chmod gou+r inputs/${f} - cp inputs/${f} input.jpg - python deepdream.py - ERROR_CODE=$? - echo "Error Code is" ${ERROR_CODE} - cp output.jpg outputs/${f} - rm output.jpg - echo "Just created" outputs/${f} + echo "Deepdream ${f}" + chmod gou+r "inputs/${f}" + cp "inputs/${f}" input.jpg + python deepdream.py + ERROR_CODE=$? + echo -e "Error Code is: ${ERROR_CODE}\n\n" + dirname_f="$(dirname "$f")" + [[ -d "inputs/$dirname_f" && "$dirname_f" != '.' && "$dirname_f" != *'/deepdream/'* && ! -d "outputs/$dirname_f" ]] && mkdir -p "outputs/${dirname_f}" + cp output.jpg "outputs/${f}" + rm output.jpg + echo "Just created outputs/${f}" fi done - - From 11bfc254a6f5a6c03fcc743ce48b5ab066d006c0 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Wed, 15 Jul 2015 22:21:13 -0600 Subject: [PATCH 2/3] Fix handling of filenames with spaces in make_json.sh --- deepdream/make_json.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepdream/make_json.sh b/deepdream/make_json.sh index 0a3011c..3d25fa7 100755 --- a/deepdream/make_json.sh +++ b/deepdream/make_json.sh @@ -25,7 +25,7 @@ counter=1 find . -type f -not -path '*/\.*' -print0 | while read -d $'\0' f; do id=$counter - name=`basename $f` + name="$( basename "$f" )" src="/outputs/$name" echo -n "{\"id\":\"$id\",\"name\":\"$name\",\"src\":\"$src\"}" >> ../temp.json if [ "$id" != "$nfiles" ]; then From fad8c5d7f1c7fc64750126447109cca4ae6386a2 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Wed, 15 Jul 2015 23:17:18 -0600 Subject: [PATCH 3/3] Fix output src path to support nested subdirs --- deepdream/make_json.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepdream/make_json.sh b/deepdream/make_json.sh index 3d25fa7..c5fee78 100755 --- a/deepdream/make_json.sh +++ b/deepdream/make_json.sh @@ -26,7 +26,7 @@ find . -type f -not -path '*/\.*' -print0 | while read -d $'\0' f; do id=$counter name="$( basename "$f" )" - src="/outputs/$name" + src="/outputs/$f" echo -n "{\"id\":\"$id\",\"name\":\"$name\",\"src\":\"$src\"}" >> ../temp.json if [ "$id" != "$nfiles" ]; then echo -n "," >> ../temp.json