Skip to content

Commit

Permalink
Clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrilvallez committed May 4, 2022
1 parent 6bf8a6d commit fd7b1a1
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 524 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ digest = hashing.total_hashing(algos, thresholds, path_database, positive_datase
utils.save_digest(digest, save_folder)
```

All this is contained in `main.py`.
All this is contained in `main.py`.

The final digest is composed of 6 files : `general.json` with general metrics for all the experiment, `attacks.json` containing the metrics for each types of attack, `images_pos.json` and `images_neg.json` containing number of correct/incorrect detection for each image in the database respectively, and `match_time.json` and `db_time.json` respectively containing the time (s) for the matching phase and the the database creation phase.
The final digest is composed of 6 files : `general.json` with general metrics for all the experiment, `attacks.json` containing the metrics for each types of attack, `images_pos.json` and `images_neg.json` containing number of correct/incorrect detection for each image in the database respectively, and `match_time.json` and `db_time.json` respectively containing the time (s) for the matching phase and the the database creation phase.

To process and create figures from the digest, one can look into `process.py`.

# Datasets

We personally used 3 datasets that can be found at <INSERT LINK !!!> and for which the splitting has already been done. They are the BSDS500 dataset, ImageNet validation set and a dataset from Kaggle containing memes from reddit.

# Pre-trained SimCLR models

The pre-trained SimCLR models are not available in this repository due to their large size. They can be downloaded (along with their architecture definition) directly in the [github of the authors ](https://github.com/google-research/simclr) or downloaded directly at <INSERT LINK !!!> (folders SimCLRv1 and SimCLRv2) and then added to the `hashing` folder of the library.
95 changes: 0 additions & 95 deletions explore_memes.py

This file was deleted.

52 changes: 0 additions & 52 deletions main3.py

This file was deleted.

62 changes: 0 additions & 62 deletions main_memes_ensemble.py

This file was deleted.

55 changes: 0 additions & 55 deletions process.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,60 +164,5 @@
res[algo] = {'fpr': fpr[index], 'threshold': thresholds[index]}


#%%
import os
from helpers import utils
from helpers import create_plot as plot

experiment_names = [f'Database_{i}_ImageNet' for i in [250, 2500, 25000]]
experiment_folders = ['Results/' + a for a in experiment_names]

res = []

for a in experiment_folders:

general, _, _, _, _,_ = utils.load_digest(a)
res.append(general)

plot.roc_comparison_database(res, save=False, filename='Comparison_db_size.pdf')

#%%
from helpers import utils

experiment_folder = 'Results/Test_memes1/'

general, image_pos, image_neg, _, _ = utils.load_digest(experiment_folder, False)


#%%

from PIL import Image
import cv2
import numpy as np

original = 'Datasets/BSDS500/Control/data17.jpg'
original = Image.open(original)
original = np.array(original.convert('L'))

copy = 'Datasets/BSDS500/Control_attacks/data17_rotation_60_and_rescaling.png'
copy = Image.open(copy)
copy = np.array(copy.convert('L'))

sift = cv2.SIFT_create()

kp1, des1 = sift.detectAndCompute(original, None)
kp2, des2 = sift.detectAndCompute(copy, None)

bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
matches = bf.match(des1,des2)
matches = sorted(matches, key = lambda x:x.distance)

img3 = cv2.drawMatches(original,kp1,copy,kp2,matches[:30],None,flags=cv2.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)

out = Image.fromarray(img3)
# out.save('test_feat.png')

img = cv2.drawKeypoints(original, np.random.choice(kp1, 500, replace=False), None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
out_keypoints = Image.fromarray(img)
out_keypoints.save('keypoints.png')

45 changes: 0 additions & 45 deletions test.py

This file was deleted.

28 changes: 0 additions & 28 deletions test.sh

This file was deleted.

Loading

0 comments on commit fd7b1a1

Please sign in to comment.