Update app.js
Browse files
app.js
CHANGED
|
@@ -44,54 +44,9 @@ async function loadModel() {
|
|
| 44 |
* Set up event listeners
|
| 45 |
*/
|
| 46 |
function setupEventListeners() {
|
| 47 |
-
modelInput.addEventListener('change', handleModelUpload);
|
| 48 |
-
weightsInput.addEventListener('change', handleWeightsUpload);
|
| 49 |
fileInput.addEventListener('change', handleImageUpload);
|
| 50 |
}
|
| 51 |
|
| 52 |
-
/**
|
| 53 |
-
* Handle model JSON file upload
|
| 54 |
-
*/
|
| 55 |
-
async function handleModelUpload(event) {
|
| 56 |
-
const file = event.target.files[0];
|
| 57 |
-
if (!file) return;
|
| 58 |
-
|
| 59 |
-
try {
|
| 60 |
-
const text = await file.text();
|
| 61 |
-
const json = JSON.parse(text);
|
| 62 |
-
modelFiles.json = text;
|
| 63 |
-
updateStatus('📄 Model JSON loaded. Now upload the weight files (.bin)', 'processing');
|
| 64 |
-
checkModelFiles();
|
| 65 |
-
} catch (error) {
|
| 66 |
-
updateStatus('❌ Error reading model JSON: ' + error.message, 'error');
|
| 67 |
-
}
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
/**
|
| 71 |
-
* Handle weight files upload
|
| 72 |
-
*/
|
| 73 |
-
async function handleWeightsUpload(event) {
|
| 74 |
-
const files = Array.from(event.target.files);
|
| 75 |
-
if (files.length === 0) return;
|
| 76 |
-
|
| 77 |
-
try {
|
| 78 |
-
modelFiles.weights = files;
|
| 79 |
-
updateStatus(`⚖️ ${files.length} weight files loaded. Processing...`, 'processing');
|
| 80 |
-
checkModelFiles();
|
| 81 |
-
} catch (error) {
|
| 82 |
-
updateStatus('❌ Error reading weight files: ' + error.message, 'error');
|
| 83 |
-
}
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
/**
|
| 87 |
-
* Check if all model files are ready and load the model
|
| 88 |
-
*/
|
| 89 |
-
function checkModelFiles() {
|
| 90 |
-
if (modelFiles.json && modelFiles.weights && modelFiles.weights.length > 0) {
|
| 91 |
-
loadModelFromFiles();
|
| 92 |
-
}
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
/**
|
| 96 |
* Handle image upload and processing
|
| 97 |
*/
|
|
|
|
| 44 |
* Set up event listeners
|
| 45 |
*/
|
| 46 |
function setupEventListeners() {
|
|
|
|
|
|
|
| 47 |
fileInput.addEventListener('change', handleImageUpload);
|
| 48 |
}
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
/**
|
| 51 |
* Handle image upload and processing
|
| 52 |
*/
|