Spaces:
Runtime error
Runtime error
test: input imgs
Browse files- main.py +1 -1
- static/index.html +2 -2
- static/script.js +33 -5
main.py
CHANGED
@@ -29,7 +29,7 @@ async def classify_doc(files: List[UploadFile] = File(...)):
|
|
29 |
return {"message": "There was an error in uploading file(s)"}
|
30 |
finally:
|
31 |
file.file.close()
|
32 |
-
return {"message": f"Successfuly uploaded {[
|
33 |
|
34 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
35 |
|
|
|
29 |
return {"message": "There was an error in uploading file(s)"}
|
30 |
finally:
|
31 |
file.file.close()
|
32 |
+
return {"message": f"Successfuly uploaded {[classify_res for file in files]}"}
|
33 |
|
34 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
35 |
|
static/index.html
CHANGED
@@ -32,8 +32,8 @@
|
|
32 |
</form>
|
33 |
</section>
|
34 |
<section>
|
35 |
-
<
|
36 |
-
<
|
37 |
</section>
|
38 |
</main>
|
39 |
</body>
|
|
|
32 |
</form>
|
33 |
</section>
|
34 |
<section>
|
35 |
+
<input id="img-input" type="file" multiple="multiple" accept="image/jpeg, image/png, image/jpg">
|
36 |
+
<output id="img-output"></output>
|
37 |
</section>
|
38 |
</main>
|
39 |
</body>
|
static/script.js
CHANGED
@@ -20,11 +20,39 @@ textGenForm.addEventListener('submit', async (event) => {
|
|
20 |
}
|
21 |
});
|
22 |
|
23 |
-
const imgGenSubmitBtn = document.querySelector('.img-gen-submit');
|
24 |
|
25 |
-
// const getDocClass = async (text)
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
});
|
|
|
20 |
}
|
21 |
});
|
22 |
|
|
|
23 |
|
|
|
24 |
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
function submitImages(acceptedFiles) {
|
37 |
+
const data = new FormData();
|
38 |
+
|
39 |
+
for (const file of acceptedFiles){
|
40 |
+
data.append('files[]', file, file.name);
|
41 |
+
}
|
42 |
+
|
43 |
+
classifyResponse = fetch('classify',
|
44 |
+
method: 'POST',
|
45 |
+
body: data);
|
46 |
+
|
47 |
+
return classifyResponse;
|
48 |
+
}
|
49 |
+
|
50 |
+
const inputImg = document.querySelector('img-input');
|
51 |
+
const outputImg = document.querySelector('img-output');
|
52 |
+
let imageArray = [];
|
53 |
+
|
54 |
+
input.addEventListener("change", event =>{
|
55 |
+
const files = event.target.files;
|
56 |
+
res = submitImages(files);
|
57 |
+
console.log(res)
|
58 |
});
|