Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import Dict
|
|
| 4 |
import numpy as np
|
| 5 |
import tensorflow as tf
|
| 6 |
from PIL import Image
|
| 7 |
-
from bustapi import BustAPI,
|
| 8 |
|
| 9 |
LABELS = [
|
| 10 |
"battery", # 电池
|
|
@@ -93,9 +93,9 @@ def predict(image):
|
|
| 93 |
app = BustAPI()
|
| 94 |
|
| 95 |
@app.post("/predict")
|
| 96 |
-
async def predict_api(
|
| 97 |
# 读取 POST 二进制流
|
| 98 |
-
img_bytes = await
|
| 99 |
# 转 PIL Image
|
| 100 |
image = Image.open(io.BytesIO(img_bytes)).convert("RGB")
|
| 101 |
# 推理
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
import tensorflow as tf
|
| 6 |
from PIL import Image
|
| 7 |
+
from bustapi import BustAPI, request, Response
|
| 8 |
|
| 9 |
LABELS = [
|
| 10 |
"battery", # 电池
|
|
|
|
| 93 |
app = BustAPI()
|
| 94 |
|
| 95 |
@app.post("/predict")
|
| 96 |
+
async def predict_api():
|
| 97 |
# 读取 POST 二进制流
|
| 98 |
+
img_bytes = await request.body()
|
| 99 |
# 转 PIL Image
|
| 100 |
image = Image.open(io.BytesIO(img_bytes)).convert("RGB")
|
| 101 |
# 推理
|