AI Model Quantizer

AI Model Quantizer

Enter model parameters, select quantization type, and estimate quantized model metrics.

Quantization Type: ${quantizationTypeDisplay}

Expected Accuracy Loss: ${accuracyLoss.toFixed(2)}%

Quantized Model Size: ${quantizedSize.toFixed(1)} MB

Compression Ratio: ${compressionRatio.toFixed(2)}x

Estimated Inference Speedup: ${estimatedInferenceSpeedup.toFixed(2)}x

`; resultSection.innerHTML = resultText; resultSection.style.display = 'block'; pdfButton.disabled = false; }; const downloadPDF = () => { if (!currentResults.quantizationType || !resultSection.innerText) { errorMessage.textContent = 'No results available to download.'; errorMessage.style.display = 'block'; return; } try { const { jsPDF } = window.jspdf; if (!jsPDF) { console.error('jsPDF is not loaded.'); errorMessage.textContent = 'PDF generation failed. Please try again.'; errorMessage.style.display = 'block'; return; } const doc = new jsPDF(); doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.text('AI Model Quantizer', 20, 20); doc.setLineWidth(0.5); doc.line(20, 25, 190, 25); doc.setFont('helvetica', 'normal'); doc.setFontSize(12); doc.text(`Original Model Size: ${currentResults.modelSize.toFixed(1)} MB`, 20, 40); doc.text(`Original Precision: ${currentResults.originalPrecision.toFixed(0)} bits`, 20, 50); doc.text(`Quantization Type: ${currentResults.quantizationType.toUpperCase()}`, 20, 60); doc.text(`Expected Accuracy Loss: ${currentResults.accuracyLoss.toFixed(2)}%`, 20, 70); doc.text(`Quantized Model Size: ${currentResults.quantizedSize.toFixed(1)} MB`, 20, 80); doc.text(`Compression Ratio: ${currentResults.compressionRatio.toFixed(2)}x`, 20, 90); doc.text(`Estimated Inference Speedup: ${currentResults.estimatedInferenceSpeedup.toFixed(2)}x`, 20, 100); doc.setDrawColor(200); doc.rect(15, 35, 180, 70); doc.save('model_quantization.pdf'); } catch (error) { console.error('PDF generation error:', error); errorMessage.textContent = 'Failed to generate PDF. Please try again.'; errorMessage.style.display = 'block'; } }; const resetForm = () => { converterForm.reset(); resultSection.innerHTML = ''; resultSection.style.display = 'none'; errorMessage.style.display = 'none'; pdfButton.disabled = true; currentResults = { modelSize: 0, originalPrecision: 0, quantizationType: '', accuracyLoss: 0, quantizedSize: 0, compressionRatio: 0, estimatedInferenceSpeedup: 0 }; modelSizeInput.focus(); }; convertButton.addEventListener('click', calculateQuantizedMetrics); resetButton.addEventListener('click', resetForm); pdfButton.addEventListener('click', downloadPDF); converterForm.addEventListener('submit', (e) => { e.preventDefault(); calculateQuantizedMetrics(); }); }); })();
Scroll to Top