pochih / CBIR

🏞 A content-based image retrieval (CBIR) system
614 stars 210 forks source link

How you get the this figure in Part3: image retrieval (return top 5 of each method)? #5

Open redhat12345 opened 6 years ago

redhat12345 commented 6 years ago

Hi,

Can you tell us that how you get this images?

ClaryK commented 6 years ago

I want to know it too...

pochih commented 6 years ago

Generally, when it comes to IR ranking with deep learning model, we use the outputs of the second last layer as input image's feature. Because the outputs of the last layer is for classification and has no matter with our task.

Compare the feature of query image and the feature of each image in the database. We can sorting all database images according to the similarity. Similarity can be counted with L2 distance or cosine similarity.

dgtlmoon commented 5 years ago

@pochih thanks for your work so far - so you're saying that this codebase merely generates a DB of various features/descriptors/etc, and that is does not having anything todo with retrieving content (images) given a query image?

Compare the feature of query image and the feature of each image in the database. We can sorting all database images according to the similarity. Similarity can be counted with L2 distance or cosine similarity.

This is actually a really inefficient way of dealing with this problem.

Can you explain exactly why you called this project "A content-based image retrieval (CBIR) system" ? because there is no retrieval going on here? or am I wrong?

KarthikDutt commented 4 years ago

@dgtlmoon - Its been a year but if you are still interested in this, then this response might be useful.

You can load the file containing the features extracted for each image. The file will be created in the cache directory of your root folder. This file contains a list of dictionaries, one dictionary per image of your dataset. It is of the form {'img':'xxx', 'cls','123','hist': ''} where img is the name of the image, cls is the class and hist holds the histogram generated for that image. You can choose one of the element of this list as your query image and then call the function infer which is inside evaluate.py to calculate the similarity distance of the query image and the other images and return the most similar results.

Code mentioned below could be helpful: from evaluate import infer samples = cPickle.load(open('D:\Work\CBIR\CBIR-master\cache\histogram_cache-region-n_bin12-n_slice3', "rb", True)) query=samples[13627] ap,res=infer(query,samples,db=None, sample_db_fn=None, depth=10, d_type='d1') depth is the number of similar images you want to retrieve and d_type is the type of simialrity metric you want to use.

You might want to modify the function infer inside evaluate to return also the matched image name along with class and distance which it is presently retrieving.

dgtlmoon commented 4 years ago

man i wish it was possible to ban/delete comments, like the one above

Praveenk8051 commented 3 years ago

@dgtlmoon You are right , the retrieval is not going on. What's the whole point of retrieving the image by passing the class_name !!