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

Add image-feature-extraction task to transformers and timm lib->task mapping #1120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rwightman
Copy link
Contributor

@rwightman rwightman commented Jan 20, 2025

There's no pipeline snippet for models w/ the image-feature-extraction task, probably because this mapping is missing?

cc @pcuenca re slack comment

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

The intent here is to enable the pipeline snippet in the "Use this model" button, and I think it'll work for that purpose. However, I'm not sure whether this will attempt to show an inference widget as well, along with the curl / js snippets. What do you think @SBrandeis?

The image-feature-extraction task is supported for inference here, but not here. The following curl command hence fails with {"error":"image-feature-extraction is not a valid pipeline"}

curl https://api-inference.huggingface.co/models/facebook/dinov2-large \ 
        -X POST \
        --data-binary '@example.jpg' \
        -H "Authorization: Bearer $TOKEN"

Also cc @merveenoyan @NielsRogge

Copy link
Member

@Vaibhavs10 Vaibhavs10 left a comment

Choose a reason for hiding this comment

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

@pcuenca
Copy link
Member

pcuenca commented Jan 21, 2025

for snippets we'd need to add the task here as well AFAIR:

That's for inference snippets / widgets IIUC. For "Use this model", would the current state of the PR work with no impact elsewhere? (i.e., no widget enabled)

@julien-c
Copy link
Member

"Use this model" snippets are defined in https://github.com/huggingface/huggingface.js/blob/44e9e02cee0a3cb9d6e89b329f8c2d60b458e480/packages/tasks/src/model-libraries.ts AFAIK

@pcuenca
Copy link
Member

pcuenca commented Jan 21, 2025

"Use this model" snippets are defined in https://github.com/huggingface/huggingface.js/blob/44e9e02cee0a3cb9d6e89b329f8c2d60b458e480/packages/tasks/src/model-libraries.ts AFAIK

Yes! The issue is that image-feature-extraction models don't have a pipeline snippet because of this condition.

i.e, this is an image-feature-extraction model (AutoModel, but no pipeline snippet)
Screenshot 2025-01-21 at 14 56 23

vs an image-classification one (AutoModel + pipeline snippets):
Screenshot 2025-01-21 at 14 56 45

My concern is whether updating LIBRARY_TASK_MAPPING would have any side effects (i.e., widgets being enabled).

@julien-c
Copy link
Member

worst case we merge and we'll check in prod:)

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.

I think this PR should work. I'm a bit late to party, sorry.

I think adding model-libraries.ts will not matter because it's mostly for third party libraries and already defined for transformers. There are two issues here:

  1. transformers image-feature-extraction models don't have pipeline snippets. transformers models are maintained separately AFAIK
    them having pipeline_tag as image-feature-extraction won't matter either e.g. this one has the tag and also have the model class properly but doesn't have snippet mapped (this PR should solve that).

I have overlooked it, thanks for fixing. I will add other vision tasks in a separate PR.

  1. timm models likewise doesn't have timmwrapper to load with transformers, which I'm surprised because they're inferred from here and TimmWrapper exists there. @rwightman opened another PR for it it seems

@merveenoyan
Copy link
Contributor

enabled the same for VLMs with recently merged image-text-to-text pipeline here

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.

5 participants