Closed agentmorris closed 1 year ago
Good catch. The deeper issue is that there are a handful of scripts that we use all the time, but never run from the command line (only from other Python code), so our command-line testing is... suboptimal.
The medium-deep issue is that we should not have been passing "args" like it was an options object; our normal paradigm is to use ct_utils.args_to_object to convert a set of command-line arguments to an options class (in this case, an instance of IntegrityCheckOptions). I did that here, and also added a "--bAllowNoLocation" option (although after this change, this would no longer have caused the script to crash, it's just a useful option to expose).
Thanks for finding this!
(Comment originally posted by agentmorris)
Awesome! Thanks for jumping on this so quickly!
Is there some basic documentation on how to get up and running w/ this repo locally so that I can take advantage of all the fantastic data management & COCO utility tools? Again, Python novice here, but I don't see a requirements.txt
anywhere or instructions on what version of python to be running, so thus far I've just been making some guesses and installed dependencies one by one when it complained at me.
Along those lines, with the latest updates to integrity_check_json_db.py
I'm now getting a ModuleNotFoundError: No module named 'ct_utils'
error... I can see that ct_utils.py is in the root directory, and I tried setting $PYTHONPATH
to point to that, but it still isn't finding the module. This is probably Python 101, so apologies in advance.
(Comment originally posted by nathanielrindlaub)
Indeed, you can roughly divide this repo into:
I'd like to think that we're pretty meticulous about documentation and environment management for (1), but for (2)... not so much. We used to maintain separate instructions for (2), and we still have a mostly-correct conda environment file for (2), but so few users were doing anything other than running MegaDetector that we stopped explicitly supporting (2).
That said, we're not that far off: I use most of these modules regularly, and I only have one conda environment, which is almost just the recommended environment for running MegaDetector.
So if you are likely to use non-MegaDetector-related scripts in this repo, I recommend following the MegaDetector setup instructions to set up a conda environment, which will give you the correct Python version, the correct dependent repos (e.g. ai4eutils), and almost all of the correct Python packages. The only thing you should ever need to do is occasionally pip-installing something that isn't present in the MegaDetector conda environment file.
The only downside of this approach if you're not running MegaDetector at all in this environment is that you're carrying around a giant PyTorch install. If you don't want to deal with installing PyTorch during the setup process, YMMV, but you should be able to substitute "environment.yml" for "environment-detector.yml" during the setup process.
Hope that helps!
(Comment originally posted by agentmorris)
Also, a more direct answer to your question about requirements.txt: because we have always used Anaconda for development, Conda environment files (in particular environment-detector.yml) play the role that requirements.txt files play in other repos.
(Comment originally posted by agentmorris)
Got it! Thank you Dan! I'll look through the MegaDetector setup instructions to get that conda env up and running. Cheers.
(Comment originally posted by nathanielrindlaub)
I was just trying to validate a COCO for Camera Traps .json file with integrity_check_json_db.py with the following command:
And ran into the following error on line 196:
AttributeError: 'Namespace' object has no attribute 'bRequireLocation'
.I could be misunderstanding something (not a Python guy) but looks to me like
options
will never beNone
–and thus thedefaultOptions
will never get assigned to it–because we pass the parsedargs
directly fromargparse
intointegrity_check_json_db()
as the second param, and theargs
will always include some default values and a value forjsonFile
.I fixed this locally by changing
bRequireLocation
->dDoNotRequireLocation
throughout and adding an arg for it and fornThreads
to argparse:I'd be happy to submit a PR for this fix if that's at all helpful.
Issue cloned from Microsoft/CameraTraps, original issue posted by nathanielrindlaub on Nov 22, 2022.