Skip to content

[Feature request] Code examples for each pipeline in the docs #134

Closed
@josephrocca

Description

@josephrocca

Reason for request

I've spent the last 15 minutes trying to find out how to use the zero-shot-image-classification, and have come to the conclusion that there should be simple example snippets for each pipeline. This is probably already on the roadmap, but there wasn't an issue for it so I'm adding this just in case.

I think the best way to do this would be to add another column to the "Supported tasks/models" table which links to a simple "getting started" code snippet for each task. There would ideally be a list of Hugging Face models that are supported too.

Additional context

This is likely not necessary, but regarding my specific search, just to give you some perspective (on the user experience of a 1x developer 😅), I first found this via the Supported tasks/models, but this gives a Python example:

image

I wasn't sure how to pass in the images (e.g. url vs blob), or how the named parameters maps to transformers.js's style (my default assumption is that all python named parameters should be within an object/POJO as the final parameter, after the positional parameters).

So then I thought - ah, I'll just go to the web demo and inspect the code, but I couldn't find a link to the web demo in the github anymore (can this be added back?). While Googling about I did manage to find this example of zero-shot text classification, which was helpful.

So I eventually managed to find this page:

image

But the ._call(images, candidate_labels, options) is not clickable, so I'm still not sure what the images array (I assume it's an array) should contain.

My next step is to guess (try blob, url), otherwise I'll dig into the code here on github. Edit: So, it does indeed take a URL, so long as CORS headers allow, of course.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions