multimodalart HF staff commited on
Commit
3e75ed6
·
1 Parent(s): 2448fe7

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +18 -23
index.html CHANGED
@@ -31,12 +31,12 @@
31
  <div id="error"></div>
32
 
33
  <script type="module">
34
- import { createRepo, uploadFile } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
35
 
36
  const uploadButton = document.getElementById('uploadButton');
37
- uploadButton.addEventListener('click', uploadFiles);
38
 
39
- async function uploadFiles() {
40
  const fileInput = document.getElementById('fileUpload');
41
  const files = Array.from(fileInput.files); // convert FileList to Array
42
  const tokenInput = document.getElementById('tokenInput');
@@ -80,27 +80,22 @@
80
  }
81
  }
82
 
83
- for (let i = 0; i < files.length; i++) {
84
- const file = files[i];
85
- processingMessage.textContent = `Processing your file ${i+1}/${files.length}...`;
86
- try {
87
- // upload file
88
- await uploadFile({
89
- repo: REPO_ID,
90
- credentials: { accessToken: HF_ACCESS_TOKEN },
91
- file: file,
92
- commitTitle: `committing file: ${file.name}`,
93
- });
94
 
95
- console.log(`File ${file.name} uploaded successfully`);
96
 
97
- // update progress bar
98
- progressBar.value = ((i + 1) / files.length) * 100;
99
- } catch (error) {
100
- console.error('Error uploading file', error);
101
- errorDiv.textContent = 'Error uploading file';
102
- return; // stop uploading further files on error
103
- }
104
  }
105
 
106
  // calculate elapsed time and speed
@@ -112,7 +107,7 @@
112
  let time5GB = (5 * 1024 / speed) / 60;
113
  let time10GB = (10 * 1024 / speed) / 60;
114
 
115
- messageDiv.innerHTML = `All files uploaded successfully in ${elapsedTime.toFixed(2)} seconds, for all ${totalSize.toFixed(2)} MB in the ${files.length} files, speed ${speed.toFixed(2)} MB/s.<br>To upload a 1GB model at this speed, it would take approximately ${time1GB.toFixed(2)} minutes.<br>To upload a 5GB model at this speed, it would take approximately ${time5GB.toFixed(2)} minutes.<br>To upload a 10GB model at this speed, it would take approximately ${time10GB.toFixed(2)} minutes.`;
116
  processingMessage.textContent = "All files processed";
117
  } else {
118
  messageDiv.textContent = 'Please select files to upload';
 
31
  <div id="error"></div>
32
 
33
  <script type="module">
34
+ import { createRepo, uploadFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
35
 
36
  const uploadButton = document.getElementById('uploadButton');
37
+ uploadButton.addEventListener('click', upload);
38
 
39
+ async function upload() {
40
  const fileInput = document.getElementById('fileUpload');
41
  const files = Array.from(fileInput.files); // convert FileList to Array
42
  const tokenInput = document.getElementById('tokenInput');
 
80
  }
81
  }
82
 
83
+ try {
84
+ // upload files
85
+ await uploadFiles({
86
+ repo: REPO_ID,
87
+ credentials: { accessToken: HF_ACCESS_TOKEN },
88
+ files: files.map(file => ({path: file.name, content: file}))
89
+ });
 
 
 
 
90
 
91
+ console.log(`All files uploaded successfully`);
92
 
93
+ // update progress bar
94
+ progressBar.value = 100;
95
+ } catch (error) {
96
+ console.error('Error uploading files', error);
97
+ errorDiv.textContent = 'Error uploading files';
98
+ return; // stop uploading further files on error
 
99
  }
100
 
101
  // calculate elapsed time and speed
 
107
  let time5GB = (5 * 1024 / speed) / 60;
108
  let time10GB = (10 * 1024 / speed) / 60;
109
 
110
+ messageDiv.innerHTML = `All files uploaded successfully in ${elapsedTime.toFixed(2)} seconds, for all ${totalSize.toFixed(2)} MB in the ${files.length} files, speed ${speed.toFixed(2)} MB/s.`;
111
  processingMessage.textContent = "All files processed";
112
  } else {
113
  messageDiv.textContent = 'Please select files to upload';