File size: 2,973 Bytes
664a799
 
 
9d4d402
 
 
 
664a799
 
 
821ff03
c18b721
13ce165
 
4f5d096
dad539d
821ff03
845b45b
664a799
 
70ff97b
664a799
 
 
 
 
c18b721
9d4d402
a15eba1
1d43aaa
664a799
3b27ab8
 
664a799
 
 
c18b721
13ce165
63b0414
7e85b83
 
 
56a7129
 
7e85b83
ae2fd3d
 
 
 
c04bc49
ae2fd3d
 
345b7e5
ae2fd3d
cd2efd1
63b0414
13ce165
b0d3cf4
4764e60
56a7129
7e85b83
b0d3cf4
e07d126
 
74c31ba
c18b721
 
facd347
958fcc3
 
 
 
720d5d2
 
 
c18b721
0c76ba3
 
845b45b
 
 
0c76ba3
c18b721
0c76ba3
 
4db8a80
 
0c76ba3
c18b721
a16d797
845b45b
 
0c76ba3
3b27ab8
c18b721
 
 
664a799
 
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /usr/bin/env bash

function fashion_mnist() {
    abcli_fashion_mnist $@
}

function abcli_fashion_mnist() {
    local task=$(abcli_unpack_keyword $1 help)

    if [ $task == "help" ] ; then
        abcli_help_line "$abcli_cli_name fashion_mnist ingest" \
            "ingest fashion_mnist data."
        abcli_help_line "$abcli_cli_name fashion_mnist predict data_1 [name_1] [data=filename/*object/url,model=object/*saved]" \
            "run fashion_mnist saved/object model name_1 predict on filename/object/url data_1."
        abcli_help_line "$abcli_cli_name fashion_mnist save [name_1] [object_1] [force]" \
            "[force] save fashion_mnist [in object_1] [as name_1]."
        abcli_help_line "$abcli_cli_name fashion_mnist train [validate]" \
            "train fashion_mnist [for validation]."

        if [ "$(abcli_keyword_is $2 verbose)" == true ] ; then
            python3 -m image_classifier.fashion_mnist --help
        fi

        return
    fi

    if [ "$task" == "ingest" ] ; then
        python3 -m image_classifier.fashion_mnist \
            ingest \
            --output_path $abcli_object_path \
            ${@:2}

        abcli_tag set . fashion_mnist
        return
    fi

    if [ "$task" == "predict" ] ; then
        local data_object=$(abcli_clarify_object "$2" $abcli_object_name)

        local model_name=$(abcli_clarify_arg "$3" fashion-mnist)

        local options=$4
        local data_source=$(abcli_option "$options" "data" object)

        if [ "$(abcli_keyword_is $data_object validate)" == true ] && [ "$data_source" == "object" ] ; then
            local output_object=$abcli_object_name

            abcli_select - ~trail
            abcli_fashion_mnist ingest
            local data_object=$abcli_object_name

            abcli_select $output_object ~trail
        fi

        abcli_log "fashion_mnist($model_name).predict($data_object): $options"

        abcli_image_classifier predict \
            $data_object \
            $model_name \
            $options \
            ${@:5}

        abcli_tag set . fashion_mnist

        return
    fi

    if [ "$task" == "save" ] ; then
        abcli_huggingface save \
            image-classifier \
            $(abcli_clarify_arg "$2" fashion-mnist) \
            ${@:3}
        return
    fi

    if [ "$task" == "train" ] ; then
        local model_object=$abcli_object_name

        local options=$2
        local do_validate=$(abcli_option_get_unpacked "$options" "validate" 0)

        abcli_select - ~trail
        abcli_fashion_mnist ingest
        local data_object=$abcli_object_name

        abcli_log "fashion_mnist.train($data_object): $options"

        abcli_select $model_object ~trail
        abcli_image_classifier_train \
            $data_object \
            ~color,~convnet,validate=$do_validate \
            ${@:3}

        abcli_tag set . fashion_mnist
        return
    fi

    abcli_log_error "-fashion_mnist: $task: command not found."
}