recent mods, catchup
Dependencies
- [2]
S3GASDBFcatch up, changes in clips, parse - [3]
BONWFSH4update on linux and work on clips - [4]
X54TLSYEcatch up commit, train now working with julia 1.10.5 but not 1.11 - [5]
UTM4NN57changes that were left on linux - [6]
JYCKLP2Echanges to clips and predict - [7]
ZI5JRTFFsmall change to clips - [8]
2UBDFCJHnew files tracked - [9]
SMODB47Pmods to clips to truncate freq to max 16000 - [10]
ROFI4OLAcatch up, working on colour images - [11]
NMQCXLNGcatch up commit, about to do some work on prediction loop - [12]
AQWXGGE3mod to clips.jl - [13]
QA2TJZRAripped ML out into the SkraakML repo, compiles quicker now - [14]
QRBFIGF2mods to clips, file meta data, oe lieux - [15]
MMG2PLXKnew functiion to make clips of downloaded bisd calls - [16]
7KO4BAOGTidy up
Change contents
- replacement in src/FileMetaData.jl at line 8
using Glob, Skraak, CSVfolders=Glob.glob("*/2024-10-18/")using Glob, Skraak, CSV, DataFramesfolders=Glob.glob("*/2025-05-18/") - replacement in src/FileMetaData.jl at line 14
CSV.write("/media/david/Pomona-4/Pomona/pomona_files_20241126_new.csv", df; append=true)CSV.write("/media/david/Pomona-4/Pomona/pomona_files_20250522_new.csv", df; append=true)#CSV.write("/media/david/Pomona-4/Pomona/pomona_files_20241126_new.csv", df; append=true) - edit in src/FileMetaData.jl at line 72
xxh64 = String[], - edit in src/FileMetaData.jl at line 208
xxh64 = readchomp(`xxh-hash $file`) #run(`xxh-hash $file`) - edit in src/FileMetaData.jl at line 230
xxh64, - edit in src/Clips.jl at line 102
end#=using Opus, PNGFiles, Skraakfunction image_from_opus(file)signal, freq = Opus.load(file)if size(signal, 2) == 2signal = (signal[:, 1] + signal[:, 2]) / 2endif freq > 8000signal, freq = Skraak.resample_to_8000hz(signal, freq)endfreq = freq |> Float32sample = signal[:]image = Skraak.get_image_from_sample(sample, freq)PNGFiles.save("$(file).png", image)print(".") - edit in src/Clips.jl at line 120
=# - replacement in src/Clips.jl at line 146
# assumes kiwi################################################################## - replacement in src/Clips.jl at line 149
filter!(row -> row.label == label, df)filter!(row -> row.label == 1, df) - edit in src/Clips.jl at line 306
label = "Rowi" - replacement in src/Clips.jl at line 308
function move_clips_to_folders(df::DataFrame)function move_clips_to_folders(df::DataFrame, label::String) - edit in src/Clips.jl at line 315
call_map = Dict(1 => "Duet", 2 => "Female - Solo", 3 => "Male - Solo") - replacement in src/Clips.jl at line 318
dst = "$(row.label)/$(row.file)"mkpath("$(row.label)/")if row.label == 4dst = "Don't Know/$(row.file)"mkpath("Don't Know/")elsedst = "$label/$(call_map[row.label])/$(row.file)"mkpath("$label/$(call_map[row.label])")end#dst = "$(row.label)/$(row.file)"#mkpath("$(row.label)/") - replacement in src/Clips.jl at line 331
if isdir(video)#=if isdir(video) - replacement in src/Clips.jl at line 337
endend=# - edit in src/Clips.jl at line 379
predictions=[a;b;c]Floraa=glob("../Misc-1/Friends of Flora (1)/Flora */*/preds3_Kahurangi_1-5_2025-02-14.csv")b=glob("../Misc-1/Friends of Flora (1)/Flora */*/*/preds3_Kahurangi_1-5_2025-02-1*.csv")c=glob("../Misc-1/Friends of Flora (1)/Flora */*/*/*/preds3_Kahurangi_1-5_2025-02-1*.csv") - replacement in src/Clips.jl at line 388
for file in listfor file in predictions - replacement in src/Clips.jl at line 398
make_clips_generic(file, 1, "Kahurangi3_ST", true)make_clips_generic(file, 1, "MOK_202505-_K1-5_T3", true) #####false - edit in src/Clips.jl at line 404
#note of false above, be close to the wavs to minimise length of fname, wont save anything if .. in filename#= - edit in src/Clips.jl at line 464
mkpath(f)outfile = "$f/$name"sample = signal[Int(st):Int(en)]WAV.wavwrite(sample, "$outfile.wav", Fs = Int(freq))image = get_image_from_sample(sample, freq)PNGFiles.save("$outfile.png", image)endprint(".")endprint(".")end=##make_clips_clusters(glob("*/"), "preds3_opensoundscape-kiwi-1.2_2025-07-09.csv")#make_clips_clusters(glob("*/"), "predsST_opensoundscape-kiwi-1.5_2025-07-09.csv")# Valid file names follow this pattern: preds3_opensoundscape-kiwi-1.2_2025-07-09.csvfunction make_clips_clusters(clusters::Vector{String},csv_name::String)::nothingx=split(csv_name, "_")@assert length(x) == 3@assert "preds" occursin x[1]@assert "opensoundscape" occursin x[2]@assert length(x[3]) == 14@assert ".csv" occursin x[3]model = split(x[2])sensitivity = replace(first(x), "preds"=>"")for cluster in clusterscd(cluster)preds = glob("*/$csv_name")for pred in predsl=CSV.read(pred, DataFrame) |> x -> names(x)for ebird in ltrymake_clips_generic(pred, ebird, model, sensitivity, true)catch e@info eendendendcd("..")endreturn nothingendfunction make_clips_generic(preds_path::String,label::String, ##column header, ie ebird or "Kiwi"model_name::String,sensitivity::Stringunique_file_names = true,)# Assumes function run from Kahurangi Data#pth = replace(preds_path, "preds-2024-10-21.csv" => "")pth0 = split(preds_path, "/")length(pth0) > 1 ? (pth = joinpath(pth0[1:end-1]) * "/") : pth = ""function assert_detections_present_(df::DataFrame, label::String, preds_path)::DataFrame1 in levels(df.label) ? (return df) :@error "No detections for label = $label at $preds_path"end# Load and group data frame by filegdf =#! format: offDataFrames.DataFrame(CSV.File(preds_path)) |>x -> assert_not_empty(x, preds_path) |>x -> assert_detections_present_(x, label, preds_path) |>x -> filter_positives!(x, label) |>group_by_file!#! format: on# Make clip and spectrogramfor (k, v) in pairs(gdf)#file_name = chop(v.file[1], head = 2, tail = 4)file_name, extension = path_to_file_string(v.file[1])#@info (file_name, extension)start_times = v.start_time |> x ->convert(Vector{Float64}, x) |>#dropmissing(x, disallowmissing = true) |> ######CHECK used to make cobb work. not working anymore, but convert works fine. This happens because the col type of dataframe is Float64? even though no missings, seems to ony happen with doc recorderssortdetections = cluster_detections(start_times)isempty(detections) && continuesignal, freq = WAV.wavread("$pth$(file_name).$(extension)")if size(signal, 2) == 2signal = (signal[:, 1] + signal[:, 2]) / 2endif freq > 8000signal, freq = resample_to_8000hz(signal, freq)endfreq = freq |> Float32length_signal = length(signal)for detection in detectionsst, en = calculate_clip_start_end(detection, freq, length_signal)if unique_file_names == truename = "$file_name-$(Int(floor(st/freq)))-$(Int(ceil(en/freq)))" #leave off path, not necesaray if unique file nameselsep = replace(pth, "/" => "--") #replace / with -- including trailing /name = "$p$file_name-$(Int(floor(st/freq)))-$(Int(ceil(en/freq)))"endf = "Clips_$(model_name)_$(today())"