vinayakarannil / deeplearning_image_similarity Goto Github PK
View Code? Open in Web Editor NEWDeep learning based image similarity search for product recommendations
Deep learning based image similarity search for product recommendations
jinja2.exceptions.TemplateNotFound
jinja2.exceptions.TemplateNotFound: main.html
WARNING:tensorflow:From C:\Users\prasad\Downloads\root\server\image_vectorizer.py:36: FastGFile.init (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
Traceback (most recent call last):
File "C:\Users\prasad\Downloads\root\server\image_vectorizer.py", line 110, in
image_data = gfile.FastGFile(filename, 'rb').read()
File "C:\python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 125, in read
self._preread_check()
File "C:\python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 85, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "C:\python36\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.UnknownError: NewRandomAccessFile failed to Create/Open: uploads/dogs_and_cats/Shoes/Crib Shoes : Access is denied.
; Input/output error
2021-05-20 13:50:13.429732: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-05-20 13:50:13.429868: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
loaded extracted_features
Hi Vinay,
can you suggest how to handle multiple request same time.
If more than one request we send only getting result for one request.
Error details:
FileExistsError: [WinError 183] Cannot create a file when that file already exist
Please suggest.
gettting image path error while runing rest-server.py
File "C:\Users\Muhammad Khalid\Desktop\Image Similarity\lib\search.py", line 103, in
image_data = gfile.GFile(image_path, 'rb').read()
NameError: name 'image_path' is not defined
################################################################################################################################
################################################################################################################################
import os
import random
import numpy as np
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import pickle
os._warn_preinit_stderr = 0
BOTTLENECK_TENSOR_NAME = 'pool_3/_reshape:0'
BOTTLENECK_TENSOR_SIZE = 2048
MODEL_INPUT_WIDTH = 299
MODEL_INPUT_HEIGHT = 299
MODEL_INPUT_DEPTH = 3
JPEG_DATA_TENSOR_NAME = 'DecodeJpeg/contents:0'
RESIZED_INPUT_TENSOR_NAME = 'ResizeBilinear:0'
MAX_NUM_IMAGES_PER_CLASS = 2 ** 27 - 1 # ~134M
def create_inception_graph():
""""Creates a graph from saved GraphDef file and returns a Graph object.
Returns:
Graph holding the trained Inception network, and various tensors we'll be
manipulating.
"""
with tf.compat.v1.Session() as sess:
model_filename = os.path.join(
'imagenet', 'classify_image_graph_def.pb')
with tf.gfile.FastGFile("imagenet/classify_image_graph_def.pb", 'rb') as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
bottleneck_tensor, jpeg_data_tensor, resized_input_tensor = (
tf.import_graph_def(graph_def, name='', return_elements=[
BOTTLENECK_TENSOR_NAME, JPEG_DATA_TENSOR_NAME,
RESIZED_INPUT_TENSOR_NAME]))
return sess.graph, bottleneck_tensor, jpeg_data_tensor, resized_input_tensor
def run_bottleneck_on_image(sess, image_data, image_data_tensor,
bottleneck_tensor):
bottleneck_values = sess.run(
bottleneck_tensor,
{image_data_tensor: image_data})
bottleneck_values = np.squeeze(bottleneck_values)
return bottleneck_values
boots_files = [
'uploads/dogs_and_cats/Boots/' + f
for
f
in
os.listdir('uploads/dogs_and_cats/Boots')
]
sandals_files = [
'uploads/dogs_and_cats/Sandals/' + f
for
f
in
os.listdir('uploads/dogs_and_cats/Sandals')
]
shoes_files = [
'uploads/dogs_and_cats/Shoes/' + f
for
f
in
os.listdir('uploads/dogs_and_cats/Shoes')
]
slippers_files = [
'uploads/dogs_and_cats/Slippers/' + f
for
f
in
os.listdir('uploads/dogs_and_cats/Slippers')
]
apparel_files = [
'uploads/dogs_and_cats/apparel/' + f
for
f
in
os.listdir('uploads/dogs_and_cats/apparel')
]
all_files = boots_files + shoes_files + slippers_files + sandals_files + apparel_files
random.shuffle(all_files)
num_images = 10000
neighbor_list = all_files[:num_images]
with open('neighbor_list_recom.pickle', 'wb') as f:
pickle.dump(neighbor_list, f)
print("saved neighbour list")
extracted_features = np.ndarray((num_images, 2048))
sess = tf.compat.v1.Session()
graph, bottleneck_tensor, jpeg_data_tensor, resized_image_tensor = (create_inception_graph())
for i, filename in enumerate(neighbor_list):
image_data = tf.io.gfile.GFile(filename, 'rb').read()
features = run_bottleneck_on_image(sess, image_data, jpeg_data_tensor, bottleneck_tensor)
extracted_features[i:i + 1] = features
if i % 250 == 0:
print(i)
np.savetxt("saved_features_recom.txt", extracted_features)
print("saved exttracted features")
"C:\Users\Muhammad Khalid\Anaconda3\python.exe" "C:/Users/Muhammad Khalid/Desktop/Recommendation systems using image similarity powered by deep learning/Deeplearning_Image_Similarity-master/server/image_vectorizer.py"
WARNING: Logging before flag parsing goes to stderr.
W0823 21:18:45.101209 20020 init.py:308] Limited tf.compat.v2.summary API due to missing TensorBoard installation.
saved neighbour list
W0823 21:18:45.223723 20020 deprecation.py:323] From C:/Users/Muhammad Khalid/Desktop/Recommendation systems using image similarity powered by deep learning/Deeplearning_Image_Similarity-master/server/image_vectorizer.py:39: FastGFile.init (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
Traceback (most recent call last):
File "C:/Users/Muhammad Khalid/Desktop/Recommendation systems using image similarity powered by deep learning/Deeplearning_Image_Similarity-master/server/image_vectorizer.py", line 113, in
image_data = tf.io.gfile.GFile(filename, 'rb').read()
File "C:\Users\Muhammad Khalid\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 122, in read
self._preread_check()
File "C:\Users\Muhammad Khalid\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 84, in _preread_check
compat.as_bytes(self.__name), 1024 * 512)
tensorflow.python.framework.errors_impl.UnknownError: NewRandomAccessFile failed to Create/Open: uploads/dogs_and_cats/Sandals/Athletic : Access is denied.
; Input/output error
Process finished with exit code 1
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.