Update README.md
Browse files
README.md
CHANGED
|
@@ -67,8 +67,18 @@ print("Predicted class:", model.config.id2label[predicted_class_idx])
|
|
| 67 |
# Predicted class: sfw
|
| 68 |
```
|
| 69 |
|
| 70 |
-
Usage with Transformers.js
|
| 71 |
```js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.1';
|
| 73 |
|
| 74 |
// Since we will download the model from HuggingFace Hub, we can skip the local model check
|
|
|
|
| 67 |
# Predicted class: sfw
|
| 68 |
```
|
| 69 |
|
| 70 |
+
Usage with Transformers.js (Vanilla JS):
|
| 71 |
```js
|
| 72 |
+
/* Instructions:
|
| 73 |
+
* - Place this script in an HTML file using the <script type="module"> tag.
|
| 74 |
+
* - Ensure the HTML file is served over a local or remote server (e.g., using Python's http.server, Node.js server, or similar).
|
| 75 |
+
* - Replace 'https://example.com/path/to/image.jpg' in the classifyImage function call with the URL of the image you want to classify.
|
| 76 |
+
*
|
| 77 |
+
* Example of how to include this script in HTML:
|
| 78 |
+
* <script type="module" src="path/to/this_script.js"></script>
|
| 79 |
+
*
|
| 80 |
+
* This setup ensures that the script can use imports and perform network requests without CORS issues.
|
| 81 |
+
*/
|
| 82 |
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.1';
|
| 83 |
|
| 84 |
// Since we will download the model from HuggingFace Hub, we can skip the local model check
|