Commit
·
bd48828
0
Parent(s):
Duplicate from multimodalart/upload_to_hub
Browse files- .gitattributes +35 -0
- README.md +12 -0
- index.html +98 -0
- style.css +28 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Upload To Hub
|
3 |
+
emoji: 🦀
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: gray
|
6 |
+
sdk: static
|
7 |
+
pinned: false
|
8 |
+
license: mit
|
9 |
+
duplicated_from: multimodalart/upload_to_hub
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<style>
|
5 |
+
body {
|
6 |
+
font-family: Arial, sans-serif;
|
7 |
+
}
|
8 |
+
input, button, progress {
|
9 |
+
display: block;
|
10 |
+
margin-top: 10px;
|
11 |
+
}
|
12 |
+
#message {
|
13 |
+
margin-top: 20px;
|
14 |
+
color: blue;
|
15 |
+
}
|
16 |
+
#error {
|
17 |
+
color: red;
|
18 |
+
}
|
19 |
+
</style>
|
20 |
+
</head>
|
21 |
+
<body>
|
22 |
+
<label for="tokenInput">Hugging Face Token:</label>
|
23 |
+
<input type="password" id="tokenInput" name="tokenInput">
|
24 |
+
<label for="repoInput">Repository ID:</label>
|
25 |
+
<input type="text" id="repoInput" name="repoInput" placeholder="my-user/nlp-model">
|
26 |
+
<input type="file" id="fileUpload" multiple>
|
27 |
+
<button id="uploadButton">Upload Files</button>
|
28 |
+
<div id="processingMessage"></div>
|
29 |
+
<progress id="progressBar" value="0" max="100"></progress>
|
30 |
+
<div id="message"></div>
|
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 |
+
class FileUploader {
|
37 |
+
constructor() {
|
38 |
+
this.uploadButton = document.getElementById('uploadButton');
|
39 |
+
this.uploadButton.addEventListener('click', () => this.upload());
|
40 |
+
}
|
41 |
+
|
42 |
+
async upload() {
|
43 |
+
const fileInput = document.getElementById('fileUpload');
|
44 |
+
const files = Array.from(fileInput.files);
|
45 |
+
const tokenInput = document.getElementById('tokenInput');
|
46 |
+
const HF_ACCESS_TOKEN = tokenInput.value;
|
47 |
+
const repoInput = document.getElementById('repoInput');
|
48 |
+
const REPO_ID = repoInput.value;
|
49 |
+
const progressBar = document.getElementById('progressBar');
|
50 |
+
const messageDiv = document.getElementById('message');
|
51 |
+
const errorDiv = document.getElementById('error');
|
52 |
+
const processingMessage = document.getElementById('processingMessage');
|
53 |
+
|
54 |
+
progressBar.value = 0;
|
55 |
+
messageDiv.textContent = '';
|
56 |
+
errorDiv.textContent = '';
|
57 |
+
processingMessage.textContent = '';
|
58 |
+
|
59 |
+
if (files.length > 0) {
|
60 |
+
const totalSize = files.reduce((total, file) => total + file.size, 0) / (1024 * 1024);
|
61 |
+
const startTime = Date.now();
|
62 |
+
|
63 |
+
try {
|
64 |
+
await createRepo({ repo: REPO_ID, credentials: { accessToken: HF_ACCESS_TOKEN } });
|
65 |
+
} catch (error) {
|
66 |
+
if (error.message !== 'You already created this model repo') {
|
67 |
+
console.error('Error creating repository', error);
|
68 |
+
errorDiv.textContent = 'Error creating repository';
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
console.log('Repository already exists, proceeding to upload files');
|
72 |
+
}
|
73 |
+
|
74 |
+
try {
|
75 |
+
await uploadFiles({ repo: REPO_ID, credentials: { accessToken: HF_ACCESS_TOKEN }, files: files.map(file => ({ path: file.name, content: file })) });
|
76 |
+
console.log('All files uploaded successfully');
|
77 |
+
progressBar.value = 100;
|
78 |
+
} catch (error) {
|
79 |
+
console.error('Error uploading files', error);
|
80 |
+
errorDiv.textContent = 'Error uploading files';
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
const elapsedTime = (Date.now() - startTime) / 1000;
|
85 |
+
const speed = totalSize / elapsedTime;
|
86 |
+
|
87 |
+
messageDiv.textContent = `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.`;
|
88 |
+
processingMessage.textContent = "All files processed";
|
89 |
+
} else {
|
90 |
+
messageDiv.textContent = 'Please select files to upload';
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
new FileUploader();
|
96 |
+
</script>
|
97 |
+
</body>
|
98 |
+
</html>
|
style.css
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
padding: 2rem;
|
3 |
+
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
4 |
+
}
|
5 |
+
|
6 |
+
h1 {
|
7 |
+
font-size: 16px;
|
8 |
+
margin-top: 0;
|
9 |
+
}
|
10 |
+
|
11 |
+
p {
|
12 |
+
color: rgb(107, 114, 128);
|
13 |
+
font-size: 15px;
|
14 |
+
margin-bottom: 10px;
|
15 |
+
margin-top: 5px;
|
16 |
+
}
|
17 |
+
|
18 |
+
.card {
|
19 |
+
max-width: 620px;
|
20 |
+
margin: 0 auto;
|
21 |
+
padding: 16px;
|
22 |
+
border: 1px solid lightgray;
|
23 |
+
border-radius: 16px;
|
24 |
+
}
|
25 |
+
|
26 |
+
.card p:last-child {
|
27 |
+
margin-bottom: 0;
|
28 |
+
}
|