Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +19 -14
index.html
CHANGED
|
@@ -10,7 +10,10 @@
|
|
| 10 |
</style>
|
| 11 |
</head>
|
| 12 |
<body>
|
| 13 |
-
<h2>
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
<label for="gender">Select Gender</label>
|
| 16 |
<select id="gender">
|
|
@@ -22,9 +25,6 @@
|
|
| 22 |
<label for="shape">Shape Coefficients (comma-separated 10 floats)</label>
|
| 23 |
<input type="text" id="shape" value="0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0">
|
| 24 |
|
| 25 |
-
<label for="model_path">Model Path (as expected in server)</label>
|
| 26 |
-
<input type="text" id="model_path" value="data/smpl">
|
| 27 |
-
|
| 28 |
<button onclick="sendRequest()">Measure</button>
|
| 29 |
|
| 30 |
<h3>Response</h3>
|
|
@@ -32,24 +32,28 @@
|
|
| 32 |
|
| 33 |
<script>
|
| 34 |
async function sendRequest() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
const shape = document.getElementById("shape").value
|
| 36 |
.split(",")
|
| 37 |
.map(parseFloat);
|
| 38 |
-
const model_path = document.getElementById("model_path").value;
|
| 39 |
-
const gender = document.getElementById("gender").value;
|
| 40 |
|
| 41 |
-
const
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
pose: {} // optional; unused
|
| 46 |
-
};
|
| 47 |
|
| 48 |
try {
|
| 49 |
const res = await fetch("/measure", {
|
| 50 |
method: "POST",
|
| 51 |
-
|
| 52 |
-
body: JSON.stringify(payload)
|
| 53 |
});
|
| 54 |
const json = await res.json();
|
| 55 |
document.getElementById("response").value = JSON.stringify(json, null, 2);
|
|
@@ -60,3 +64,4 @@
|
|
| 60 |
</script>
|
| 61 |
</body>
|
| 62 |
</html>
|
|
|
|
|
|
| 10 |
</style>
|
| 11 |
</head>
|
| 12 |
<body>
|
| 13 |
+
<h2>Upload Body Model File & Measure</h2>
|
| 14 |
+
|
| 15 |
+
<label for="modelFile">Upload Model File</label>
|
| 16 |
+
<input type="file" id="modelFile" />
|
| 17 |
|
| 18 |
<label for="gender">Select Gender</label>
|
| 19 |
<select id="gender">
|
|
|
|
| 25 |
<label for="shape">Shape Coefficients (comma-separated 10 floats)</label>
|
| 26 |
<input type="text" id="shape" value="0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0">
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
<button onclick="sendRequest()">Measure</button>
|
| 29 |
|
| 30 |
<h3>Response</h3>
|
|
|
|
| 32 |
|
| 33 |
<script>
|
| 34 |
async function sendRequest() {
|
| 35 |
+
const fileInput = document.getElementById("modelFile");
|
| 36 |
+
const file = fileInput.files[0];
|
| 37 |
+
|
| 38 |
+
if (!file) {
|
| 39 |
+
alert("Please upload a model file.");
|
| 40 |
+
return;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
const gender = document.getElementById("gender").value;
|
| 44 |
const shape = document.getElementById("shape").value
|
| 45 |
.split(",")
|
| 46 |
.map(parseFloat);
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
const formData = new FormData();
|
| 49 |
+
formData.append("model_file", file);
|
| 50 |
+
formData.append("gender", gender);
|
| 51 |
+
formData.append("shape", JSON.stringify(shape));
|
|
|
|
|
|
|
| 52 |
|
| 53 |
try {
|
| 54 |
const res = await fetch("/measure", {
|
| 55 |
method: "POST",
|
| 56 |
+
body: formData
|
|
|
|
| 57 |
});
|
| 58 |
const json = await res.json();
|
| 59 |
document.getElementById("response").value = JSON.stringify(json, null, 2);
|
|
|
|
| 64 |
</script>
|
| 65 |
</body>
|
| 66 |
</html>
|
| 67 |
+
|