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

Generalize inference snippets #106

Merged
merged 4 commits into from
Apr 19, 2022
Merged

Generalize inference snippets #106

merged 4 commits into from
Apr 19, 2022

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Apr 19, 2022

This PR:

  1. Generalizes snippets so that they can support tasks that send file as an input
  2. As an example, I've added snippets for img-cls task
  3. If this PR gets approved, I'll add remaining tasks (such as obj-det, aud-cls, etc.) & it should close Add inference API snippets for non-NLP tasks #50 read more here

Example screenshots of img-cls task (please check whether the snippets look correct: @Narsil @osanseviero ):
Screenshot 2022-04-19 at 13 03 53
Screenshot 2022-04-19 at 13 03 55
Screenshot 2022-04-19 at 13 03 57

@mishig25 mishig25 changed the title Snippet for img-cls task Generalize inference snippets Apr 19, 2022
Copy link

@Narsil Narsil left a comment

Choose a reason for hiding this comment

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

Snippets are good !

@mishig25
Copy link
Collaborator Author

mishig25 commented Apr 19, 2022

for the file path: currently we have cats.jpg

Should it be:

  1. cats.jpg
  2. or ./cats.jpg
  3. or {PATH_TO_IMG_FILE}
  4. or something else?

@Narsil
Copy link

Narsil commented Apr 19, 2022

I think it's ok to leave cats.jpg it's pretty understandable what supposed to be there, and the error messages are also usually pretty explicit (missing file cats.jpg).

Wdyt ?

@beurkinger
Copy link
Contributor

beurkinger commented Apr 19, 2022

Note: you can also easily do away with the regex stuff :)

const inputsImageClassification = (_, noQuotes = false) => noQuotes ? `cats.jpgs` : `"cats.jpg"`;
const modelInputSnippets: {
	[key in PipelineType]?: (model: ModelData, noQuotes: boolean) => string;
} = {
const inputs = modelInputSnippets[model.pipeline_tag];

Not saying this is better, I'll let you judge what's the best solution.

js/src/lib/inferenceSnippets/inputs.ts Outdated Show resolved Hide resolved
js/src/lib/inferenceSnippets/serveCurl.ts Outdated Show resolved Hide resolved
@beurkinger
Copy link
Contributor

beurkinger commented Apr 19, 2022

Looks good ! I only found some admittedly petty comments to make. Still needs to try it live :)

@mishig25 mishig25 merged commit 9cf841d into main Apr 19, 2022
@mishig25 mishig25 deleted the support_img_cls_snippet branch April 19, 2022 14:52
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.

Add inference API snippets for non-NLP tasks
3 participants