# 病虫害识别:38 类病 / 健状态
import requests
r = requests.post(
"http://localhost:5000/api/disease/predict",
files={"file": open("leaf.jpg", "rb")},
data={"top_k": 5},
).json()
top = r["result"]["top1"]
print(top["class_cn"], top["confidence"])
# 苹果 · 黑星病 0.964
print(r["result"]["advice"])
# 同一接口的 cURL 写法
curl -X POST "http://localhost:5000/api/disease/predict" \
-F "file=@leaf.jpg" \
-F "top_k=5"
# 返回
{
"success": true,
"result": {
"status": "disease",
"top1": {
"class_cn": "苹果 · 黑星病",
"confidence": 0.964,
"healthy": false
},
"advice": "疏除病叶、清园并喷施保护性药剂……"
}
}
# 叶冠分割:覆盖率 + 长势等级 + 叠加图
r = requests.post(
"http://localhost:5000/api/leafseg/predict",
files={"file": open("canopy.jpg", "rb")},
data={"conf": 0.25},
).json()["result"]
print(r["canopy_pct"], r["growth_level"])
# 61.3 茂密
# r["overlay_png_base64"] 可直接落盘或前端展示