Package: wbia-orientation
Orientation Plug-in - Part of the WildMe / Wildbook IA Project.A plugin for automatic detection of object-oriented bounding box based on axis-aligned box
for wildlife species.Installation./run_developer_setup.shREST APIWith the plugin installed, register the module name with theWBIAControl.pyfile
in the wbia repository located atwbia/wbia/control/WBIAControl.py.  Register
the module by adding the stringwbia_plugin_orientationto the
listAUTOLOAD_PLUGIN_MODNAMES.Then, load the web-based WBIA IA service and open the URL that is registered with
the@register_api decorator.cd~/code/wbia/pythondev.py--web{"status":{"cache":-1,"message":"","code":200,"success":true},"response":"[wbia_plugin_identification_example] hello world with WBIA controller <WBIAController(testdb1) at 0x11e776e90>"}Python APIpython>>>importwbia>>>importwbia_orientation>>>species='spotteddolphin'>>>url='https://cthulhu.dyn.wildme.io/public/datasets/orientation.spotteddolphin.coco.tar.gz'>>>ibs=wbia_orientation._plugin.wbia_orientation_test_ibs(species,dataset_url=url)>>>aid_list=ibs.get_valid_aids()>>>aid_list=aid_list[:10]>>>output,theta=ibs.wbia_plugin_detect_oriented_box(aid_list,species,False,False)>>>expected_theta=[-0.4158303737640381,1.5231519937515259,2.0344438552856445,1.6124389171600342,1.5768203735351562,4.669830322265625,1.3162155151367188,1.2578175067901611,0.9936041831970215,0.8561460971832275]>>>importnumpyasnp>>>diff=np.abs(np.array(theta)-np.array(expected_theta))>>>assertdiff.all()<1e-6The function from the plugin is automatically added as a method to the ibs object
asibs.wbia_plugin_detect_oriented_box(), which is registered using the@register_ibs_method decorator.Code Style and Development GuidelinesContributingIt’s recommended that you usepre-committo ensure linting procedures are run
on any commit you make. (See alsopre-commit.com)Referencepre-commit’s installation instructionsfor software installation on your OS/platform. After you have the software installed, runpre-commitinstallon the command line. Now every time you commit to this project’s code base the linter procedures will automatically run over the changed files.  To run pre-commit on files preemtively from the command line use:gitadd.pre-commitrun# orpre-commitrun--all-filesBrunetteOur code base has been formatted by Brunette, which is a fork and more configurable version of Black (https://black.readthedocs.io/en/stable/).Flake8Try to conform to PEP8.  You should set up your preferred editor to use flake8 as its Python linter, but pre-commit will ensure compliance before a git commit is completed.To run flake8 from the command line use:flake8This will use the flake8 configuration withinsetup.cfg,
which ignores several errors and stylistic considerations.
See thesetup.cfgfile for a full and accurate listing of stylistic codes to ignore.PyTestOur code uses Google-style documentation tests (doctests) that uses pytest and xdoctest to enable full support.  To run the tests from the command line use:pytestTo run doctests with+REQUIRES(–web-tests)do:pytest--web-testsResults and ExamplesQuantitative and qualitative results are presentedhereImplementation detailsDependenciesPython >= 3.7PyTorch >= 1.5DataData used for training and evaluation:sea turtle head parts -orientation.seaturtle.coco.tar.gzsea dragon head parts -orientation.seadragon.coco.tar.gzmanta ray body annotations -orientation.mantaray.coco.tar.gzspotted dolphin body annotations -orientation.spotteddolphin.coco.tar.gzhammerhead shark body annotations -orientation.hammerhead.coco.tar.gzright whale bonnet parts -orientation.rightwhale.coco.tar.gzwhale  shark -orientation.whaleshark.coco.tar.gzData preprocessingEach dataset is preprocessed to speed-up image loading during training. At the first time of running a training or a testing script on a dataset the following operations are applied:an object is cropped based on a segmentation boudnding box from annotations with a padding around equal to the half size of the box to allow for image augmentationsan image is resized so the smaller side is equal to the double size of a model input; the aspect ratio is preserved.The preprocessed dataset is saved indatadirectory.Data augmentationsDuring the training the data is augmented online in the following way:Random Horizontal FlipsRandom Vertical FlipsRandom RotationsRandom ScaleRandom CropColor Jitter (variations in brightness, hue, contrast and saturation)Both training and testing data are resized to the model input size and normalized.TrainingRun the training script:pythonwbia_orientation/train.py--cfg<path_to_config_file><additional_optional_params>Configuration files are listed inexperimentsfolder. For example, the following line trains the model with parameters specified in the config file:pythonwbia_orientation/train.py--cfgwbia_orientation/config/mantaray.yamlTo override a parameter in config, add this parameter as a command line argument:pythonwbia_orientation/train.py--cfgwbia_orientation/config/mantaray.yamlTRAIN.BS64TestingThe test script evaluates on the test set with the best model saved during training:pythonwbia_orientation/test.py--cfg<path_to_config_file><additional_optional_params>For example:pythonwbia_orientation/test.py--cfgwbia_orientation/config/mantaray.yamlBy default, the accuracy of detected rotation angle is computed for a threshold of 10 degrees.
Pass a different value as a command line parameter to evaluate with another threshold:pythonwbia_orientation/test.py--cfgwbia_orientation/config/mantaray.yamlTEST.THETA_THR15.pytest