kamangir
commited on
Commit
•
6e72b38
1
Parent(s):
6801348
validating fashion_mnist train - kamangir/bolt#692
Browse files- image_classifier/classes.py +18 -12
image_classifier/classes.py
CHANGED
@@ -11,6 +11,7 @@ import matplotlib.pyplot as plt
|
|
11 |
import tensorflow as tf
|
12 |
from tqdm import *
|
13 |
import time
|
|
|
14 |
import abcli.logging
|
15 |
import logging
|
16 |
|
@@ -36,7 +37,9 @@ class Image_Classifier(object):
|
|
36 |
if not success:
|
37 |
return False
|
38 |
|
39 |
-
success, self.params = file.load_json(
|
|
|
|
|
40 |
if not success:
|
41 |
return False
|
42 |
|
@@ -247,29 +250,32 @@ class Image_Classifier(object):
|
|
247 |
file.save_image(output_filename, image)
|
248 |
|
249 |
def save(self, model_path):
|
250 |
-
model_filename = "{}/image_classifier/model"
|
251 |
-
|
|
|
|
|
|
|
252 |
try:
|
253 |
self.model.save(model_filename)
|
254 |
-
logger.info("image_classifier.model -> {}"
|
255 |
except:
|
256 |
-
|
257 |
-
|
258 |
-
crash_report("image_classifier.save({}) failed".format(model_path))
|
259 |
return False
|
260 |
|
261 |
self.params["object_name"] = path.name(model_path)
|
262 |
|
263 |
-
self.params["model_size"] = file.size(
|
264 |
-
"{}/image_classifier/model".format(model_path)
|
265 |
-
)
|
266 |
|
267 |
if not file.save_json(
|
268 |
-
"{}/class_names.json"
|
|
|
269 |
):
|
270 |
return False
|
271 |
|
272 |
-
if not file.save_json(
|
|
|
|
|
|
|
273 |
return False
|
274 |
|
275 |
return True
|
|
|
11 |
import tensorflow as tf
|
12 |
from tqdm import *
|
13 |
import time
|
14 |
+
from abcli.logging import crash_report
|
15 |
import abcli.logging
|
16 |
import logging
|
17 |
|
|
|
37 |
if not success:
|
38 |
return False
|
39 |
|
40 |
+
success, self.params = file.load_json(
|
41 |
+
f"{model_path}/image_classifier/model/params.json"
|
42 |
+
)
|
43 |
if not success:
|
44 |
return False
|
45 |
|
|
|
250 |
file.save_image(output_filename, image)
|
251 |
|
252 |
def save(self, model_path):
|
253 |
+
model_filename = f"{model_path}/image_classifier/model"
|
254 |
+
|
255 |
+
if not file.prepare_for_saving(model_filename):
|
256 |
+
return False
|
257 |
+
|
258 |
try:
|
259 |
self.model.save(model_filename)
|
260 |
+
logger.info(f"image_classifier.model -> {model_filename}")
|
261 |
except:
|
262 |
+
crash_report(f"-image_classifier: save({model_path}): failed.")
|
|
|
|
|
263 |
return False
|
264 |
|
265 |
self.params["object_name"] = path.name(model_path)
|
266 |
|
267 |
+
self.params["model_size"] = file.size(f"{model_path}/image_classifier/model")
|
|
|
|
|
268 |
|
269 |
if not file.save_json(
|
270 |
+
f"{model_path}/class_names.json",
|
271 |
+
self.class_names,
|
272 |
):
|
273 |
return False
|
274 |
|
275 |
+
if not file.save_json(
|
276 |
+
f"{model_path}/image_classifier/model/params.json",
|
277 |
+
self.params,
|
278 |
+
):
|
279 |
return False
|
280 |
|
281 |
return True
|