| 1337 | |
| 1338 | // `loading`: we have finished downloading (or already cacheOnly) and are loading onto WebGPU |
| 1339 | const reportCallback = (iter: number, loading = false) => { |
| 1340 | // report |
| 1341 | for (let j = 0; j < this.initProgressCallback.length; ++j) { |
| 1342 | let text: string; |
| 1343 | if (loading) { |
| 1344 | text = "Loading model from cache[" + iter + "/" + list.length + "]: "; |
| 1345 | text += Math.ceil(fetchedBytes / (1024 * 1024)).toString() + "MB loaded. " |
| 1346 | text += Math.floor(fetchedBytes * 100 / totalBytes).toString() + "% completed, " |
| 1347 | text += timeElapsed + " secs elapsed."; |
| 1348 | } else { |
| 1349 | text = "Fetching param cache[" + iter + "/" + list.length + "]: "; |
| 1350 | text += Math.ceil(fetchedBytes / (1024 * 1024)).toString() + "MB fetched. " |
| 1351 | text += Math.floor(fetchedBytes * 100 / totalBytes).toString() + "% completed, " |
| 1352 | text += timeElapsed + " secs elapsed."; |
| 1353 | text += " It can take a while when we first visit this page to populate the cache." |
| 1354 | text += " Later refreshes will become faster."; |
| 1355 | } |
| 1356 | this.initProgressCallback[j]({ |
| 1357 | progress: fetchedBytes / totalBytes, |
| 1358 | timeElapsed: timeElapsed, |
| 1359 | text: text |
| 1360 | }); |
| 1361 | } |
| 1362 | }; |
| 1363 | |
| 1364 | for (let j = 0; j < this.initProgressCallback.length; ++j) { |
| 1365 | this.initProgressCallback[j]({ |