feat: adds photo_id param for computer vision scoreObservation #555
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Give the user the ability to select which photo under an observation will be sent to the computer vision model, see https://forum.inaturalist.org/t/use-computer-vision-on-each-photo-in-an-observation/4210 , it had one very recent comment about it. The objective is NOT to allow using multiple photos to get some type of combined score, but just the ability to select ONE photo from the observation.
Solution
This extends the API to accept an additional query parameter,
photo_id, that will be used to get the specific observation photo to pass on to the computer vision model. If thephoto_idprovided is not associated with the observation, the request returns a 422.If this gets merged, I intend to follow up with a pull-request in
inaturalistto take the selected photo’s id (keeping in mind flagged photos I guess!) in obs/show and use it to pass on toTaxonAutocompleteas a part ofvisionParamsprop.Testing
I extended the existing integration test in the v2 section to test calling the endpoint with the new param (there is already an existing test without the
photo_idparam). I ran computervision specific tests and they were fine.Alternatives considered
I did think about just switching the api call in
inaturalistto use thescore_imageendpoint, and adding the additional context manually (like lat, long, observed_on… this seems to be what the observation uploader does [Is this what iNat next is doing too?]), but it looks like the score_image endpoint accepts image bytes, and it does not make sense to me to constantly send the image bytes over the api, especially if people might be switching between the photos to check for different cv suggestions. It makes more sense to me to just reference the photo by id and have the server handle photo fetching / context setting in this case.If iNat expects to support multiple photos to get a combined score in the near term, I do question if this new query param might make things tougher for that but I suppose that’s up for discussion in this PR. Perhaps that will just be a new endpoint if ever implemented!