Spaces:
Sleeping
Sleeping
Update app.py
Browse files修正post的predict_image方法
app.py
CHANGED
|
@@ -52,16 +52,10 @@ def predict_text_api(payload: dict):
|
|
| 52 |
|
| 53 |
# ✅ API 路由:圖片分析(POST)
|
| 54 |
@api.post("/run/predict_image")
|
| 55 |
-
async def predict_image_api(file: UploadFile = File(...), explain_mode: str = Form(
|
| 56 |
try:
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
temp_file_path = temp_file.name
|
| 60 |
-
|
| 61 |
-
with open(temp_file_path, "rb") as f:
|
| 62 |
-
result = analyze_image(f.read(), explain_mode=explain_mode)
|
| 63 |
-
|
| 64 |
-
os.remove(temp_file_path)
|
| 65 |
|
| 66 |
return {
|
| 67 |
"data": [
|
|
|
|
| 52 |
|
| 53 |
# ✅ API 路由:圖片分析(POST)
|
| 54 |
@api.post("/run/predict_image")
|
| 55 |
+
async def predict_image_api(file: UploadFile = File(...), explain_mode: str = Form(...)):
|
| 56 |
try:
|
| 57 |
+
img = await file.read()
|
| 58 |
+
result = analyze_image(img,explain_mode=explain_mode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
return {
|
| 61 |
"data": [
|