kamangir
commited on
Commit
•
1d43aaa
1
Parent(s):
a15eba1
validating ingest - kamangir/bolt#689
Browse files- abcli/fashion_mnist.sh +1 -1
- fashion_mnist/__init__.py +1 -1
- fashion_mnist/__main__.py +9 -3
- fashion_mnist/ingest.py +57 -0
abcli/fashion_mnist.sh
CHANGED
@@ -21,7 +21,7 @@ function fashion_mnist() {
|
|
21 |
if [ "$task" == "ingest" ] ; then
|
22 |
python3 -m fashion_mnist \
|
23 |
ingest \
|
24 |
-
--
|
25 |
${@:2}
|
26 |
return
|
27 |
fi
|
|
|
21 |
if [ "$task" == "ingest" ] ; then
|
22 |
python3 -m fashion_mnist \
|
23 |
ingest \
|
24 |
+
--output_path $abcli_object_path \
|
25 |
${@:2}
|
26 |
return
|
27 |
fi
|
fashion_mnist/__init__.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
name = "fashion_mnist"
|
2 |
|
3 |
-
version = "1.1.
|
4 |
|
5 |
description = "fashion-mnist + hugging-face + awesome-bash-cli"
|
|
|
1 |
name = "fashion_mnist"
|
2 |
|
3 |
+
version = "1.1.33"
|
4 |
|
5 |
description = "fashion-mnist + hugging-face + awesome-bash-cli"
|
fashion_mnist/__main__.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import argparse
|
2 |
from . import *
|
|
|
3 |
from abcli import logging
|
4 |
import logging
|
5 |
|
@@ -9,13 +10,18 @@ parser = argparse.ArgumentParser(name, description=f"{name}-{version}")
|
|
9 |
parser.add_argument(
|
10 |
"task",
|
11 |
type=str,
|
12 |
-
help="
|
|
|
|
|
|
|
|
|
|
|
13 |
)
|
14 |
args = parser.parse_args()
|
15 |
|
16 |
success = False
|
17 |
-
if args.task == "
|
18 |
-
success =
|
19 |
else:
|
20 |
logger.error(f"-{name}: {args.task}: command not found.")
|
21 |
|
|
|
1 |
import argparse
|
2 |
from . import *
|
3 |
+
from .ingest import *
|
4 |
from abcli import logging
|
5 |
import logging
|
6 |
|
|
|
10 |
parser.add_argument(
|
11 |
"task",
|
12 |
type=str,
|
13 |
+
help="ingest",
|
14 |
+
)
|
15 |
+
parser.add_argument(
|
16 |
+
"--output_path",
|
17 |
+
type=str,
|
18 |
+
default="",
|
19 |
)
|
20 |
args = parser.parse_args()
|
21 |
|
22 |
success = False
|
23 |
+
if args.task == "ingest":
|
24 |
+
success = ingest(args.output_path)
|
25 |
else:
|
26 |
logger.error(f"-{name}: {args.task}: command not found.")
|
27 |
|
fashion_mnist/ingest.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from abcli import file
|
2 |
+
from abcli import string
|
3 |
+
from abcli.logging import crash_report
|
4 |
+
import os.path
|
5 |
+
from abcli import logging
|
6 |
+
import tensorflow as tf
|
7 |
+
import logging
|
8 |
+
|
9 |
+
logger = logging.getLogger(__name__)
|
10 |
+
|
11 |
+
|
12 |
+
def ingest(output_path):
|
13 |
+
import tensorflow as tf
|
14 |
+
|
15 |
+
try:
|
16 |
+
fashion_mnist = tf.keras.datasets.fashion_mnist
|
17 |
+
|
18 |
+
(train_images, train_labels), (
|
19 |
+
test_images,
|
20 |
+
test_labels,
|
21 |
+
) = fashion_mnist.load_data()
|
22 |
+
except:
|
23 |
+
crash_report("-fashion_mnist: ingest.")
|
24 |
+
return False
|
25 |
+
|
26 |
+
logger.info("ingesting fashion_mnist")
|
27 |
+
|
28 |
+
success = True
|
29 |
+
for name, thing in zip(
|
30 |
+
"train_images,train_labels,test_images,test_labels".split(","),
|
31 |
+
[train_images, train_labels, test_images, test_labels],
|
32 |
+
):
|
33 |
+
if file.save(os.path.join(output_path, name), thing):
|
34 |
+
logger.info(f"ingested {name}: {string.pretty_size_of_matrix(thing)}")
|
35 |
+
else:
|
36 |
+
success = False
|
37 |
+
|
38 |
+
class_names = [
|
39 |
+
"T-shirt/top",
|
40 |
+
"Trouser",
|
41 |
+
"Pullover",
|
42 |
+
"Dress",
|
43 |
+
"Coat",
|
44 |
+
"Sandal",
|
45 |
+
"Shirt",
|
46 |
+
"Sneaker",
|
47 |
+
"Bag",
|
48 |
+
"Ankle boot",
|
49 |
+
]
|
50 |
+
if file.save_json(os.path.join(output_path, "class_names"), class_names):
|
51 |
+
logger.info(
|
52 |
+
f"ingested {len(class_names)} class name(s): {', '.join(class_names)}"
|
53 |
+
)
|
54 |
+
else:
|
55 |
+
success = False
|
56 |
+
|
57 |
+
return success
|