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 requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
six
tensorflow>=1.14.0
requests>=2.22.0
Pillow>=6.0.0
Pillow>=6.1.0
BeautifulSoup4>=4.6.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='tensorpy',
version='1.4.0',
version='1.4.1',
description='Easy Image Classification with TensorFlow!',
long_description=long_description,
long_description_content_type='text/markdown',
Expand All @@ -32,7 +32,7 @@
'six',
'tensorflow>=1.14.0',
'requests>=2.22.0',
'Pillow>=6.0.0',
'Pillow>=6.1.0',
'BeautifulSoup4>=4.6.0',
],
packages=['tensorpy'],
Expand Down
6 changes: 3 additions & 3 deletions tensorpy/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def main():
break

if images_classified >= settings.MAX_IMAGES_PER_PAGE:
print("\n(NOTE: Exceeded page classification limit "
"of %d images per URL! Stopping early.)" % (
settings.MAX_IMAGES_PER_PAGE))
print("\n(NOTE: Exceeded page classification limit "
"of %d images per URL! Stopping early.)" % (
settings.MAX_IMAGES_PER_PAGE))

if images_classified == 0:
print("\nCould not find images to classify on the page! "
Expand Down
14 changes: 8 additions & 6 deletions tensorpy/image_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@


def get_image_file_dimensions(file_name):
image = Image.open(file_name)
image_dimensions = image.size # (width, height) tuple
return image_dimensions
with Image.open(file_name) as image:
image_dimensions = image.size # (width, height) tuple
return image_dimensions


def convert_image_file_to_jpg(file_name):
Expand All @@ -26,15 +26,17 @@ def convert_image_file_to_jpg(file_name):
outfile = f + ".jpg"
if infile != outfile:
try:
Image.open(infile).convert('RGB').save(outfile, "JPEG")
with Image.open(infile) as image:
image.convert('RGB').save(outfile, "JPEG")
except IOError:
raise Exception("Cannot convert %s to jpg!" % file_name)


def load_image_from_url(image_url):
response = requests.get(image_url)
image = Image.open(StringIO(response.content)).convert('RGB')
return image
with Image.open(StringIO(response.content)) as image:
image.convert('RGB')
return image


def get_image_dimensions(image):
Expand Down