Closed prashastk closed 5 years ago
I have added an extra test for Issue 1 and the it seems the server will correctly catch when the dimension of the blob mismatches. I was not able to reproduce Issue 1.
Can you provide more info?
This is the test I am using to try to replicate.
def test_addSetAndDescriptorsDimMismatch(self):
db = self.create_connection()
all_queries = []
# Add Set
set_name = "features_64d_dim_mismatched"
dims = 64
descriptor_set = {}
descriptor_set["name"] = set_name
descriptor_set["dimensions"] = dims
query = {}
query["AddDescriptorSet"] = descriptor_set
all_queries.append(query)
response, img_array = db.query(all_queries)
self.assertEqual(response[0]["AddDescriptorSet"]["status"], 0)
# Add Descriptors
all_queries = []
descriptor_blob = []
x = np.zeros(dims/2)
x = x.astype('float32')
# print type(x[0])
# print "size: ", len(x.tobytes())/4
descriptor_blob.append(x.tobytes())
descriptor = {}
descriptor["set"] = set_name
query = {}
query["AddDescriptor"] = descriptor
all_queries.append(query)
response, img_array = db.query(all_queries, [descriptor_blob])
print(db.get_last_response_str())
# Check correct error
self.assertEqual(response[0]["status"], -1)
self.assertEqual(response[0]["info"], "Blob Dimensions Mismatch")
Also, can you provide more detail on Issue 2? Does this happen after the AddDescriptor in Issue 1 is done?
Thanks!
This should produce Issue 1:
x = np.zeros(dims/2)
x = x.astype('float32').tobytes()
x = np.frombuffer(x.tobytes()).tobytes()
descriptor_blob.append(x)
(I'll try to re-produce it tomorrow and update this)
Issue 2 was happening after data with the Issue 1 was added into the server.
I tried that way as well, and get an error:
x = np.frombuffer(x.tobytes()).tobytes()
AttributeError: 'str' object has no attribute 'tobytes'
I was not able to reproduce this error, even with a couple of different wrong sizes.
I will add more testcases for this issues in #101 for the future, and close this issues unless/until we find a way to reproduce it.
Thanks!
Some bug in my code added descriptor blobs which had gone through the following transformations:
After this
blob
becomes a 32 dimnp.float
array.Issue 1 - AddDescriptor for a 64 dim set worked fine with this blob Issue 2 - A FindDescriptor query with k_neighbors crashes the server: Server log