Xenova HF staff commited on
Commit
1232fc2
1 Parent(s): 68bd058

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md CHANGED
@@ -4,4 +4,50 @@ library_name: transformers.js
4
 
5
  https://huggingface.co/caidas/swin2SR-realworld-sr-x4-64-bsrgan-psnr with ONNX weights to be compatible with Transformers.js.
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
 
4
 
5
  https://huggingface.co/caidas/swin2SR-realworld-sr-x4-64-bsrgan-psnr with ONNX weights to be compatible with Transformers.js.
6
 
7
+ ## Usage (Transformers.js)
8
+
9
+ If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@xenova/transformers) using:
10
+ ```bash
11
+ npm i @xenova/transformers
12
+ ```
13
+
14
+ **Example:** Upscale an image with `Xenova/swin2SR-realworld-sr-x4-64-bsrgan-psnr`.
15
+ ```js
16
+ import { pipeline } from '@xenova/transformers';
17
+
18
+ // Create image-to-image pipeline
19
+ const upscaler = await pipeline('image-to-image', 'Xenova/swin2SR-realworld-sr-x4-64-bsrgan-psnr', {
20
+ // quantized: false, // Uncomment this line to use the quantized version
21
+ });
22
+
23
+ // Upscale an image
24
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/butterfly.jpg';
25
+ const output = await upscaler(url);
26
+ // RawImage {
27
+ // data: Uint8Array(3145728) [ ... ],
28
+ // width: 1024,
29
+ // height: 1024,
30
+ // channels: 3
31
+ // }
32
+
33
+ // (Optional) Save the upscaled image
34
+ output.save('upscaled.png');
35
+ ```
36
+
37
+ <details>
38
+ <summary>See example output</summary>
39
+
40
+ Input image:
41
+
42
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/eqLyvsErNQvXAFDD2MylF.png)
43
+
44
+
45
+ Output image:
46
+
47
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/_yYB-1NRfobL2wWMIcy3k.png)
48
+
49
+ </details>
50
+
51
+ ---
52
+
53
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).