Spaces:
Running
Running
Aschen
commited on
Commit
•
f6a76d5
1
Parent(s):
25ea5f1
build js :facepalm:
Browse files- dist/app.js +47 -35
dist/app.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import { createRepo, commit, whoAmI } from "@huggingface/hub";
|
2 |
const c = console;
|
3 |
const FILES_TO_UPLOAD = [
|
4 |
"./mobilenet/model.json",
|
@@ -21,9 +20,9 @@ window.document.addEventListener("DOMContentLoaded", () => {
|
|
21 |
tokenEl.value = storedToken;
|
22 |
/// ^to help in dev.
|
23 |
}
|
24 |
-
repoNameEl.value = `
|
25 |
/// "random" repo name
|
26 |
-
form.addEventListener("submit", async
|
27 |
event.preventDefault();
|
28 |
const token = tokenEl.value;
|
29 |
const repoName = repoNameEl.value;
|
@@ -35,38 +34,51 @@ window.document.addEventListener("DOMContentLoaded", () => {
|
|
35 |
const credentials = {
|
36 |
accessToken: token,
|
37 |
};
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
button.removeAttribute("disabled");
|
71 |
});
|
72 |
});
|
|
|
|
|
|
1 |
const c = console;
|
2 |
const FILES_TO_UPLOAD = [
|
3 |
"./mobilenet/model.json",
|
|
|
20 |
tokenEl.value = storedToken;
|
21 |
/// ^to help in dev.
|
22 |
}
|
23 |
+
repoNameEl.value = `hello-world-${Date.now() % 1_000}`;
|
24 |
/// "random" repo name
|
25 |
+
form.addEventListener("submit", async (event) => {
|
26 |
event.preventDefault();
|
27 |
const token = tokenEl.value;
|
28 |
const repoName = repoNameEl.value;
|
|
|
34 |
const credentials = {
|
35 |
accessToken: token,
|
36 |
};
|
37 |
+
const result = await fetch("./mobilenet/model.json", {
|
38 |
+
headers: {
|
39 |
+
Range: "bytes=0-100",
|
40 |
+
},
|
41 |
+
});
|
42 |
+
const text = await result.text();
|
43 |
+
c.log(text);
|
44 |
+
output.append("\n" + text);
|
45 |
+
// try {
|
46 |
+
// const { name: username } = await whoAmI({ credentials });
|
47 |
+
// const name = `${username}/${repoName}`;
|
48 |
+
// const { repoUrl } = await createRepo({
|
49 |
+
// repo: {
|
50 |
+
// type: "model",
|
51 |
+
// name,
|
52 |
+
// },
|
53 |
+
// credentials,
|
54 |
+
// });
|
55 |
+
// const operations: CommitFile[] = await Promise.all(
|
56 |
+
// FILES_TO_UPLOAD.map(async (file) => {
|
57 |
+
// return {
|
58 |
+
// operation: "addOrUpdate",
|
59 |
+
// path: filenameFromURL(file),
|
60 |
+
// content: await (await fetch(file)).blob(),
|
61 |
+
// };
|
62 |
+
// })
|
63 |
+
// );
|
64 |
+
// const commitOutput = await commit({
|
65 |
+
// repo: {
|
66 |
+
// type: "model",
|
67 |
+
// name,
|
68 |
+
// },
|
69 |
+
// credentials,
|
70 |
+
// title: "upload model",
|
71 |
+
// operations,
|
72 |
+
// });
|
73 |
+
// c.log(commitOutput);
|
74 |
+
// button.insertAdjacentHTML(
|
75 |
+
// "afterend",
|
76 |
+
// `<div class="text-green-500 mb-6">🎉 Upload complete! Model page is <a target="_blank" class="text-bold underline" href="${repoUrl}">${repoUrl}</a></div>`
|
77 |
+
// );
|
78 |
+
// } catch (err) {
|
79 |
+
// output.append("\n" + err);
|
80 |
+
// }
|
81 |
button.removeAttribute("disabled");
|
82 |
});
|
83 |
});
|
84 |
+
export {};
|