Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: model, … file paths relative to script location #3

Closed
FloMee opened this issue Mar 9, 2022 · 6 comments
Closed

Comments

@FloMee
Copy link

FloMee commented Mar 9, 2022

It would be nice to have the possibility to run the analyze.py script independently of the actual location of the user (e.g. python3 BirdNET-Analyzer/analyze.py ...). To allow this it would be necessary to define the model, label, species_list and eBird-codes file paths relative to the location of analyze.py.

I'd like to suggest the following after parsing the arguments:

cfg.MODEL_PATH = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), cfg.MODEL_PATH)
cfg.LABELS_FILE = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), cfg.LABELS_FILE)
cfg.MDATA_MODEL_PATH = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), cfg.MDATA_MODEL_PATH)

And Line 308 (cfg.SPECIES_LIST_FILE = args.slist) could be replaced by:

cfg.SPECIES_LIST_FILE = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), args.slist)

Moreover there should be a cfg.CODES_FILE to adjust the path for the eBird-Codes as well.

@kahst
Copy link
Owner

kahst commented Mar 10, 2022

I added the requested path changes and also create a cfg.CODES_FILE. However, I'll leave this issue open until I tested this on Windows with multiple threads.

kahst added a commit that referenced this issue Mar 10, 2022
@kahst
Copy link
Owner

kahst commented Mar 10, 2022

As mentioned in #4, reverted changes for now. Do we need to run the script from outside the repo folder if we want to run it from an R script?

@FloMee
Copy link
Author

FloMee commented Mar 10, 2022

Thank's for your quick response.

Do we need to run the script from outside the repo folder if we want to run it from an R script?

Yes, that would be great as I don't want to set my working directory for every R session to the directory of the repo.

I want to be able to distribute the executable without the remainder of the repo.

I totally agree.

Yet, what I did was add the latest checkpoint and also the codes files to the dist folder.

Copying the checkpoints and the codes files into the file of the executable in addition to the relative paths is exactly what I intended to do. With this setup I should be able to call the executable from everywhere.

Sorry for mixing up the two issues…

kahst added a commit that referenced this issue Mar 14, 2022
@kahst
Copy link
Owner

kahst commented Mar 14, 2022

Ok, done :)

Can you please check and see if everything works as expected? Closing for now.

@kahst kahst closed this as completed Mar 14, 2022
@FloMee
Copy link
Author

FloMee commented Mar 15, 2022

I have to reopen the issue as there is still something missing - sorry!

Of course we need to add another line to adjust the codes file path as well.

cfg.CODES_FILE = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), cfg.CODES_FILE)

And the loadLabels function has to be called explicitly with the cfg.LABELS_FILE variable as the default variable won't be overwritten.

cfg.LABELS = loadLabels(cfg.LABELS_FILE)

This should do the trick ;-) Thanks for your adjustments and all your effort for this project!

@FloMee FloMee reopened this Mar 15, 2022
kahst added a commit that referenced this issue Mar 15, 2022
@kahst
Copy link
Owner

kahst commented Mar 15, 2022

Good catch. I also added relative paths for cfg.TRANSLATED_LABELS_PATH and cfg.ERROR_LOG_FILE. Additionally, I added path transformations to other scripts, too. Closing again :)

@kahst kahst closed this as completed Mar 15, 2022
Josef-Haupt pushed a commit to Josef-Haupt/BirdNET-Analyzer that referenced this issue Feb 24, 2024
Josef-Haupt pushed a commit to Josef-Haupt/BirdNET-Analyzer that referenced this issue Feb 24, 2024
Josef-Haupt pushed a commit to Josef-Haupt/BirdNET-Analyzer that referenced this issue Feb 24, 2024
Josef-Haupt pushed a commit to Josef-Haupt/BirdNET-Analyzer that referenced this issue Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants