PetervanLunteren/EcoAssist

Local variable 'elapsed_time' referenced before assignment

FedakD opened this issue · 4 comments

FedakD commented

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

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:

  • Recreate the error in EcoAssist.
  • Close all EcoAssist windows by clicking the cross at the top - do not quit the program as a whole. On Mac and Linux close the terminal window last.
  • Navigate to the EcoAssist_files folder. You can find its location here.
  • Open EcoAssist_files\EcoAssist\logfiles\session_log.txt (Windows) or .EcoAssist_files/EcoAssist/logfiles/stdout.txt (Mac and Linux).
  • Copy everything after the line EXECUTED: start_deploy({}) and paste it here.
FedakD commented

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

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

Great!

For those who have the same problem:

There should be two model files:

  • \EcoAssist_files\pretrained_models\md_v5a.0.0.pt
  • \EcoAssist_files\pretrained_models\md_v5b.0.0.pt

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: