craymichael / CNN_LCD

CNNs for Loop-Closure Detection on the Oxford New College and City Centre Datasets
GNU General Public License v3.0
58 stars 14 forks source link

use my photo? #3

Closed IConquer96 closed 5 years ago

IConquer96 commented 5 years ago

Hello, can I judge the similarity by entering my own two photos?

craymichael commented 5 years ago

Hi, there is not a built-in way to do this currently, but if you could modify this highlighted line in cnn_lcd.py. For example, you could change it to something like the following:

from scipy.ndimage import imread
...
# Load your images
imgs = np.asarray([imread(my_image) for my_image in my_image_dir])
# Spoof the ground truth (unless you have it)
n_imgs = len(imgs)
gt = np.full([n_imgs, n_imgs], 0.)

Let me know how things go!

IConquer96 commented 5 years ago

i change the code like you said:

Load your images

my_img_dir = 'ldata/' imgs = np.asarray([imread(my_img_dir+my_image) for my_image in os.listdir('ldata')])

Spoof the ground truth (unless you have it)

n_imgs = len(imgs) gt = np.full([n_imgs, n_imgs], 0.)

and this (cause i don't have the ground truth):

# Compute similarity matrix
sim = similarity_matrix(descs, gt, plot=True, cluster=True, median=False,
                        k_size=k_size, name='_'.join([args.dataset, model_name]))

but i think the result may be wrong ,i used two diffrent images and two similar images ,got the same images like that Figure_1-1 but when i use 100+ images ,it shows that: Figure_1

craymichael commented 5 years ago

This may be an issue of image interpolation. It may also be a limitation of the method, which is unsupervised. I expect the method to perform poorly with a small amount of data, especially as the similarity values are normalized globally (i.e. by the largest difference between image descriptors).

Try removing interpolation from lines 244 and 258 of cnn_lcd.py:

cax = ax.imshow(sim, cmap='coolwarm', interpolation='none',
                vmin=0., vmax=1.)
IConquer96 commented 5 years ago

i did the change as you said,but nothing went good ,so i give up,but i have one more question?why i run the code as you wrote ,the average precision is so low,and the p-r cure is not like the ariticle?

craymichael commented 5 years ago

Performance will vary depending on the parameters used (e.g. for clustering or median filtering), and the CNN model. I could not replicate their results (from the article) exactly using the Overfeat model so tried methods of improving the detection quality.

IConquer96 commented 5 years ago

okay,thank you!!