forked from tonybeltramelli/pix2code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpix2code
More file actions
executable file
·64 lines (55 loc) · 1.41 KB
/
Copy pathpix2code
File metadata and controls
executable file
·64 lines (55 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# www.tonybeltramelli.com
# Handle arguments
if [ $# -eq 0 ]
then
echo "Error: no arguments supplied"
echo "Usage:"
echo " -i|--input <input image path>"
echo " -t|--target <target platform (ios|android|web)>"
exit 1
elif [ $# -ne 0 ]
then
for i in "$@"
do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $2 | sed 's/^[^=]*=//g'`
case $PARAM in
-i|--input)
INPUT=$VALUE
;;
-t|--target)
TARGET=$VALUE
;;
esac
shift
done
fi
echo "Input image: $INPUT"
echo "Target platform: $TARGET"
base_path=${INPUT%/*}
base_name=${INPUT##*/}
file_name=${base_name%.*}
rm -rf ../bin/pix2code.h5
rm -rf ../bin/pix2code.json
rm -rf ../bin/meta_dataset.npy
rm -rf ../bin/words.vocab
cp ../results/${TARGET}_results/pix2code.h5 ../bin/
cp ../results/${TARGET}_results/pix2code.json ../bin/
cp ../results/${TARGET}_results/meta_dataset.npy ../bin/
cp ../results/${TARGET}_results/words.vocab ../bin/
echo "Generating code with pre-trained model..."
./sample.py $base_path $base_path $file_name &>/dev/null
echo "Compiling output for target platform..."
cd ../compiler
if [ "$TARGET" == "ios" ]
then
./ios-compiler.py $base_path/ $file_name
elif [ "$TARGET" == "android" ]
then
./android-compiler.py $base_path/ $file_name
elif [ "$TARGET" == "web" ]
then
./web-compiler.py $base_path/ $file_name
fi
echo "Code generated successfully"