Skip to content
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

[Widgets] Don't call api inference if output exists #1063

Merged
merged 2 commits into from
Oct 31, 2023

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Oct 30, 2023

Closes #1011
This PR is continuation of #1017
Follow up to #979

#979 correctly implemented behaviour for the previewInputSample function here. Which is: don't call api-inference if sample.output exists

The same should be the case for applyInputSample (which is this PR). Don't call api-inference if sample.output exists. #1011 happened because api-inference was called and there was no cached example although sample.output was in the repo

Order of merge operations

  1. Merge [Widgets] Refactor examples running #1023
  2. Then merge [Widgets] Don't call api inference if output exists #1063 (this PR)
  3. Then merge [Widgets] Handle display logic #1019

Copy link
Contributor

@SBrandeis SBrandeis left a comment

Choose a reason for hiding this comment

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

The logic is not implemented for most widgets. Is that intended?

async function getOutput({
withModelLoading = false,
isOnLoadCall = false,
exampleOutput = undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

This has no effect in this widget

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, because widgets such as AudioToAudio or ImageSegmentation are not expected to have example.output in their model cards

for example here

function applyInputSample(sample: WidgetExampleAssetInput, opts: ExampleRunOpts = {}) {
, if they were expected to have example.output, the typing would have been sample: WidgetExampleAssetInput<WIDGET OUTPUT TYPE>

docs here for the list of supported output types: https://huggingface.co/docs/hub/models-widgets#example-outputs from #978

@julien-c could you confirm this statement

yes, because widgets such as AudioToAudio or ImageSegmentation are not expected to have example.output in their model cards

Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure i understand, i'm a bit lost...

Copy link
Member

Choose a reason for hiding this comment

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

from the docs (emphasis mine):

each widget example can also optionally describe the corresponding model output, directly in the output property

AudioToAudio or ImageSegmentation should support a file output, i.e. a output.url, same as text-to-image:

image

Copy link
Collaborator Author

@mishig25 mishig25 Oct 31, 2023

Choose a reason for hiding this comment

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

Here is what I meant:

At the current state of widgets, uses can supply output in their modelcard for any widget. However, only subset of widgets will show/use that example output

AudioToAudio or ImageSegmentation should support a file output

But in the current implementation, AudioToAudio or ImageSegmentation do neither validation nor usage of output

Should I open a PR (extend the current PR) to make all the remaining widgets validate and use output ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As we discussed internally, lets merge this PR without the proposed changes above (remaining widgets validate and use output). And iterate in subseq PRs

Copy link
Member

Choose a reason for hiding this comment

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

Should I open a PR (extend the current PR) to make all the remaining widgets validate and use output ?

Yes

Copy link
Member

Choose a reason for hiding this comment

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

that was the goal to support output for all widgets

@mishig25 mishig25 merged commit 0539694 into main Oct 31, 2023
2 checks passed
@mishig25 mishig25 deleted the don_compute_output_exists branch October 31, 2023 09:37
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.

Show static widget output on load
3 participants