kamangir commited on
Commit
13ce165
1 Parent(s): dad539d

validating single image predict for fashion_mnist - kamangir/bolt#692

Browse files
abcli/fashion_mnist.sh CHANGED
@@ -10,8 +10,8 @@ function abcli_fashion_mnist() {
10
  if [ $task == "help" ] ; then
11
  abcli_help_line "$abcli_cli_name fashion_mnist ingest" \
12
  "ingest fashion_mnist data."
13
- abcli_help_line "$abcli_cli_name fashion_mnist predict object_1 [name_1] [object]" \
14
- "run fashion_mnist saved/object model name_1 predict on object_1."
15
  abcli_help_line "$abcli_cli_name fashion_mnist save [name_1] [object_1] [force]" \
16
  "[force] save fashion_mnist [in object_1] [as name_1]."
17
  abcli_help_line "$abcli_cli_name fashion_mnist train [validate]" \
@@ -35,8 +35,12 @@ function abcli_fashion_mnist() {
35
  fi
36
 
37
  if [ "$task" == "predict" ] ; then
38
- local data_object=$(abcli_clarify_object "$2" $abcli_object_name)
 
 
 
39
 
 
40
  if [ "$(abcli_keyword_is $data_object validate)" == true ] ; then
41
  local output_object=$abcli_object_name
42
 
@@ -47,8 +51,7 @@ function abcli_fashion_mnist() {
47
  abcli_select $output_object ~trail
48
  fi
49
 
50
- abcli_huggingface predict \
51
- image-classifier \
52
  $data_object \
53
  $(abcli_clarify_arg "$3" fashion-mnist) \
54
  ${@:4}
 
10
  if [ $task == "help" ] ; then
11
  abcli_help_line "$abcli_cli_name fashion_mnist ingest" \
12
  "ingest fashion_mnist data."
13
+ abcli_help_line "$abcli_cli_name fashion_mnist predict data_1 [name_1] [data=filename/*object/url,model=object/*saved]" \
14
+ "run fashion_mnist saved/object model name_1 predict on filename/object/url data_1."
15
  abcli_help_line "$abcli_cli_name fashion_mnist save [name_1] [object_1] [force]" \
16
  "[force] save fashion_mnist [in object_1] [as name_1]."
17
  abcli_help_line "$abcli_cli_name fashion_mnist train [validate]" \
 
35
  fi
36
 
37
  if [ "$task" == "predict" ] ; then
38
+ # Args
39
+ # $2: data_1: data for prediction
40
+ # $3: name_1: model name
41
+ # $4: options: data=filename/*object/url,model=object/*saved
42
 
43
+ local data_object=$(abcli_clarify_object "$2" $abcli_object_name)
44
  if [ "$(abcli_keyword_is $data_object validate)" == true ] ; then
45
  local output_object=$abcli_object_name
46
 
 
51
  abcli_select $output_object ~trail
52
  fi
53
 
54
+ abcli_image_classifier predict \
 
55
  $data_object \
56
  $(abcli_clarify_arg "$3" fashion-mnist) \
57
  ${@:4}
abcli/image_classifier.sh CHANGED
@@ -12,8 +12,8 @@ function abcli_image_classifier() {
12
  "describe model object_1."
13
  abcli_help_line "$abcli_cli_name image_classifier install" \
14
  "install image_classifier."
15
- abcli_help_line "$abcli_cli_name image_classifier predict object_1 [name_1] [object]" \
16
- "run image_classifier saved/object model name_1 predict on object_1."
17
  abcli_help_line "$abcli_cli_name image_classifier save [name_1] [object_1] [force]" \
18
  "[force] save image_classifier [in object_1] [as name_1]."
19
  abcli_help_line "$abcli_cli_name image_classifier train object_1" \
@@ -48,15 +48,6 @@ function abcli_image_classifier() {
48
  return
49
  fi
50
 
51
- if [ "$task" == "predict" ] ; then
52
- abcli_huggingface predict \
53
- image-classifier \
54
- $2 \
55
- $(abcli_clarify_arg "$3" image-classifier) \
56
- ${@:4}
57
- return
58
- fi
59
-
60
  if [ "$task" == "save" ] ; then
61
  abcli_huggingface save \
62
  image-classifier \
@@ -69,36 +60,48 @@ function abcli_image_classifier() {
69
  }
70
 
71
  function abcli_image_classifier_predict() {
72
- local model_object=$(abcli_clarify_object "$1")
73
- local data_object=$(abcli_clarify_object "$2")
 
 
 
 
 
 
 
 
 
74
 
75
- abcli_download object $model_object
76
  abcli_download object $data_object
 
 
 
 
77
 
78
- abcli_log "image_classifier($model_object).predict($data_object)"
79
 
80
  if [ ! -f "$abcli_object_root/$data_object/test_images.pyndarray" ] ; then
81
  python3 -m image_classifier \
82
  preprocess \
83
  --infer_annotation 0 \
84
- --model_path $abcli_object_root/$model_object \
85
  --objects $abcli_object_root/$data_object \
86
  --output_path $abcli_object_root/$data_object \
87
  --purpose predict \
88
  ${@:3}
89
  fi
90
 
91
- cp -v ../$data_object/*.pyndarray .
92
- cp -v ../$model_object/image_classifier/model/class_names.json .
93
 
94
  python3 -m image_classifier \
95
  predict \
96
  --data_path $abcli_object_root/$data_object \
97
- --model_path $abcli_object_root/$model_object \
98
  --output_path $abcli_object_path \
99
  ${@:4}
100
 
101
- abcli_tag set . image_classifier,predict
102
  }
103
 
104
  function abcli_image_classifier_train() {
 
12
  "describe model object_1."
13
  abcli_help_line "$abcli_cli_name image_classifier install" \
14
  "install image_classifier."
15
+ abcli_help_line "$abcli_cli_name image_classifier predict data_1 [name_1] [data=filename/*object/url,model=object/*saved]" \
16
+ "run fashion_mnist saved/object model name_1 predict on filename/object/url data_1."
17
  abcli_help_line "$abcli_cli_name image_classifier save [name_1] [object_1] [force]" \
18
  "[force] save image_classifier [in object_1] [as name_1]."
19
  abcli_help_line "$abcli_cli_name image_classifier train object_1" \
 
48
  return
49
  fi
50
 
 
 
 
 
 
 
 
 
 
51
  if [ "$task" == "save" ] ; then
52
  abcli_huggingface save \
53
  image-classifier \
 
60
  }
61
 
62
  function abcli_image_classifier_predict() {
63
+ # Args
64
+ # $1: data_1: data for prediction
65
+ # $2: name_1: model name
66
+ # $3: options: data=filename/*object/url,model=object/*saved
67
+
68
+ local data_object=$(abcli_clarify_object "$1")
69
+
70
+ local model_path=$(abcli_huggingface get_model_path image-classifier "$2" "$3")
71
+
72
+ local options=$3
73
+ local model_source=$(abcli_option "$options" "model" saved)
74
 
 
75
  abcli_download object $data_object
76
+ if [ "$model_source" == "object" ] ; then
77
+ local model_object=TBD
78
+ abcli_download object $model_object
79
+ fi
80
 
81
+ abcli_log "image_classifier($model_path).predict($data_object)"
82
 
83
  if [ ! -f "$abcli_object_root/$data_object/test_images.pyndarray" ] ; then
84
  python3 -m image_classifier \
85
  preprocess \
86
  --infer_annotation 0 \
87
+ --model_path $model_path \
88
  --objects $abcli_object_root/$data_object \
89
  --output_path $abcli_object_root/$data_object \
90
  --purpose predict \
91
  ${@:3}
92
  fi
93
 
94
+ cp -v $abcli_object_root/$data_object/*.pyndarray .
95
+ cp -v $model_path/image_classifier/model/class_names.json .
96
 
97
  python3 -m image_classifier \
98
  predict \
99
  --data_path $abcli_object_root/$data_object \
100
+ --model_path $model_path \
101
  --output_path $abcli_object_path \
102
  ${@:4}
103
 
104
+ abcli_tag set . image_classifier,predict
105
  }
106
 
107
  function abcli_image_classifier_train() {
image_classifier/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
  name = "image_classifier"
2
 
3
- version = "1.1.131"
4
 
5
  description = "fashion-mnist + hugging-face + awesome-bash-cli"
 
1
  name = "image_classifier"
2
 
3
+ version = "1.1.134"
4
 
5
  description = "fashion-mnist + hugging-face + awesome-bash-cli"