Skip to content

fix(hf-inference): image segmentation #1431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged

Conversation

oOraph
Copy link
Contributor

@oOraph oOraph commented May 6, 2025

related: #1430

@oOraph oOraph force-pushed the dev/hf-inference-img-seg branch 3 times, most recently from 1e88330 to 7768e88 Compare May 6, 2025 11:31
response.every((x) => typeof x.label === "string" && typeof x.mask === "string" && typeof x.score === "number")
response.every(
(x) =>
typeof x.label === "string" && typeof x.mask === "string" && (!("score" in x) || typeof x.score === "number")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
typeof x.label === "string" && typeof x.mask === "string" && (!("score" in x) || typeof x.score === "number")
typeof x.label === "string" && typeof x.mask === "string" && (x.score === undefined || typeof x.score === "number")

i think you can just do this (more TS-idiomatic)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just ignore the type checks on score?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah my bad I changed it and erased the change by mistake (push force)
-> done: removed the whole type check on score, as we prefer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm it's better to type check no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the type is score?: number; it's a valid type, we don't want random objects or string, just an optional number

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@oOraph oOraph force-pushed the dev/hf-inference-img-seg branch 4 times, most recently from c9a51fb to e737a5c Compare May 7, 2025 13:00
Array.isArray(response) &&
response.every((x) => typeof x.label === "string" && typeof x.mask === "string" && typeof x.score === "number")
) {
if (Array.isArray(response) && response.every((x) => typeof x.label === "string" && typeof x.mask === "string")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Array.isArray(response) && response.every((x) => typeof x.label === "string" && typeof x.mask === "string")) {
if (Array.isArray(response) && response.every((x) => typeof x.label === "string" && typeof x.mask === "string" && (x.score === undefined || typeof x.score === "number"))) {

@oOraph oOraph force-pushed the dev/hf-inference-img-seg branch from e737a5c to 738bd8e Compare May 9, 2025 08:07
related: #1430

Signed-off-by: Raphael Glon <[email protected]>
@oOraph oOraph force-pushed the dev/hf-inference-img-seg branch from 738bd8e to e972cab Compare May 9, 2025 08:11
@julien-c julien-c merged commit 1dcc11a into main May 9, 2025
5 checks passed
@julien-c julien-c deleted the dev/hf-inference-img-seg branch May 9, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants