BirdNET-Analyzer icon indicating copy to clipboard operation
BirdNET-Analyzer copied to clipboard

Add an option for not analyzing files that have been analyzed

Open BenCretois opened this issue 2 years ago • 1 comments

When dealing with large amount of data (and thus long processing time) the server can unexpectedly crash, shutting down the analysis. It would be great if there was an option for avoiding the analysis of files that have already been analyzed.

I made a very quick fix but I am pretty much sure this can be optimized. In the function analyzeFile I added:

def analyzeFile(item):

    # Get file path and restore cfg
    fpath = item[0]
    cfg.setConfig(item[1])

    # CUSTOM - CHECK IF THE FILE ALREADY EXISTS
    rpath = fpath.replace(cfg.INPUT_PATH, '')
    rpath = rpath[1:] if rpath[0] in ['/', '\\'] else rpath

    # Check if file already exists and if it does skip the analysis
    if cfg.RESULT_TYPE == 'table':
        rtype = '.BirdNET.selection.table.txt' 
    elif cfg.RESULT_TYPE == 'audacity':
        rtype = '.BirdNET.results.txt'
    else:
        rtype = '.BirdNET.results.csv'

    outname = os.path.join(cfg.OUTPUT_PATH, rpath.rsplit('.', 1)[0] + rtype)

    if os.path.exists(outname):
        print("File {} already exists".format(outname))
    else:
        DO THE REST OF THE ANALYSIS

BenCretois avatar Apr 17 '23 10:04 BenCretois

Hi! Something like this is on our agenda and will also be added to the GUI. Thanks for sharing!

Josef-Haupt avatar Apr 18 '23 14:04 Josef-Haupt