Skip to content

Commit 2402f72

Browse files
author
machineuser
committed
🔖 @hugginface/inference v1.8.0
1 parent c601145 commit 2402f72

File tree

9 files changed

+98
-34
lines changed

9 files changed

+98
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or
4848
```html
4949

5050
<script type="module">
51-
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@1.7.1/+esm';
51+
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@1.8.0/+esm';
5252
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
5353
</script>
5454
```

docs/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
local: inference/interfaces/ImageClassificationReturnValue
8181
- title: ImageSegmentationReturnValue
8282
local: inference/interfaces/ImageSegmentationReturnValue
83+
- title: ImageToTextReturn
84+
local: inference/interfaces/ImageToTextReturn
8385
- title: ObjectDetectionReturnValue
8486
local: inference/interfaces/ObjectDetectionReturnValue
8587
- title: Options

docs/index.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or
4848
```html
4949

5050
<script type="module">
51-
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@1.7.1/+esm';
51+
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@1.8.0/+esm';
5252
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
5353
</script>
5454
```
@@ -92,8 +92,15 @@ await inference.translation({
9292

9393
await inference.textToImage({
9494
inputs: 'award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]',
95-
negative_prompt: 'blurry',
9695
model: 'stabilityai/stable-diffusion-2',
96+
parameters: {
97+
negative_prompt: 'blurry',
98+
}
99+
})
100+
101+
await inference.imageToText({
102+
data: await (await fetch('https://picsum.photos/300/300')).blob(),
103+
model: 'nlpconnect/vit-gpt2-image-captioning',
97104
})
98105
```
99106

docs/inference/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pnpm add @huggingface/inference
1414

1515
## Usage
1616

17-
**Important note:** Using an API key is optional to get started, however you will be rate limited eventually. Join [Hugging Face](https://huggingface.co/join) and then visit [access tokens](https://huggingface.co/settings/tokens) to generate your API key for **free**.
17+
**Important note:** Using an API key is optional to get started, however you will be rate limited eventually. Join [Hugging Face](https://huggingface.co/join) and then visit [access tokens](https://huggingface.co/settings/tokens) to generate your API key for **free**.
1818

1919
Your API key should be kept private. If you need to protect it in front-end applications, we suggest setting up a proxy server that stores the API key.
2020

@@ -150,8 +150,15 @@ await hf.imageSegmentation({
150150

151151
await hf.textToImage({
152152
inputs: 'award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]',
153-
negative_prompt: 'blurry',
154153
model: 'stabilityai/stable-diffusion-2',
154+
parameters: {
155+
negative_prompt: 'blurry',
156+
}
157+
})
158+
159+
await hf.imageToText({
160+
data: readFileSync('test/cats.png'),
161+
model: 'nlpconnect/vit-gpt2-image-captioning'
155162
})
156163
```
157164

@@ -184,6 +191,7 @@ await hf.textToImage({
184191
- [x] Object detection
185192
- [x] Image segmentation
186193
- [x] Text to image
194+
- [x] Image to text
187195

188196
## Running tests
189197

docs/inference/classes/HfInference.md

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#### Defined in
1717

18-
[HfInference.ts:597](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L597)
18+
[HfInference.ts:629](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L629)
1919

2020
## Properties
2121

@@ -25,7 +25,7 @@
2525

2626
#### Defined in
2727

28-
[HfInference.ts:594](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L594)
28+
[HfInference.ts:626](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L626)
2929

3030
___
3131

@@ -35,7 +35,7 @@ ___
3535

3636
#### Defined in
3737

38-
[HfInference.ts:595](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L595)
38+
[HfInference.ts:627](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L627)
3939

4040
## Methods
4141

@@ -59,7 +59,7 @@ Recommended model: superb/hubert-large-superb-er
5959

6060
#### Defined in
6161

62-
[HfInference.ts:831](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L831)
62+
[HfInference.ts:863](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L863)
6363

6464
___
6565

@@ -83,7 +83,7 @@ Recommended model (english language): facebook/wav2vec2-large-960h-lv60-self
8383

8484
#### Defined in
8585

86-
[HfInference.ts:812](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L812)
86+
[HfInference.ts:844](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L844)
8787

8888
___
8989

@@ -106,7 +106,7 @@ This task corresponds to any chatbot like structure. Models tend to have shorter
106106

107107
#### Defined in
108108

109-
[HfInference.ts:782](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L782)
109+
[HfInference.ts:814](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L814)
110110

111111
___
112112

@@ -129,7 +129,7 @@ This task reads some text and outputs raw float values, that are usually consume
129129

130130
#### Defined in
131131

132-
[HfInference.ts:803](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L803)
132+
[HfInference.ts:835](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L835)
133133

134134
___
135135

@@ -152,7 +152,7 @@ Tries to fill in a hole with a missing word (token to be precise). That’s the
152152

153153
#### Defined in
154154

155-
[HfInference.ts:605](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L605)
155+
[HfInference.ts:637](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L637)
156156

157157
___
158158

@@ -176,7 +176,7 @@ Recommended model: google/vit-base-patch16-224
176176

177177
#### Defined in
178178

179-
[HfInference.ts:851](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L851)
179+
[HfInference.ts:883](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L883)
180180

181181
___
182182

@@ -200,7 +200,30 @@ Recommended model: facebook/detr-resnet-50-panoptic
200200

201201
#### Defined in
202202

203-
[HfInference.ts:899](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L899)
203+
[HfInference.ts:931](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L931)
204+
205+
___
206+
207+
### imageToText
208+
209+
**imageToText**(`args`, `options?`): `Promise`<[`ImageToTextReturn`](../interfaces/ImageToTextReturn)\>
210+
211+
This task reads some image input and outputs the text caption.
212+
213+
#### Parameters
214+
215+
| Name | Type |
216+
| :------ | :------ |
217+
| `args` | [`ImageToTextArgs`](../modules#imagetotextargs) |
218+
| `options?` | [`Options`](../interfaces/Options) |
219+
220+
#### Returns
221+
222+
`Promise`<[`ImageToTextReturn`](../interfaces/ImageToTextReturn)\>
223+
224+
#### Defined in
225+
226+
[HfInference.ts:966](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L966)
204227

205228
___
206229

@@ -237,7 +260,7 @@ Helper that prepares request arguments
237260

238261
#### Defined in
239262

240-
[HfInference.ts:934](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L934)
263+
[HfInference.ts:978](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L978)
241264

242265
___
243266

@@ -261,7 +284,7 @@ Recommended model: facebook/detr-resnet-50
261284

262285
#### Defined in
263286

264-
[HfInference.ts:871](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L871)
287+
[HfInference.ts:903](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L903)
265288

266289
___
267290

@@ -284,7 +307,7 @@ Want to have a nice know-it-all bot that can answer any question?. Recommended m
284307

285308
#### Defined in
286309

287-
[HfInference.ts:639](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L639)
310+
[HfInference.ts:671](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L671)
288311

289312
___
290313

@@ -311,7 +334,7 @@ ___
311334

312335
#### Defined in
313336

314-
[HfInference.ts:986](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L986)
337+
[HfInference.ts:1030](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L1030)
315338

316339
___
317340

@@ -340,7 +363,7 @@ Make request that uses server-sent events and returns response as a generator
340363

341364
#### Defined in
342365

343-
[HfInference.ts:1022](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L1022)
366+
[HfInference.ts:1066](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L1066)
344367

345368
___
346369

@@ -363,7 +386,7 @@ This task is well known to summarize longer text into shorter text. Be careful,
363386

364387
#### Defined in
365388

366-
[HfInference.ts:627](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L627)
389+
[HfInference.ts:659](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L659)
367390

368391
___
369392

@@ -386,7 +409,7 @@ Don’t know SQL? Don’t want to dive into a large spreadsheet? Ask questions i
386409

387410
#### Defined in
388411

389-
[HfInference.ts:657](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L657)
412+
[HfInference.ts:689](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L689)
390413

391414
___
392415

@@ -409,7 +432,7 @@ Usually used for sentiment-analysis this will output the likelihood of classes o
409432

410433
#### Defined in
411434

412-
[HfInference.ts:680](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L680)
435+
[HfInference.ts:712](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L712)
413436

414437
___
415438

@@ -432,7 +455,7 @@ Use to continue text from a prompt. This is a very generic task. Recommended mod
432455

433456
#### Defined in
434457

435-
[HfInference.ts:693](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L693)
458+
[HfInference.ts:725](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L725)
436459

437460
___
438461

@@ -455,7 +478,7 @@ Use to continue text from a prompt. Same as `textGeneration` but returns generat
455478

456479
#### Defined in
457480

458-
[HfInference.ts:705](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L705)
481+
[HfInference.ts:737](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L737)
459482

460483
___
461484

@@ -479,7 +502,7 @@ Recommended model: stabilityai/stable-diffusion-2
479502

480503
#### Defined in
481504

482-
[HfInference.ts:919](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L919)
505+
[HfInference.ts:951](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L951)
483506

484507
___
485508

@@ -502,7 +525,7 @@ Usually used for sentence parsing, either grammatical, or Named Entity Recogniti
502525

503526
#### Defined in
504527

505-
[HfInference.ts:715](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L715)
528+
[HfInference.ts:747](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L747)
506529

507530
___
508531

@@ -525,7 +548,7 @@ This task is well known to translate text from one language to another. Recommen
525548

526549
#### Defined in
527550

528-
[HfInference.ts:741](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L741)
551+
[HfInference.ts:773](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L773)
529552

530553
___
531554

@@ -548,4 +571,4 @@ This task is super useful to try out classification with zero code, you simply p
548571

549572
#### Defined in
550573

551-
[HfInference.ts:753](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L753)
574+
[HfInference.ts:785](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L785)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Interface: ImageToTextReturn
2+
3+
## Properties
4+
5+
### generated\_text
6+
7+
**generated\_text**: `string`
8+
9+
The generated caption
10+
11+
#### Defined in
12+
13+
[HfInference.ts:622](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L622)

docs/inference/interfaces/TextGenerationStreamReturn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### details
66

7-
`Optional` **details**: [`TextGenerationStreamDetails`](TextGenerationStreamDetails)
7+
**details**: ``null`` \| [`TextGenerationStreamDetails`](TextGenerationStreamDetails)
88

99
Generation details
1010
Only available when the generation is finished
@@ -17,7 +17,7 @@ ___
1717

1818
### generated\_text
1919

20-
`Optional` **generated\_text**: `string`
20+
**generated\_text**: ``null`` \| `string`
2121

2222
Complete generated text
2323
Only available when the generation is finished

docs/inference/modules.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [ConversationalReturn](interfaces/ConversationalReturn)
1717
- [ImageClassificationReturnValue](interfaces/ImageClassificationReturnValue)
1818
- [ImageSegmentationReturnValue](interfaces/ImageSegmentationReturnValue)
19+
- [ImageToTextReturn](interfaces/ImageToTextReturn)
1920
- [ObjectDetectionReturnValue](interfaces/ObjectDetectionReturnValue)
2021
- [Options](interfaces/Options)
2122
- [QuestionAnswerReturn](interfaces/QuestionAnswerReturn)
@@ -155,6 +156,16 @@ ___
155156

156157
___
157158

159+
### ImageToTextArgs
160+
161+
Ƭ **ImageToTextArgs**: [`Args`](interfaces/Args) & { `data`: `Blob` \| `ArrayBuffer` }
162+
163+
#### Defined in
164+
165+
[HfInference.ts:611](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L611)
166+
167+
___
168+
158169
### ObjectDetectionArgs
159170

160171
Ƭ **ObjectDetectionArgs**: [`Args`](interfaces/Args) & { `data`: `Blob` \| `ArrayBuffer` }
@@ -237,7 +248,7 @@ ___
237248

238249
### TextToImageArgs
239250

240-
Ƭ **TextToImageArgs**: [`Args`](interfaces/Args) & { `inputs`: `string` ; `negative_prompt?`: `string` }
251+
Ƭ **TextToImageArgs**: [`Args`](interfaces/Args) & { `inputs`: `string` ; `parameters?`: { `guidance_scale?`: `number` ; `height?`: `number` ; `negative_prompt?`: `string` ; `num_inference_steps?`: `number` ; `width?`: `number` } }
241252

242253
#### Defined in
243254

@@ -251,7 +262,7 @@ ___
251262

252263
#### Defined in
253264

254-
[HfInference.ts:591](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L591)
265+
[HfInference.ts:609](https://github.com/huggingface/huggingface.js/blob/main/packages/inference/src/HfInference.ts#L609)
255266

256267
___
257268

packages/inference/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/inference",
3-
"version": "1.7.1",
3+
"version": "1.8.0",
44
"license": "MIT",
55
"author": "Tim Mikeladze <[email protected]>",
66
"description": "Typescript wrapper for the Hugging Face Inference API",

0 commit comments

Comments
 (0)