image-processing - FastApi 中的多个文件
问题描述
我需要通过 FastApi 上传多个图像文件。我正在使用这段代码:
@app.post("/analyze")
async def analyze(files: List[UploadFile] = File(...)):
for img in files:
contents = await img.read()
nparr = np.fromstring(contents, np.uint8)
img1 = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
print(img1.shape)
img1 = resize_image(img1)
print(img1.shape)
但它显示错误为:
NameError: name 'List' is not defined
请帮忙!
我会尝试通过 fastapi 上传多个图像,然后对其执行 opencv 操作。如果我使用 Postman 代替 SwaggerUI 进行测试,还要在哪里上传图片?
解决方案
推荐阅读
- wordpress - 在wordpress中编辑帖子时如何设置指定的字体系列?
- php - `content_for_layout` 如何在 shopify 中加载内容?
- c# - 文件流重命名文件
- javascript - React Native - FlatList 对 renderItems 中的每个项目进行获取请求
- mongodb - 如何在 MongoDB 中应用密集排名?
- python - 如何根据另一个数据框中的变量从数据框中选择列
- python - 尝试在熊猫数据框中追加时获得“真”值而不是实际值
- cross-browser - browser.tabs.executescript() 在 Firefox 中不起作用
- python - ValueError: n_splits=3 不能大于每个类的成员数
- linux - tensorflow-1.12.0rc1-cp27-cp27mu-linux_x86_64.whl 不是这个平台支持的轮子