Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Fix HRNet dimension error on images with alpha channel (cvat-ai#5570)
Browse files Browse the repository at this point in the history
This is pretty much the same fix applied to f-BRS in cvat-ai#5384. We've been
using HRNet for a while and now an then we receive "500 errors" just as
reported in cvat-ai#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.
  • Loading branch information
rodrigoberriel authored and mikhail-treskin committed Jul 1, 2023
1 parent 8914c94 commit b95859d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion serverless/pytorch/saic-vul/hrnet/nuclio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b95859d

Please sign in to comment.