Default to 16 hash size and add "Original" similarity (#768)

This commit is contained in:
Rafał Mikrut 2022-07-05 19:58:57 +02:00 committed by GitHub
parent d1c66fda1b
commit e3cea67634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 19 deletions

24
Cargo.lock generated
View File

@ -221,9 +221,9 @@ checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.9.1" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
@ -455,9 +455,9 @@ dependencies = [
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"typenum", "typenum",
@ -1415,9 +1415,9 @@ dependencies = [
[[package]] [[package]]
name = "infer" name = "infer"
version = "0.8.1" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e035cede526e0b21d5adffc9fa0eb4ef5d6026fe9c5b0bfe8084b9472b587a55" checksum = "f178e61cdbfe084aa75a2f4f7a25a5bb09701a47ae1753608f194b15783c937a"
dependencies = [ dependencies = [
"cfb", "cfb",
] ]
@ -1810,9 +1810,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.12.0" version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
@ -2887,9 +2887,9 @@ dependencies = [
[[package]] [[package]]
name = "trash" name = "trash"
version = "2.1.4" version = "2.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d0492e349e41bfa40e9d446a5803b84275898f0b3bda568b23e10325702095d" checksum = "fe090367848cd40c4230ff3ce4e2ff6a2fd511c1e14ae047a4a4c37ef7965236"
dependencies = [ dependencies = [
"chrono", "chrono",
"libc", "libc",
@ -2924,9 +2924,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]] [[package]]
name = "ucd-trie" name = "ucd-trie"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c"
[[package]] [[package]]
name = "unic-langid" name = "unic-langid"

View File

@ -145,7 +145,7 @@ pub enum Commands {
hash_alg: HashAlg, hash_alg: HashAlg,
#[clap(short = 'z', long, default_value = "Lanczos3", parse(try_from_str = parse_similar_image_filter), help = "Hash algorithm (allowed: Lanczos3, Nearest, Triangle, Faussian, Catmullrom)")] #[clap(short = 'z', long, default_value = "Lanczos3", parse(try_from_str = parse_similar_image_filter), help = "Hash algorithm (allowed: Lanczos3, Nearest, Triangle, Faussian, Catmullrom)")]
image_filter: FilterType, image_filter: FilterType,
#[clap(short = 'c', long, default_value = "8", parse(try_from_str = parse_image_hash_size), help = "Hash size (allowed: 4, 8, 16)")] #[clap(short = 'c', long, default_value = "16", parse(try_from_str = parse_image_hash_size), help = "Hash size (allowed: 8, 16, 32, 64)")]
hash_size: u8, hash_size: u8,
}, },
#[clap(name = "music", about = "Finds same music by tags", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n czkawka music -d /home/rafal -f results.txt")] #[clap(name = "music", about = "Finds same music by tags", help_message = HELP_MESSAGE, after_help = "EXAMPLE:\n czkawka music -d /home/rafal -f results.txt")]

View File

@ -63,7 +63,7 @@ imagepipe = "0.5.0"
# Checking for invalid extensions # Checking for invalid extensions
mime_guess = "2.0.4" mime_guess = "2.0.4"
infer = "0.8.0" infer = "0.9.0"
num_cpus = "1.13.1" num_cpus = "1.13.1"

View File

@ -1,4 +1,5 @@
# Core # Core
core_similarity_original = Original
core_similarity_very_high = Very High core_similarity_very_high = Very High
core_similarity_high = High core_similarity_high = High
core_similarity_medium = Medium core_similarity_medium = Medium
@ -26,7 +27,7 @@ core_directory_overlap = Directories: All directories to search overlaps with ex
core_directory_unable_to_get_device_id = Directories: Unable to get device id from folder { $path } core_directory_unable_to_get_device_id = Directories: Unable to get device id from folder { $path }
core_ffmpeg_not_found = Cannot find proper installation of FFmpeg core_ffmpeg_not_found = Cannot find proper installation of FFmpeg
core_ffmpeg_not_found_windows = When using Windows be sure that ffmpeg.exe and ffprobe.exe are available in PATH or are put directly to same folder where is app executable core_ffmpeg_not_found_windows = Be sure that ffmpeg.exe and ffprobe.exe are available in PATH or are put directly to same folder where is app executable
core_ffmpeg_missing_in_snap = Similar Videos don't work currently with snap, if you want help look at - { $url } core_ffmpeg_missing_in_snap = Similar Videos don't work currently with snap, if you want help look at - { $url }
core_saving_to_cache = Saved to file { $number } cache entries core_saving_to_cache = Saved to file { $number } cache entries

View File

@ -1247,7 +1247,9 @@ pub fn get_string_from_similarity(similarity: &u32, hash_size: u8) -> String {
// } // }
// #[cfg(not(debug_assertions))] // #[cfg(not(debug_assertions))]
if *similarity <= SIMILAR_VALUES[index_preset][0] { if *similarity == 0 {
flc!("core_similarity_original")
} else if *similarity <= SIMILAR_VALUES[index_preset][0] {
flc!("core_similarity_very_high") flc!("core_similarity_very_high")
} else if *similarity <= SIMILAR_VALUES[index_preset][1] { } else if *similarity <= SIMILAR_VALUES[index_preset][1] {
flc!("core_similarity_high") flc!("core_similarity_high")
@ -1347,6 +1349,9 @@ pub fn test_image_conversion_speed() {
} }
#[allow(dead_code)] #[allow(dead_code)]
// Function to validate if after first check there are any duplicated entries
// E.g. /a.jpg is used also as master and similar image which is forbidden, because may
// cause accidentally delete more pictures that user wanted
fn debug_check_for_duplicated_things( fn debug_check_for_duplicated_things(
hashes_parents: HashMap<&Vec<u8>, u32>, hashes_parents: HashMap<&Vec<u8>, u32>,
hashes_similarity: HashMap<&Vec<u8>, (&Vec<u8>, u32)>, hashes_similarity: HashMap<&Vec<u8>, (&Vec<u8>, u32)>,

View File

@ -203,7 +203,9 @@ impl SimilarVideos {
pub fn find_similar_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&futures::channel::mpsc::UnboundedSender<ProgressData>>) { pub fn find_similar_videos(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&futures::channel::mpsc::UnboundedSender<ProgressData>>) {
if !check_if_ffmpeg_is_installed() { if !check_if_ffmpeg_is_installed() {
self.text_messages.errors.push(flc!("core_ffmpeg_not_found")); self.text_messages.errors.push(flc!("core_ffmpeg_not_found"));
#[cfg(target_os = "windows")]
self.text_messages.errors.push(flc!("core_ffmpeg_not_found_windows")); self.text_messages.errors.push(flc!("core_ffmpeg_not_found_windows"));
#[cfg(target_os = "linux")]
self.text_messages.errors.push(flc!( self.text_messages.errors.push(flc!(
"core_ffmpeg_missing_in_snap", "core_ffmpeg_missing_in_snap",
generate_translation_hashmap(vec![("url", "https://github.com/snapcrafters/ffmpeg/issues/73".to_string())]) generate_translation_hashmap(vec![("url", "https://github.com/snapcrafters/ffmpeg/issues/73".to_string())])
@ -803,7 +805,7 @@ pub fn load_hashes_from_file(text_messages: &mut Messages, delete_outdated_cache
} }
fn get_cache_file() -> String { fn get_cache_file() -> String {
"cache_similar_videos_50.bin".to_string() "cache_similar_videos.bin".to_string()
} }
pub fn check_if_ffmpeg_is_installed() -> bool { pub fn check_if_ffmpeg_is_installed() -> bool {

View File

@ -755,7 +755,7 @@ pub fn load_configuration(
let combo_box_duplicate_hash_type = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxDuplicateHashType).unwrap().clone(), 0); let combo_box_duplicate_hash_type = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxDuplicateHashType).unwrap().clone(), 0);
let combo_box_duplicate_checking_method = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxDuplicateCheckMethod).unwrap().clone(), 0); let combo_box_duplicate_checking_method = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxDuplicateCheckMethod).unwrap().clone(), 0);
let combo_box_image_hash_size = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashSize).unwrap().clone(), 0); let combo_box_image_hash_size = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashSize).unwrap().clone(), 1); // 16 instead default 8
let combo_box_image_hash_algorithm = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashType).unwrap().clone(), 0); let combo_box_image_hash_algorithm = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageHashType).unwrap().clone(), 0);
let combo_box_image_resize_algorithm = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageResizeAlgorithm).unwrap().clone(), 0); let combo_box_image_resize_algorithm = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxImageResizeAlgorithm).unwrap().clone(), 0);
let combo_box_big_files_mode = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxBigFiles).unwrap().clone(), 0); let combo_box_big_files_mode = loaded_entries.get_object(hashmap_ls.get(&LoadText::ComboBoxBigFiles).unwrap().clone(), 0);
@ -1033,7 +1033,7 @@ pub fn reset_configuration(manual_clearing: bool, upper_notebook: &GuiUpperNoteb
main_notebook.combo_box_duplicate_check_method.set_active(Some(0)); main_notebook.combo_box_duplicate_check_method.set_active(Some(0));
main_notebook.combo_box_image_hash_algorithm.set_active(Some(0)); main_notebook.combo_box_image_hash_algorithm.set_active(Some(0));
main_notebook.combo_box_image_resize_algorithm.set_active(Some(0)); main_notebook.combo_box_image_resize_algorithm.set_active(Some(0));
main_notebook.combo_box_image_hash_size.set_active(Some(0)); main_notebook.combo_box_image_hash_size.set_active(Some(1)); // Set as 16 instead 8
main_notebook.combo_box_big_files_mode.set_active(Some(0)); main_notebook.combo_box_big_files_mode.set_active(Some(0));
main_notebook.check_button_broken_files_audio.set_active(DEFAULT_BROKEN_FILES_AUDIO); main_notebook.check_button_broken_files_audio.set_active(DEFAULT_BROKEN_FILES_AUDIO);