Ibm-granite-4.0 / index.html
Javedalam's picture
Create index.html
a703e60 verified
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Granite ONNX Loader</title>
</head>
<body>
<h3>Granite 4.0-micro-ONNX-web Test</h3>
<button id="run">Load Model</button>
<div id="log" style="margin-top:10px;font-family:monospace;white-space:pre-wrap;"></div>
<script type="module">
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@4";
const log = document.getElementById("log");
const btn = document.getElementById("run");
const append = (msg) => { log.textContent += msg + "\n"; };
btn.onclick = async () => {
log.textContent = "";
append("Starting…");
try {
append("Downloading model: onnx-community/granite-4.0-micro-ONNX-web");
const pipe = await pipeline(
"text-generation",
"onnx-community/granite-4.0-micro-ONNX-web",
{ progress_callback: (p) => append(`Progress: ${p * 100}%`) }
);
append("Model ready. Running inference…");
const out = await pipe("The future of AI is", { max_new_tokens: 30 });
append("Output:\n" + out[0].generated_text);
} catch (e) {
append("ERROR: " + (e.message || e));
}
};
</script>
</body>
</html>