Fix HRNet dimension error on images with alpha channel (#5570)

This is pretty much the same fix applied to f-BRS in #5384. We've been
using HRNet for a while and now an then we receive "500 errors" just as
reported in #5299 when someone forgets to drop the alpha-channel from
our images.

### Motivation and context
The RuntimeError is a little bit different, but comes from the same
issue: RGBA instead of RGB images:
> RuntimeError: Given groups=1, weight of size [16, 3, 1, 1], expected
input[*, 4, *, *] to have 3 channels, but got 4 channels instead.

### How has this been tested?
I created a task with images with and w/o alpha channel, and the
interactor works on both now.
main
Rodrigo Berriel 3 years ago committed by GitHub
parent 6c3e3c98a6
commit 43ed0a2e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Helm: Empty password for Redis (<https://github.com/opencv/cvat/pull/5520>)
- Fixed HRNet serverless function runtime error on images with alpha channel (<https://github.com/opencv/cvat/pull/5570>)
- Preview & chunk cache settings are ignored (<https://github.com/opencv/cvat/pull/5569>)
### Security

@ -24,7 +24,7 @@ def handler(context, event):
neg_points = data["neg_points"]
threshold = data.get("threshold", 0.5)
buf = io.BytesIO(base64.b64decode(data["image"]))
image = Image.open(buf)
image = Image.open(buf).convert('RGB')
mask, polygon = context.user_data.model.handle(image, pos_points,
neg_points, threshold)

Loading…
Cancel
Save