Transformer.js
#2
by
ninini1
- opened
Hello,
Thank you for your work. Do you think you can make the model usable in javascript with transformer.js or any other way?
<script type="module">
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.1.0';
document.getElementById('runModel').addEventListener('click', async () => {
const fileInput = document.getElementById('imageInput');
if (fileInput.files.length === 0) {
alert('Veuillez sélectionner une image.');
return;
}
const imageFile = fileInput.files[0];
const imageBitmap = await createImageBitmap(imageFile);
const classifier = await pipeline('image-classification', 'umm-maybe/AI-image-detector');
const results = await classifier(imageBitmap);
document.getElementById('outputText').innerText = `Résultat : ${JSON.stringify(results, null, 2)}`;
});
</script>
Results in
Uncaught (in promise) Error: Could not locate file: "https://huggingface.co/umm-maybe/AI-image-detector/resolve/main/onnx/model_quantized.onnx".
Thank you!
Hi there, unfortunately I have had a bit of an adversarial relationship with JavaScript throughout my career, so I can't directly assist. But I approved the pull request to add an ONNX version of the checkpoint. Hopefully that helps!
umm-maybe
changed discussion status to
closed