PetervanLunteren / EcoAssist

Simplify camera trap image analysis with ML species recognition models based around the MegaDetector model
MIT License
121 stars 16 forks source link

Local variable 'elapsed_time' referenced before assignment #9

Closed FedakD closed 1 year ago

FedakD commented 1 year ago

Hi Peter,

I'm having similar issues as to Rolland from before where deploying the model leads to an error with lines 1100 and 951 in the EcoAssist_GUI.py. I've updated my Git and completely uninstalled/reinstalled Anaconda and EcoAssist several times, similar to the previous user issue fix. As far as I can tell, EcoAssist installed properly since I have the GUI up and can search folders where images are stored.

Below is the command error prompt:

Exception in Tkinter callback Traceback (most recent call last): File "EcoAssist\EcoAssist_GUI.py", line 1100, in start_deploy deploy_model(var_choose_folder.get(), additional_img_options, data_type = "img") File "EcoAssist\EcoAssist_GUI.py", line 951, in deploy_model progress_stats['text'] = create_md_progress_lbl(elapsed_time = elapsed_time, UnboundLocalError: local variable 'elapsed_time' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\ProgramData\anaconda3\envs\ecoassistcondaenv\lib\tkinter__init.py", line 1892, in call__ return self.func(*args) File "EcoAssist\EcoAssist_GUI.py", line 1121, in start_deploy reset_frame_states() NameError: name 'reset_frame_states' is not defined

PetervanLunteren commented 1 year ago

Hi @FedakD,

That error message means that there is some unexpected model output. The log file should point us in the right direction. Could you please:

FedakD commented 1 year ago

Hi @PetervanLunteren ,

Thanks for the quick reply. Here is the text from the log file. It looks like the MD code may not be downloaded into the expected folder.

EXECUTED: deploy_model({'path_to_image_folder': 'D:/Camera/BOCCA/BOCCA 7 - Ekuthuleni', 'selected_options': ['--output_relative_filenames', '--recursive', '--checkpoint_frequency=1000'], 'data_type': 'img'})

EXECUTED: switch_yolov5_git_to({'model_type': 'old models'})

command:

['C:\ProgramData\anaconda3\envs\ecoassistcondaenv\python.exe', 'C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py', 'C:\Program Files\EcoAssist_files\pretrained_models\md_v5a.0.0.pt', '--output_relative_filenames', '--recursive', '--checkpoint_frequency=1000', 'D:\Camera\BOCCA\BOCCA 7 - Ekuthuleni', 'D:\Camera\BOCCA\BOCCA 7 - Ekuthuleni\image_recognition_file.json']

Traceback (most recent call last): File "C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py", line 816, in main() File "C:\Program Files\EcoAssist_files\cameratraps\detection\run_detector_batch.py", line 665, in main assert os.path.exists(args.detector_file), \ AssertionError: detector file C:\Program Files\EcoAssist_files\pretrained_models\md_v5a.0.0.pt does not exist ERROR: local variable 'elapsed_time' referenced before assignment

DETAILS: Traceback (most recent call last): File "EcoAssist\EcoAssist_GUI.py", line 1100, in start_deploy deploy_model(var_choose_folder.get(), additional_img_options, data_type = "img") File "EcoAssist\EcoAssist_GUI.py", line 951, in deploy_model progress_stats['text'] = create_md_progress_lbl(elapsed_time = elapsed_time, UnboundLocalError: local variable 'elapsed_time' referenced before assignment

FedakD commented 1 year ago

Hi @PetervanLunteren ,

I copy/pasted the model files (md_v5a and b as well as the run_detector.py files) into the pretrained_models folder, and it's starting to run. I had those files saved in another folder from my initial download of MegaDetector before opting to try your GUI, so it looks like the installation didn't include those files initially into EcoAssist.

I'll mark this solved, but thank you for the quick response!

Derek

PetervanLunteren commented 1 year ago

Great!

For those who have the same problem:

There should be two model files:

Sometimes protection software prevent the download of the actual model files. If so, download them manually and place them in \EcoAssist_files\pretrained_models\. You can download them here: