Skip to content

Add support to image-to-video task for inference #1471

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

apolinario
Copy link
Contributor

Internal discussion

The goal is:

  • Keep inputs similar to image-to-image
  • Keep outputs similar to text-to-video
  • For now super generic about.md
  • data.ts for the /tasks on huggingface.co is pending merging this PR

@apolinario apolinario changed the title Add support to image-to-video task Add support to image-to-video task for inference May 21, 2025
Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Thanks @apolinario ! Pretty solid PR already :) I've made some high-level comments while you are still working on it. I do think it's best to split the PR into 2 (one for spec definition, one for proper implementation for each provider).

@@ -266,6 +268,11 @@ const prepareImageToImageInput = (model: ModelDataMinimal): object => {
return { inputs: data.image, parameters: { prompt: data.prompt } };
};

const prepareImageToVideoInput = (model: ModelDataMinimal): object => {
const data = JSON.parse(getModelInputSnippet(model) as string);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a simple example in https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/snippets/inputs.ts ? Something like this:

const inputsImageToVideo = () => `{
    "image": "cat.png",
    "prompt": "Make the cat dance."
}`;

and then

    "image-to-video": inputsImageToVideo,

in the modelInputSnippets mapping.

This way, const data = JSON.parse(getModelInputSnippet(model) as string); will return a valid payload to generate the inference snippets.

@@ -0,0 +1,23 @@
import type { ImageToVideoInput } from "@huggingface/tasks";
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not add this file yet and wait for a follow-up PR. The current implementation assumes it works with FalAI and Replicate which is not the case yet -and not tested-. Better to separate them and keep this PR for specs definition only.

@apolinario apolinario marked this pull request as ready for review May 21, 2025 09:01
@apolinario
Copy link
Contributor Author

Thanks @Wauplin ! I've kept it strictly spec-based for now and applied your suggestion for snippets/inputs.ts

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Let's wait for another review, especially for the about.md/data.ts part which I know less about

Copy link
Contributor

@merveenoyan merveenoyan left a comment

Choose a reason for hiding this comment

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

thanks a lot 💗

@apolinario
Copy link
Contributor Author

Thanks merve, applied your suggestions!

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.

Approving in principle - deferring to @merveenoyan re: data.ts

I will review the inference client implementation more thoroughly :)

Copy link
Contributor

@merveenoyan merveenoyan left a comment

Choose a reason for hiding this comment

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

LGTM :)

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.

4 participants