kamangir commited on
Commit
183bd3e
1 Parent(s): 9d4d402

validating train - kamangir/bolt#689

Browse files
image_classifier/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
  name = "image_classifier"
2
 
3
- version = "1.1.43"
4
 
5
  description = "fashion-mnist + hugging-face + awesome-bash-cli"
 
1
  name = "image_classifier"
2
 
3
+ version = "1.1.44"
4
 
5
  description = "fashion-mnist + hugging-face + awesome-bash-cli"
image_classifier/__main__.py CHANGED
@@ -1,26 +1,8 @@
1
  import argparse
2
- import cv2
3
- from functools import reduce
4
- import matplotlib.pyplot as plt
5
- import numpy as np
6
- import os
7
- import os.path
8
- import tensorflow as tf
9
- from tqdm import *
10
- import re
11
- import time
12
  from . import *
13
- from abcli import objects
14
- from abcli import cache
15
  from abcli import file
16
- from abcli.tasks import host
17
- from abcli import graphics
18
- from abcli.options import Options
19
- from abcli import path
20
- from abcli.storage import instance as storage
21
- from abcli import string
22
- from abcli.plugins import tags
23
-
24
  import abcli.logging
25
  import logging
26
 
@@ -136,33 +118,18 @@ args = parser.parse_args()
136
 
137
  success = False
138
  if args.task == "describe":
139
- image_classifier().load(args.model_path)
140
  success = True
141
  elif args.task == "eval":
142
  success = eval(args.input_path, args.output_path)
143
- elif args.task == "ingest":
144
- success = ingest(
145
- args.include,
146
- args.output_path,
147
- {
148
- "count": args.count,
149
- "exclude": args.exclude,
150
- "negative": args.negative,
151
- "non_empty": args.non_empty,
152
- "positive": args.positive,
153
- "test_size": args.test_size,
154
- },
155
- )
156
  elif args.task == "predict":
157
- classifier = image_classifier()
158
 
159
  if classifier.load(args.model_path):
160
- success, test_images = file.load(
161
- "{}/test_images.pyndarray".format(args.data_path)
162
- )
163
 
164
  if success:
165
- logger.info("test_images: {}".format(string.pretty_size_of_matrix(test_images)))
166
 
167
  _, test_labels = file.load(
168
  "{}/test_labels.pyndarray".format(args.data_path),
@@ -172,23 +139,26 @@ elif args.task == "predict":
172
 
173
  test_images = test_images / 255.0
174
 
175
- success = classifier.predict(test_images, test_labels, args.output_path)
 
 
 
 
176
  elif args.task == "preprocess":
177
  success = preprocess(
178
  args.output_path,
179
- {
180
- "objects": args.objects,
181
- "infer_annotation": args.infer_annotation,
182
- "purpose": args.purpose,
183
- "window_size": args.window_size,
184
- },
185
  )
186
  elif args.task == "train":
187
- classifier = image_classifier()
188
- success = classifier.train(
189
  args.data_path,
190
  args.model_path,
191
- {"color": args.color, "convnet": args.convnet, "epochs": args.epochs},
 
 
192
  )
193
  else:
194
  logger.error(f"-{name}: {args.task}: command not found.")
 
1
  import argparse
 
 
 
 
 
 
 
 
 
 
2
  from . import *
3
+ from .classes import Image_Classifier
4
+ from .funcs import *
5
  from abcli import file
 
 
 
 
 
 
 
 
6
  import abcli.logging
7
  import logging
8
 
 
118
 
119
  success = False
120
  if args.task == "describe":
121
+ Image_Classifier().load(args.model_path)
122
  success = True
123
  elif args.task == "eval":
124
  success = eval(args.input_path, args.output_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  elif args.task == "predict":
126
+ classifier = Image_Classifier()
127
 
128
  if classifier.load(args.model_path):
129
+ success, test_images = file.load(f"{args.data_path}/test_images.pyndarray")
 
 
130
 
131
  if success:
132
+ logger.info(f"test_images: {string.pretty_size_of_matrix(test_images)}")
133
 
134
  _, test_labels = file.load(
135
  "{}/test_labels.pyndarray".format(args.data_path),
 
139
 
140
  test_images = test_images / 255.0
141
 
142
+ success = classifier.predict(
143
+ test_images,
144
+ test_labels,
145
+ args.output_path,
146
+ )
147
  elif args.task == "preprocess":
148
  success = preprocess(
149
  args.output_path,
150
+ objects=args.objects,
151
+ infer_annotation=args.infer_annotation,
152
+ purpose=args.purpose,
153
+ window_size=args.window_size,
 
 
154
  )
155
  elif args.task == "train":
156
+ success = Image_Classifier.train(
 
157
  args.data_path,
158
  args.model_path,
159
+ color=args.color,
160
+ convnet=args.convnet,
161
+ epochs=args.epochs,
162
  )
163
  else:
164
  logger.error(f"-{name}: {args.task}: command not found.")