Skip to content

Commit

Permalink
Fixed repeatedly calling filter after recordInsert
Browse files Browse the repository at this point in the history
Changed confidence slider mouseout timeout
  • Loading branch information
Mattk70 committed Oct 31, 2023
1 parent f4f2e23 commit 5a4a61d
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 83 deletions.
178 changes: 178 additions & 0 deletions custom_tfjs/custom_tfjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/**
* @license
* Copyright 2023 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

// This file is autogenerated.


import {registerKernel} from '@tensorflow/tfjs-core/dist/base';
import '@tensorflow/tfjs-core/dist/base_side_effects';
export * from '@tensorflow/tfjs-core/dist/base';
export * from '@tensorflow/tfjs-converter';

//backend = cpu
export * from '@tensorflow/tfjs-backend-cpu/dist/base';
import {splitVConfig as SplitV_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/SplitV';
registerKernel(SplitV_cpu);
import {maxConfig as Max_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Max';
registerKernel(Max_cpu);
import {minConfig as Min_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Min';
registerKernel(Min_cpu);
import {subConfig as Sub_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Sub';
registerKernel(Sub_cpu);
import {realDivConfig as RealDiv_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/RealDiv';
registerKernel(RealDiv_cpu);
import {multiplyConfig as Multiply_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Multiply';
registerKernel(Multiply_cpu);
import {sliceConfig as Slice_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Slice';
registerKernel(Slice_cpu);
import {concatConfig as Concat_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Concat';
registerKernel(Concat_cpu);
import {reshapeConfig as Reshape_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Reshape';
registerKernel(Reshape_cpu);
import {zerosLikeConfig as ZerosLike_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/ZerosLike';
registerKernel(ZerosLike_cpu);
import {complexConfig as Complex_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Complex';
registerKernel(Complex_cpu);
import {fFTConfig as FFT_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/FFT';
registerKernel(FFT_cpu);
import {realConfig as Real_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Real';
registerKernel(Real_cpu);
import {imagConfig as Imag_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Imag';
registerKernel(Imag_cpu);
import {complexAbsConfig as ComplexAbs_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/ComplexAbs';
registerKernel(ComplexAbs_cpu);
import {packConfig as Pack_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Pack';
registerKernel(Pack_cpu);
import {transposeConfig as Transpose_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Transpose';
registerKernel(Transpose_cpu);
import {reverseConfig as Reverse_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Reverse';
registerKernel(Reverse_cpu);
import {expandDimsConfig as ExpandDims_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/ExpandDims';
registerKernel(ExpandDims_cpu);
import {resizeBilinearConfig as ResizeBilinear_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/ResizeBilinear';
registerKernel(ResizeBilinear_cpu);
import {castConfig as Cast_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Cast';
registerKernel(Cast_cpu);
import {conv2DConfig as Conv2D_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Conv2D';
registerKernel(Conv2D_cpu);
import {addConfig as Add_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Add';
registerKernel(Add_cpu);
import {sigmoidConfig as Sigmoid_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Sigmoid';
registerKernel(Sigmoid_cpu);
import {fusedDepthwiseConv2DConfig as FusedDepthwiseConv2D_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/FusedDepthwiseConv2D';
registerKernel(FusedDepthwiseConv2D_cpu);
import {meanConfig as Mean_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Mean';
registerKernel(Mean_cpu);
import {stridedSliceConfig as StridedSlice_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/StridedSlice';
registerKernel(StridedSlice_cpu);
import {batchMatMulConfig as BatchMatMul_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/BatchMatMul';
registerKernel(BatchMatMul_cpu);
import {_fusedMatMulConfig as _FusedMatMul_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/_FusedMatMul';
registerKernel(_FusedMatMul_cpu);
import {identityConfig as Identity_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Identity';
registerKernel(Identity_cpu);
import {maximumConfig as Maximum_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Maximum';
registerKernel(Maximum_cpu);
import {greaterConfig as Greater_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Greater';
registerKernel(Greater_cpu);
import {tileConfig as Tile_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Tile';
registerKernel(Tile_cpu);
import {selectConfig as Select_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Select';
registerKernel(Select_cpu);
import {topKConfig as TopK_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/TopK';
registerKernel(TopK_cpu);
import {squareConfig as Square_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/Square';
registerKernel(Square_cpu);
import {greaterEqualConfig as GreaterEqual_cpu} from '@tensorflow/tfjs-backend-cpu/dist/kernels/GreaterEqual';
registerKernel(GreaterEqual_cpu);

//backend = webgl
export * from '@tensorflow/tfjs-backend-webgl/dist/base';
import {splitVConfig as SplitV_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/SplitV';
registerKernel(SplitV_webgl);
import {maxConfig as Max_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Max';
registerKernel(Max_webgl);
import {minConfig as Min_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Min';
registerKernel(Min_webgl);
import {subConfig as Sub_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Sub';
registerKernel(Sub_webgl);
import {realDivConfig as RealDiv_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/RealDiv';
registerKernel(RealDiv_webgl);
import {multiplyConfig as Multiply_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Multiply';
registerKernel(Multiply_webgl);
import {sliceConfig as Slice_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Slice';
registerKernel(Slice_webgl);
import {concatConfig as Concat_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Concat';
registerKernel(Concat_webgl);
import {reshapeConfig as Reshape_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Reshape';
registerKernel(Reshape_webgl);
import {zerosLikeConfig as ZerosLike_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/ZerosLike';
registerKernel(ZerosLike_webgl);
import {complexConfig as Complex_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Complex';
registerKernel(Complex_webgl);
import {fFTConfig as FFT_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/FFT';
registerKernel(FFT_webgl);
import {realConfig as Real_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Real';
registerKernel(Real_webgl);
import {imagConfig as Imag_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Imag';
registerKernel(Imag_webgl);
import {complexAbsConfig as ComplexAbs_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/ComplexAbs';
registerKernel(ComplexAbs_webgl);
import {packConfig as Pack_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Pack';
registerKernel(Pack_webgl);
import {transposeConfig as Transpose_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Transpose';
registerKernel(Transpose_webgl);
import {reverseConfig as Reverse_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Reverse';
registerKernel(Reverse_webgl);
import {expandDimsConfig as ExpandDims_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/ExpandDims';
registerKernel(ExpandDims_webgl);
import {resizeBilinearConfig as ResizeBilinear_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/ResizeBilinear';
registerKernel(ResizeBilinear_webgl);
import {castConfig as Cast_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Cast';
registerKernel(Cast_webgl);
import {conv2DConfig as Conv2D_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Conv2D';
registerKernel(Conv2D_webgl);
import {addConfig as Add_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Add';
registerKernel(Add_webgl);
import {sigmoidConfig as Sigmoid_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Sigmoid';
registerKernel(Sigmoid_webgl);
import {fusedDepthwiseConv2DConfig as FusedDepthwiseConv2D_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/FusedDepthwiseConv2D';
registerKernel(FusedDepthwiseConv2D_webgl);
import {meanConfig as Mean_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Mean';
registerKernel(Mean_webgl);
import {stridedSliceConfig as StridedSlice_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/StridedSlice';
registerKernel(StridedSlice_webgl);
import {batchMatMulConfig as BatchMatMul_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/BatchMatMul';
registerKernel(BatchMatMul_webgl);
import {_fusedMatMulConfig as _FusedMatMul_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/_FusedMatMul';
registerKernel(_FusedMatMul_webgl);
import {identityConfig as Identity_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Identity';
registerKernel(Identity_webgl);
import {maximumConfig as Maximum_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Maximum';
registerKernel(Maximum_webgl);
import {greaterConfig as Greater_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Greater';
registerKernel(Greater_webgl);
import {tileConfig as Tile_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Tile';
registerKernel(Tile_webgl);
import {selectConfig as Select_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Select';
registerKernel(Select_webgl);
import {topKConfig as TopK_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/TopK';
registerKernel(TopK_webgl);
import {squareConfig as Square_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/Square';
registerKernel(Square_webgl);
import {greaterEqualConfig as GreaterEqual_webgl} from '@tensorflow/tfjs-backend-webgl/dist/kernels/GreaterEqual';
registerKernel(GreaterEqual_webgl);
23 changes: 23 additions & 0 deletions custom_tfjs/custom_tfjs_core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2023 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

// This file is autogenerated.


import {registerKernel} from '@tensorflow/tfjs-core/dist/base';
import '@tensorflow/tfjs-core/dist/base_side_effects';
export * from '@tensorflow/tfjs-core/dist/base';
11 changes: 11 additions & 0 deletions custom_tfjs_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"kernels": ["SplitV", "Max", "Min", "Sub", "RealDiv", "Multiply", "Slice", "Concat", "Reshape", "ZerosLike", "Complex", "FFT", "Real", "Imag", "ComplexAbs", "Pack", "Transpose", "Reverse", "ExpandDims", "ResizeBilinear", "Cast", "Conv2D", "Add", "Sigmoid", "FusedDepthwiseConv2D", "fusedDepthwiseConv2d__op", "Mean", "StridedSlice", "BatchMatMul", "_FusedMatMul", "fusedMatMul__op", "Identity", "Maximum", "Greater", "Tile", "Select", "TopK", "Square", "GreaterEqual"],
"backends": [
"cpu", "webgl"
],
"models": [
"./model/model.json"
],
"outputPath": "./custom_tfjs",
"forwardModeOnly": true
}
64 changes: 0 additions & 64 deletions js/audio_normalizer.js

This file was deleted.

30 changes: 16 additions & 14 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ const filename = document.getElementById('filename');
filename.addEventListener('click', openFileInList);
filename.addEventListener('contextmenu', buildFileMenu);

function renderFilnamePanel() {
function renderFilenamePanel() {
if (!currentFile) return;
const openfile = currentFile;
const files = fileList;
Expand Down Expand Up @@ -939,7 +939,7 @@ function hideAll() {
const save2dbLink = document.getElementById('save2db');
save2dbLink.addEventListener('click', async () => {
worker.postMessage({ action: 'save2db', file: currentFile })
renderFilnamePanel();
renderFilenamePanel();
});

const export2audio = document.getElementById('export2audio');
Expand Down Expand Up @@ -1465,13 +1465,6 @@ const setUpWorkerMessaging = () => {
case 'diskDB-has-records':
chartsLink.classList.remove('disabled');
exploreLink.classList.remove('disabled');
if (currentFile) {
worker.postMessage({
action: 'filter',
species: isSpeciesViewFiltered(true),
active: getActiveRowID(),
}); // no re-prepare
}
break;
case 'file-location-id':
onFileLocationID(args);
Expand All @@ -1481,15 +1474,24 @@ const setUpWorkerMessaging = () => {
break;
case 'generate-alert':
if (args.render) {
renderFilnamePanel();
renderFilenamePanel();
window.electron.unsavedRecords(false);
document.getElementById('unsaved-icon').classList.add('d-none');
}
if (args.file) { // File is in disk database but not found
let message = args.message;
message += '\nWould you like to remove the file from the Archive?';
if (confirm(message)) deleteFile(args.file)
} else { alert(args.message) }
} else {
if (args.savedToDB){
worker.postMessage({
action: 'filter',
species: isSpeciesViewFiltered(true),
active: getActiveRowID(),
}); // no re-prepare
}
alert(args.message)
}
break;
case 'location-list':
LOCATIONS = args.locations;
Expand All @@ -1501,7 +1503,7 @@ const setUpWorkerMessaging = () => {
case 'mode-changed':
STATE.mode = args.mode;
// Update the current file name in the UI
renderFilnamePanel();
renderFilenamePanel();
console.log('Mode changed to: ' + args.mode);
break;
case 'no-detections-remain':
Expand Down Expand Up @@ -2475,7 +2477,7 @@ async function onWorkerLoadedAudio({
NEXT_BUFFER = undefined;
if (currentFile !== file) {
currentFile = file;
renderFilnamePanel();
renderFilenamePanel();
fileStart = start;
fileEnd = new Date(fileStart + (currentFileDuration * 1000));
}
Expand Down Expand Up @@ -3906,7 +3908,7 @@ function deleteFile(file) {
fileName: file
})
}
renderFilnamePanel()
renderFilenamePanel()
}
}
// Utility functions to wait for file to load
Expand Down
5 changes: 3 additions & 2 deletions js/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ async function handleMessage(e) {
if (STATE.mode !== 'explore' && !args.batch && args.toDisk) {
UI.postMessage({
event: 'generate-alert',
message: `${count} ${args.cname} record has been saved to the archive.`
message: `${count} ${args.cname} record has been saved to the archive.`,
savedToDB: true
})
}
break;
Expand Down Expand Up @@ -1651,7 +1652,7 @@ async function batchInsertRecords(cname, label, toDisk, files, originalCname) {
}
await db.runAsync('END');
console.log(`Batch record update took ${(Date.now() - t0) / 1000} seconds`)
if (STATE.mode !== 'explore' && toDisk) UI.postMessage({ event: 'generate-alert', message: `${count} ${cname} records have been saved to the archive.` })
if (STATE.mode !== 'explore' && toDisk) UI.postMessage({ event: 'generate-alert', message: `${count} ${cname} records have been saved to the archive.`, savedToDB: true })
}

const onInsertManualRecord = async ({ cname, start, end, comment, count, file, label, toDisk, batch, originalCname }) => {
Expand Down
Loading

0 comments on commit 5a4a61d

Please sign in to comment.