Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/test_python_folder_classify.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tensorpy import image_base

classifications = image_base.classify_folder_images('./images')
print("*** Displaying Image Classification Results: ***")
print("*** Displaying Image Classification Results as list: ***")
for classification in classifications:
print classification
5 changes: 5 additions & 0 deletions examples/test_python_folder_classify_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from tensorpy import image_base

dictionary = image_base.classify_folder_images('./images', return_dict=True)
print("*** Displaying Image Classification Results as dictionary: ***")
print dictionary
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='tensorpy',
version='1.0.15',
version='1.0.16',
url='http://tensorpy.com',
author='Michael Mintz',
author_email='@mintzworld',
Expand Down
14 changes: 9 additions & 5 deletions tensorpy/image_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def classify_local_image(file_path):
return best_guess


def classify_folder_images(folder_path):
classified_images = []
def classify_folder_images(folder_path, return_dict=False):
classified_images_list = []
classified_images_dict = {}
files = [f for f in listdir(folder_path) if isfile(join(folder_path, f))]
images = [f for f in files if (f.endswith('.jpg') or f.endswith('.png'))]
total = len(images)
Expand All @@ -128,10 +129,13 @@ def classify_folder_images(folder_path):
counter += 1
sys.stdout.write("\rClassifying Image %d of %s..." % (counter, total))
sys.stdout.flush()
classified_images.append(
classify_local_image(os.path.join(folder_path, image)))
result = classify_local_image(os.path.join(folder_path, image))
classified_images_list.append(result)
classified_images_dict[image] = result
sys.stdout.write("\rAll classifications have been completed!\n")
return classified_images
if return_dict:
return classified_images_dict
return classified_images_list


def classify(image_url):
Expand Down