This repository was archived by the owner on Sep 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 23
23
from PIL import Image
24
24
25
25
parser = argparse .ArgumentParser ()
26
- parser .add_argument ('--image ' , type = str , default = '' )
26
+ parser .add_argument ('--base64_image ' , type = str , default = '' )
27
27
args , _ = parser .parse_known_args ()
28
28
29
- im = args .image .replace ('_' , '/' ).replace ('-' , '+' )
29
+ im = args .base64_image .replace ('_' , '/' ).replace ('-' , '+' )
30
+
31
+ missing_base64_padding = len (im ) % 4
32
+ if missing_base64_padding != 0 :
33
+ im += ('=' * (4 - missing_base64_padding ))
30
34
31
35
img = Image .open (cStringIO .StringIO (im .decode ('base64' )))
32
36
img .show ()
Original file line number Diff line number Diff line change 57
57
58
58
JSON_OBJ=$( python create_random_embedding.py)
59
59
60
- echo -e " ${JSON_OBJ} > " ${TMP_FILE} "
60
+ echo -e " ${JSON_OBJ} " > " ${TMP_FILE} "
61
61
62
62
OUTPUT=$( gcloud ml-engine predict --model " ${MODEL_NAME} " --json-instances " ${TMP_FILE} " )
63
- IMAGE=$( echo " ${OUTPUT} " | cut -d' ' -f 4)
64
-
65
- python display_image.py --image " ${IMAGE} "
63
+ IMAGE=$( echo " ${OUTPUT} " | awk ' NR==2 {print $2}' )
64
+ python display_image.py --base64_image " ${IMAGE} "
You can’t perform that action at this time.
0 commit comments