Spaces:
Runtime error
Runtime error
carlfeynman
commited on
Commit
•
60e550e
1
Parent(s):
ad33cbb
debug
Browse files- server.py +2 -13
- static/index.html +2 -11
server.py
CHANGED
@@ -37,22 +37,11 @@ def store_img(image):
|
|
37 |
|
38 |
@app.post("/predict")
|
39 |
async def predict(image: UploadFile):
|
|
|
40 |
print(image)
|
41 |
# tensor_image, raw_image = process_image(image)
|
42 |
# print(tensor_image.shape)
|
43 |
# prediction = mnist_classifier.predict(tensor_image)
|
44 |
# store_img(raw_image)
|
45 |
prediction = []
|
46 |
-
return {"prediction": prediction}
|
47 |
-
|
48 |
-
class Item(BaseModel):
|
49 |
-
name: str
|
50 |
-
|
51 |
-
@app.post("/home")
|
52 |
-
async def home(item: Item):
|
53 |
-
return {
|
54 |
-
'prediction': [{
|
55 |
-
'name': item.name
|
56 |
-
}]
|
57 |
-
}
|
58 |
-
|
|
|
37 |
|
38 |
@app.post("/predict")
|
39 |
async def predict(image: UploadFile):
|
40 |
+
return {'msg': 'ok'}
|
41 |
print(image)
|
42 |
# tensor_image, raw_image = process_image(image)
|
43 |
# print(tensor_image.shape)
|
44 |
# prediction = mnist_classifier.predict(tensor_image)
|
45 |
# store_img(raw_image)
|
46 |
prediction = []
|
47 |
+
return {"prediction": prediction}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/index.html
CHANGED
@@ -160,18 +160,9 @@
|
|
160 |
var imageData = canvas.toDataURL("image/png");
|
161 |
var formData = new FormData();
|
162 |
formData.append("image", dataURLtoBlob(imageData), "image.png");
|
163 |
-
|
164 |
-
fetch('/home', {
|
165 |
method: 'POST',
|
166 |
-
|
167 |
-
headers: {
|
168 |
-
'Content-Type': 'application/json', // Set the Content-Type header
|
169 |
-
},
|
170 |
-
body: JSON.stringify({
|
171 |
-
|
172 |
-
'name': 'arun'
|
173 |
-
|
174 |
-
})
|
175 |
})
|
176 |
.then(response => response.json())
|
177 |
.then(data => {
|
|
|
160 |
var imageData = canvas.toDataURL("image/png");
|
161 |
var formData = new FormData();
|
162 |
formData.append("image", dataURLtoBlob(imageData), "image.png");
|
163 |
+
fetch('/predict', {
|
|
|
164 |
method: 'POST',
|
165 |
+
body: formData,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
})
|
167 |
.then(response => response.json())
|
168 |
.then(data => {
|