ccd97 / image-classify-server Goto Github PK
View Code? Open in Web Editor NEWImage classification using Tensorflow (Inception v3)
Home Page: http://tf-classify.herokuapp.com
Image classification using Tensorflow (Inception v3)
Home Page: http://tf-classify.herokuapp.com
Hi, I must say thank you for sharing the project but i've encountered some issues.
The original graph.pb and labels.txt works, but not my models(graph+labels).
Do you have a specific way to train your models ?
This is how I train my models:
https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#3
I have cloned this repo & setup django project. But when I upload a image & click detect button, it didn't show any detected class. Please help.
Hi I am getting these errors, when I upload the image it says loading and stops, the error in the command line is given below
`Improper call to JPEG library in state 203
Internal Server Error: /classify_image/classify_api/
Traceback (most recent call last):
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 51, in classify_api
classify_result = tf_classify(tmp_f, int(request.POST.get('k', MAX_K)))
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 72, in tf_classify
predictions = SESS.run(GRAPH_TENSOR, {'DecodeJpeg/contents:0': image_data})
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
InvalidArgumentError: Invalid JPEG data, size 20480
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Caused by op u'DecodeJpeg', defined at:
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/neutrino/image-classify-server/tf_inception/urls.py", line 17, in <module>
from classify_image.views import classify, classify_api
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 31, in <module>
SESS, GRAPH_TENSOR, LABELS = load_graph()
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 25, in load_graph
_ = tf.import_graph_def(graph_def, name='')
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 288, in import_graph_def
op_def=op_def)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/Users/neutrino/image-classify-server/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): Invalid JPEG data, size 20480
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]`
As you told previously I tried with 3.6 but getting the following error and I am using .jpg format only
`Not a JPEG file: starts with 0x89 0x50
Internal Server Error: /classify_image/classify_api/
Traceback (most recent call last):
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1022, in _do_call
return fn(*args)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1004, in _run_fn
status, run_metadata)
File "/Users/neutrino/anaconda/lib/python3.6/contextlib.py", line 89, in __exit__
next(self.gen)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid JPEG data, size 97175
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 51, in classify_api
classify_result = tf_classify(tmp_f, int(request.POST.get('k', MAX_K)))
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 72, in tf_classify
predictions = SESS.run(GRAPH_TENSOR, {'DecodeJpeg/contents:0': image_data})
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid JPEG data, size 97175
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Caused by op 'DecodeJpeg', defined at:
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/neutrino/anaconda/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/neutrino/image-classify-server/tf_inception/urls.py", line 17, in <module>
from classify_image.views import classify, classify_api
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 31, in <module>
SESS, GRAPH_TENSOR, LABELS = load_graph()
File "/Users/neutrino/image-classify-server/classify_image/views.py", line 25, in load_graph
_ = tf.import_graph_def(graph_def, name='')
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 287, in import_graph_def
op_def=op_def)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2395, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/Users/neutrino/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1264, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): Invalid JPEG data, size 97175
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]`
D:\Cat_and_Dog_Classifier_Site_UI>python manage.py runserver
Performing system checks...
2018-10-04 00:39:14.188819: W tensorflow/core/framework/op_def_util.cc:355] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().
Unhandled exception in thread started by <function check_errors..wrapper at 0x00000229B58756A8>
Traceback (most recent call last):
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 366, in run_checks
return checks.run_checks(**kwargs)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\urls\resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\functional.py", line 37, in get
res = instance.dict[self.name] = self.func(instance)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\functional.py", line 37, in get
res = instance.dict[self.name] = self.func(instance)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\importlib_init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "D:\Cat_and_Dog_Classifier_Site_UI\tf_inception\urls.py", line 19, in
from classify_image.views import classify, classify_api
File "D:\Cat_and_Dog_Classifier_Site_UI\classify_image\views.py", line 31, in
SESS, GRAPH_TENSOR, LABELS = load_graph()
File "D:\Cat_and_Dog_Classifier_Site_UI\classify_image\views.py", line 27, in load_graph
softmax_tensor = sess.graph.get_tensor_by_name('softmax:0')
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3664, in get_tensor_by_name
return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3488, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "C:\Users\Ketan Ingale\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3530, in _as_graph_element_locked
"graph." % (repr(name), repr(op_name)))
KeyError: "The name 'softmax:0' refers to a Tensor which does not exist. The operation, 'softmax', does not exist in the graph."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.