活动介绍

INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.18.0.1:0 - "GET /_app/version.json HTTP/1.1" 200 - {} 2025-08-01 16:28:05.187 | INFO | faster_whisper.transcribe:transcribe:839 - Processing audio with duration 00:02.640 - {} Unable to load any of {libcudnn_ops.so.9.1.0, libcudnn_ops.so.9.1, libcudnn_ops.so.9, libcudnn_ops.so} Invalid handle. Cannot load symbol cudnnCreateTensorDescriptor Debian中nvidia-smi和nvcc都安装好了,whisper使用cuda时还是出现错误提示

时间: 2025-08-01 22:18:52 浏览: 11
<think>我们遇到了一个关于在Debian系统上使用CUDA运行faster-whisper时出现错误的问题。错误信息显示无法加载libcudnn_ops.so系列文件,并且还提示“Invalid handle. Cannot load symbol cudnnCreateTensorDescriptor”。 分析: 1. 错误表明CUDA深度神经网络库(cuDNN)没有被正确安装或配置。 2. `nvidia-smi` 和 `nvcc` 能正常工作说明NVIDIA驱动和CUDA工具包已经安装,但cuDNN可能没有安装或者安装不正确。 3. cuDNN是NVIDIA提供的用于深度神经网络的GPU加速库,许多深度学习框架(包括faster-whisper)依赖它。 解决方案: 步骤1:确认cuDNN是否安装 步骤2:如果没有安装,则安装cuDNN 步骤3:设置环境变量,确保库文件被正确链接 详细步骤: 1. 检查cuDNN是否安装: 通常cuDNN库文件会放在`/usr/local/cuda/lib64`或`/usr/lib/x86_64-linux-gnu`等目录。我们可以检查这些目录下是否有类似`libcudnn_ops.so*`的文件。 例如,运行: ```bash find /usr -name libcudnn_ops.so* 2>/dev/null ``` 2. 如果没有找到,则需要安装cuDNN。 安装cuDNN的方法: a. 前往NVIDIA官网下载cuDNN,需要注册账号:https://developer.nvidia.com/cudnn b. 根据你的CUDA版本选择对应的cuDNN版本(可以通过`nvcc --version`查看CUDA版本)。 c. 下载cuDNN的Debian包(.deb文件)或者压缩包(.tgz文件)。 使用.deb文件安装(推荐): ```bash sudo dpkg -i cudnn-local-repo-<version>.deb sudo apt update sudo apt install libcudnn8 libcudnn8-dev # 根据版本不同,可能是libcudnn8或者libcudnn9 ``` 或者使用.tgz文件安装: ```bash tar -xvf cudnn-linux-x86_64-<version>.tgz sudo cp cuda/include/cudnn*.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn* ``` 3. 设置环境变量: 确保CUDA库路径在LD_LIBRARY_PATH中。可以将以下内容添加到`~/.bashrc`或`~/.profile`中: ```bash export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH ``` 然后执行: ```bash source ~/.bashrc ``` 4. 更新库缓存: ```bash sudo ldconfig ``` 5. 验证cuDNN安装: 可以运行以下命令验证: ```bash cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2 ``` 或者(新版本): ```bash cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR ``` 如果找不到,可以尝试在`/usr/include`下查找`cudnn_version.h`。 6. 如果仍然遇到问题,可能是由于cuDNN版本与CUDA版本不匹配,请确保下载的cuDNN版本与CUDA版本兼容。 7. 另外,错误信息中提到了`libcudnn_ops.so.9.1.0`等,但安装的可能是其他版本(如8.x或9.0),需要确认版本号。 8. 如果已经安装了cuDNN但是仍然找不到,可以尝试创建符号链接: 假设我们找到了`libcudnn_ops.so.9.1.0`,那么可以: ```bash sudo ln -s /path/to/libcudnn_ops.so.9.1.0 /usr/lib/libcudnn_ops.so.9 sudo ln -s /usr/lib/libcudnn_ops.so.9 /usr/lib/libcudnn_ops.so ``` 然后更新缓存: ```bash sudo ldconfig ``` 9. 最后,重新运行程序。 注意:faster-whisper依赖于ctranslate2,而ctranslate2需要CUDA和cuDNN。确保安装的ctranslate2版本与CUDA版本匹配。 如果以上步骤还不能解决问题,可能需要检查是否安装了多个CUDA版本,并确保使用的CUDA版本一致。 由于这是一个环境配置问题,没有具体的代码需要提供,但我们可以写一个简单的CUDA程序来测试cuDNN是否安装成功。 测试程序(需要安装pytorch): ```python import torch print(torch.cuda.is_available()) # 应该输出True # 测试cuDNN from torch.backends import cudnn print(cudnn.is_available()) # 应该输出True print(cudnn.is_acceptable(torch.cuda.FloatTensor(1))) # 应该输出True ``` 如果没有安装pytorch,可以通过以下方式安装(根据你的CUDA版本): ```bash pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 ``` 请将`cu113`替换为你的CUDA版本(如`cu102`,`cu111`等)。 希望这些步骤能帮助你解决问题。 如果你已经按照上述步骤操作但仍然遇到问题,请提供更多信息,例如: - 操作系统版本 - CUDA版本 - cuDNN版本 - Python版本 - faster-whisper和ctranslate2的版本 §§相关问题§§: 1. 如何检查Debian系统上安装的CUDA版本? 2. 如何卸载旧版本的cuDNN并安装新版本? 3. 在Linux系统中如何设置环境变量? 4. 如何解决动态库链接错误?</think>### 解决Debian系统CUDA与cuDNN兼容性问题 以下是完整的解决方案,针对您在使用faster-whisper时遇到的CUDA/cuDNN兼容性问题: --- ### **问题原因分析** 1. **缺失cuDNN库**:`libcudnn_ops.so`是cuDNN的核心组件,未安装或路径未配置 2. **版本不匹配**:CUDA Toolkit、cuDNN和NVIDIA驱动版本不兼容 3. **环境变量未设置**:系统未正确识别CUDA/cuDNN库路径 4. **权限问题**:库文件权限不足导致加载失败 --- ### **解决方案步骤** #### 1. **验证CUDA安装** ```bash # 检查NVIDIA驱动版本 nvidia-smi # 检查CUDA编译器版本 nvcc --version ``` 确保驱动版本 ≥ CUDA版本要求(如CUDA 11.x需要驱动≥450.80.02) #### 2. **安装cuDNN(关键步骤)** ```bash # 添加NVIDIA包仓库 distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ && curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | sudo apt-key add - \ && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list # 安装匹配的cuDNN版本(以CUDA 11.x为例) sudo apt update sudo apt install libcudnn8 libcudnn8-dev ``` #### 3. **配置环境变量** 编辑 `~/.bashrc`: ```bash export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH export CUDA_HOME=/usr/local/cuda ``` 激活配置: ```bash source ~/.bashrc ``` #### 4. **创建符号链接(解决"Invalid handle"错误)** ```bash # 定位实际安装的cuDNN版本 find /usr -name "libcudnn_ops.so*" 2>/dev/null # 创建符号链接(示例路径,需替换实际路径) sudo ln -s /usr/lib/x86_64-linux-gnu/libcudnn_ops.so.8 /usr/lib/libcudnn_ops.so.9 sudo ldconfig ``` #### 5. **验证cuDNN安装** 创建测试文件 `cudnn_test.cpp`: ```cpp #include <cudnn.h> #include <iostream> int main() { cudnnHandle_t handle; cudnnStatus_t status = cudnnCreate(&handle); if (status == CUDNN_STATUS_SUCCESS) { std::cout << "cuDNN initialized successfully!" << std::endl; cudnnDestroy(handle); return 0; } else { std::cerr << "cuDNN initialization failed: " << status << std::endl; return 1; } } ``` 编译并运行: ```bash g++ cudnn_test.cpp -o test -lcudnn ./test ``` 成功输出:`cuDNN initialized successfully!` #### 6. **重装PyTorch与faster-whisper** ```bash # 卸载冲突包 pip uninstall torch torchaudio torchvision # 安装CUDA兼容的PyTorch pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118 # 重装faster-whisper pip install faster-whisper ``` --- ### **常见问题排查** 1. **版本兼容表**: | CUDA版本 | cuDNN版本 | PyTorch版本 | |----------|-----------|-------------| | 11.8 | 8.7.0 | ≥2.0 | | 12.1 | 8.9.0 | ≥2.1 | 2. **权限修复命令**: ```bash sudo chmod a+r /usr/local/cuda/include/cudnn*.h sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn* ``` 3. **多CUDA版本切换**: ```bash sudo update-alternatives --config cuda ``` --- ### **最终验证** ```python import torch from faster_whisper import WhisperModel print("CUDA available:", torch.cuda.is_available()) # 应输出 True print("cuDNN enabled:", torch.backends.cudnn.enabled) # 应输出 True # 测试faster-whisper model = WhisperModel("base", device="cuda", compute_type="float16") segments, info = model.transcribe("audio.mp3") print("Detected language:", info.language) ``` ---
阅读全文

相关推荐

2025-07-23 16:48:26 2025-07-23 16:48:26.051 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.18.0.1:0 - "POST /api/v1/images/image/config/update HTTP/1.1" 500 - {} 2025-07-23 16:48:26 Exception in ASGI application 2025-07-23 16:48:26 + Exception Group Traceback (most recent call last): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 76, in collapse_excgroups 2025-07-23 16:48:26 | yield 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 178, in __call__ 2025-07-23 16:48:26 | async with anyio.create_task_group() as task_group: 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ 2025-07-23 16:48:26 | raise BaseExceptionGroup( 2025-07-23 16:48:26 | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) 2025-07-23 16:48:26 +-+---------------- 1 ---------------- 2025-07-23 16:48:26 | Traceback (most recent call last): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi 2025-07-23 16:48:26 | result = await app( # type: ignore[func-returns-value] 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ 2025-07-23 16:48:26 | return await self.app(scope, receive, send) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__ 2025-07-23 16:48:26 | await super().__call__(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__ 2025-07-23 16:48:26 | await self.middleware_stack(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__ 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__ 2025-07-23 16:48:26 | await self.app(scope, receive, _send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__ 2025-07-23 16:48:26 | await self.app(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 | with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 | self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 | response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/app/backend/open_webui/main.py", line 1117, in inspect_websocket 2025-07-23 16:48:26 | return await call_next(request) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 | raise app_exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 | await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 | with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 | self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 | response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/app/backend/open_webui/main.py", line 1096, in check_url 2025-07-23 16:48:26 | response = await call_next(request) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 | raise app_exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 | await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 | with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 | self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 | response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/app/backend/open_webui/main.py", line 1082, in commit_session_after_request 2025-07-23 16:48:26 | response = await call_next(request) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 | raise app_exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 | await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 | with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 | self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 | response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/app/backend/open_webui/utils/security_headers.py", line 11, in dispatch 2025-07-23 16:48:26 | response = await call_next(request) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 | raise app_exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 | await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 | with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 | self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 | response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/app/backend/open_webui/main.py", line 1070, in dispatch 2025-07-23 16:48:26 | response = await call_next(request) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 | raise app_exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 | await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette_compress/__init__.py", line 94, in __call__ 2025-07-23 16:48:26 | return await self._brotli(scope, receive, send) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette_compress/_brotli.py", line 106, in __call__ 2025-07-23 16:48:26 | await self.app(scope, receive, wrapper) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ 2025-07-23 16:48:26 | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app 2025-07-23 16:48:26 | await app(scope, receive, sender) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__ 2025-07-23 16:48:26 | await self.middleware_stack(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 735, in app 2025-07-23 16:48:26 | await route.handle(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle 2025-07-23 16:48:26 | await self.app(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 76, in app 2025-07-23 16:48:26 | await wrap_app_handling_exceptions(app, request)(scope, receive, send) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app 2025-07-23 16:48:26 | raise exc 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app 2025-07-23 16:48:26 | await app(scope, receive, sender) 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 73, in app 2025-07-23 16:48:26 | response = await f(request) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app 2025-07-23 16:48:26 | raw_response = await run_endpoint_function( 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function 2025-07-23 16:48:26 | return await dependant.call(**values) 2025-07-23 16:48:26 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | File "/app/backend/open_webui/routers/images.py", line 303, in update_image_config 2025-07-23 16:48:26 | set_image_model(request, form_data.MODEL) 2025-07-23 16:48:26 | File "/app/backend/open_webui/routers/images.py", line 239, in set_image_model 2025-07-23 16:48:26 | if model != options["sd_model_checkpoint"]: 2025-07-23 16:48:26 | ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 | KeyError: 'sd_model_checkpoint' 2025-07-23 16:48:26 +------------------------------------ 2025-07-23 16:48:26 2025-07-23 16:48:26 During handling of the above exception, another exception occurred: 2025-07-23 16:48:26 2025-07-23 16:48:26 Traceback (most recent call last): 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi 2025-07-23 16:48:26 result = await app( # type: ignore[func-returns-value] 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ 2025-07-23 16:48:26 return await self.app(scope, receive, send) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__ 2025-07-23 16:48:26 await super().__call__(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__ 2025-07-23 16:48:26 await self.middleware_stack(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__ 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__ 2025-07-23 16:48:26 await self.app(scope, receive, _send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__ 2025-07-23 16:48:26 await self.app(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/app/backend/open_webui/main.py", line 1117, in inspect_websocket 2025-07-23 16:48:26 return await call_next(request) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 raise app_exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/app/backend/open_webui/main.py", line 1096, in check_url 2025-07-23 16:48:26 response = await call_next(request) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 raise app_exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/app/backend/open_webui/main.py", line 1082, in commit_session_after_request 2025-07-23 16:48:26 response = await call_next(request) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 raise app_exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/app/backend/open_webui/utils/security_headers.py", line 11, in dispatch 2025-07-23 16:48:26 response = await call_next(request) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 raise app_exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 177, in __call__ 2025-07-23 16:48:26 with recv_stream, send_stream, collapse_excgroups(): 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__ 2025-07-23 16:48:26 self.gen.throw(typ, value, traceback) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 179, in __call__ 2025-07-23 16:48:26 response = await self.dispatch_func(request, call_next) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/app/backend/open_webui/main.py", line 1070, in dispatch 2025-07-23 16:48:26 response = await call_next(request) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 154, in call_next 2025-07-23 16:48:26 raise app_exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro 2025-07-23 16:48:26 await self.app(scope, receive_or_disconnect, send_no_error) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette_compress/__init__.py", line 94, in __call__ 2025-07-23 16:48:26 return await self._brotli(scope, receive, send) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette_compress/_brotli.py", line 106, in __call__ 2025-07-23 16:48:26 await self.app(scope, receive, wrapper) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ 2025-07-23 16:48:26 await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app 2025-07-23 16:48:26 await app(scope, receive, sender) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__ 2025-07-23 16:48:26 await self.middleware_stack(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 735, in app 2025-07-23 16:48:26 await route.handle(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle 2025-07-23 16:48:26 await self.app(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 76, in app 2025-07-23 16:48:26 await wrap_app_handling_exceptions(app, request)(scope, receive, send) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app 2025-07-23 16:48:26 raise exc 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app 2025-07-23 16:48:26 await app(scope, receive, sender) 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 73, in app 2025-07-23 16:48:26 response = await f(request) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app 2025-07-23 16:48:26 raw_response = await run_endpoint_function( 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function 2025-07-23 16:48:26 return await dependant.call(**values) 2025-07-23 16:48:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 File "/app/backend/open_webui/routers/images.py", line 303, in update_image_config 2025-07-23 16:48:26 set_image_model(request, form_data.MODEL) 2025-07-23 16:48:26 File "/app/backend/open_webui/routers/images.py", line 239, in set_image_model 2025-07-23 16:48:26 if model != options["sd_model_checkpoint"]: 2025-07-23 16:48:26 ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-23 16:48:26 KeyError: 'sd_model_checkpoint'

ERROR: Exception in ASGI application + Exception Group Traceback (most recent call last): | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 76, in collapse_excgroups | yield | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 177, in __call__ | async with anyio.create_task_group() as task_group: | ^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi | result = await app( # type: ignore[func-returns-value] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ | return await self.app(scope, receive, send) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ | await super().__call__(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ | await self.middleware_stack(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ | raise exc | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ | await self.app(scope, receive, _send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__ | await self.app(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 176, in __call__ | with recv_stream, send_stream, collapse_excgroups(): | ^^^^^^^^^^^^^^^^^^^^ | File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 158, in __exit__ | self.gen.throw(value) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups | raise exc | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 178, in __call__ | response = await self.dispatch_func(request, call_next) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/06.renwu/00.fix_bug/test-automation-platform-backend/src/app/middlewares/request_logger_middleware.py", line 17, in dispatch | response = await call_next(request) | ^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 156, in call_next | raise app_exc | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 141, in coro | await self.app(scope, receive_or_disconnect, send_no_error) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ | await self.middleware_stack(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 734, in app | await route.handle(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle | await self.app(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 76, in app | await wrap_app_handling_exceptions(app, request)(scope, receive, send) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | raise exc | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | await app(scope, receive, sender) | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 73, in app | response = await f(request) | ^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 301, in app | raw_response = await run_endpoint_function( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 212, in run_endpoint_function | return await dependant.call(**values) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/06.renwu/00.fix_bug/test-automation-platform-backend/src/app/api/v1/device_monitor.py", line 281, in get_memory_trend | resp_memory = await influxdb.query_api.query(query_mem_trend) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/influxdb_client/client/query_api_async.py", line 102, in query | response = await self._post_query(org=org, query=self._create_query(query, self.default_dialect, params)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/influxdb_client/client/query_api_async.py", line 234, in _post_query | raise ApiException(http_resp=RESTResponseAsync(response, data)) | influxdb_client.rest.ApiException: (401) | Reason: Unauthorized | HTTP response headers: <CIMultiDictProxy('Content-Type': 'application/json; charset=utf-8', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': 'v2.7.12', 'X-Platform-Error-Code': 'unauthorized', 'Date': 'Wed, 13 Aug 2025 06:30:57 GMT', 'Content-Length': '55')> | HTTP response body: b'{"code":"unauthorized","message":"unauthorized access"}' | +------------------------------------ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__ raise exc File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__ await self.app(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 176, in __call__ with recv_stream, send_stream, collapse_excgroups(): ^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 82, in collapse_excgroups raise exc File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 178, in __call__ response = await self.dispatch_func(request, call_next) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/06.renwu/00.fix_bug/test-automation-platform-backend/src/app/middlewares/request_logger_middleware.py", line 17, in dispatch response = await call_next(request) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 156, in call_next raise app_exc File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 141, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/starlette/routing.py", line 73, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 301, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 212, in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/06.renwu/00.fix_bug/test-automation-platform-backend/src/app/api/v1/device_monitor.py", line 281, in get_memory_trend resp_memory = await influxdb.query_api.query(query_mem_trend) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/influxdb_client/client/query_api_async.py", line 102, in query response = await self._post_query(org=org, query=self._create_query(query, self.default_dialect, params)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/qxz5mik/platform_work/04.code/test-automation-platform-backend/.venv/lib/python3.12/site-packages/influxdb_client/client/query_api_async.py", line 234, in _post_query raise ApiException(http_resp=RESTResponseAsync(response, data)) influxdb_client.rest.ApiException: (401) Reason: Unauthorized HTTP response headers: <CIMultiDictProxy('Content-Type': 'application/json; charset=utf-8', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': 'v2.7.12', 'X-Platform-Error-Code': 'unauthorized', 'Date': 'Wed, 13 Aug 2025 06:30:57 GMT', 'Content-Length': '55')> HTTP response body: b'{"code":"unauthorized","message":"unauthorized access"}' 这是什么错误,如何解决

2025-08-04 10:28:21.088 | ERROR | uvicorn.protocols.http.h11_impl:run_asgi:434 - Exception in ASGI application + Exception Group Traceback (most recent call last): | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\_utils.py", line 76, in collapse_excgroups | yield | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 186, in __call__ | async with anyio.create_task_group() as task_group: | │ │ └ <anyio._backends._asyncio.TaskGroup object at 0x000001A381063730> | │ └ <function create_task_group at 0x000001A3F0A1C790> | └ <module 'anyio' from 'D:\\dev\\EquipmentRegistryDataPlatform\\venv\\lib\\site-packages\\anyio\\__init__.py'> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 815, in __aexit__ | raise BaseExceptionGroup( | └ <class 'exceptiongroup.BaseExceptionGroup'> | | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 429, in run_asgi | result = await app( # type: ignore[func-returns-value] | └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x000001A3EF059690> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__ | return await self.app(scope, receive, send) | │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062890>> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | │ └ <fastapi.applications.FastAPI object at 0x000001A3FF747340> | └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x000001A3EF059690> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\fastapi\applications.py", line 1054, in __call__ | await super().__call__(scope, receive, send) | │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062890>> | │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\applications.py", line 113, in __call__ | await self.middleware_stack(scope, receive, send) | │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062890>> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | │ └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x000001A3FFC93670> | └ <fastapi.applications.FastAPI object at 0x000001A3FF747340> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\errors.py", line 187, in __call__ | raise exc | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\errors.py", line 165, in __call__ | await self.app(scope, receive, _send) | │ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x000001A3F136C940> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | │ └ <starlette.middleware.cors.CORSMiddleware object at 0x000001A3FFC93760> | └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x000001A3FFC93670> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\cors.py", line 93, in __call__ | await self.simple_response(scope, receive, send, request_headers=headers) | │ │ │ │ │ └ Headers({'host': '127.0.0.1:9999', 'connection': 'keep-alive', 'content-length': '34', 'pragma': 'no-cache', 'cache-control':... | │ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x000001A3F136C940> | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | │ └ <function CORSMiddleware.simple_response at 0x000001A3FF87D1B0> | └ <starlette.middleware.cors.CORSMiddleware object at 0x000001A3FFC93760> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\cors.py", line 144, in simple_response | await self.app(scope, receive, send) | │ │ │ │ └ functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at 0x000001A3FFC93760... | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | │ └ <app.core.middlewares.BackGroundTaskMiddleware object at 0x000001A3FFC936D0> | └ <starlette.middleware.cors.CORSMiddleware object at 0x000001A3FFC93760> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 28, in __call__ | await self.handle_http(scope, receive, send) | │ │ │ │ └ functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at 0x000001A3FFC93760... | │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | │ └ <function SimpleBaseMiddleware.handle_http at 0x000001A3FF87DEA0> | └ <app.core.middlewares.BackGroundTaskMiddleware object at 0x000001A3FFC936D0> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 38, in handle_http | await response(scope, receive, send_wrapper) | │ │ │ └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x000001A3F136C700> | │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x000001A381062... | │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... | └ <app.core.middlewares.APILoggerMiddleware object at 0x000001A3FFC93D90> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 185, in __call__ | with collapse_excgroups(): | └ <function collapse_excgroups at 0x000001A3F0C3C9D0> | | File "C:\Program Files\Python310\lib\contextlib.py", line 153, in __exit__ | self.gen.throw(typ, value, traceback) | │ │ │ │ │ └ <traceback object at 0x000001A3811BAB00> | │ │ │ │ └ ExceptionGroup('unhandled errors in a TaskGroup', [TypeError("'module' object is not callable")]) | │ │ │ └ <class 'exceptiongroup.ExceptionGroup'> | │ │ └ <method 'throw' of 'generator' objects> | │ └ <generator object collapse_excgroups at 0x000001A3810ED620> | └ <contextlib._GeneratorContextManager object at 0x000001A381063CD0> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\_utils.py", line 82, in collapse_excgroups | raise exc | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 187, in __call__ | response = await self.dispatch_func(request, call_next) | │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x000001A3F136C820> | │ │ └ <starlette.middleware.base._CachedRequest object at 0x000001A381063F40> | │ └ <bound method APILoggerMiddleware.dispatch of <app.core.middlewares.APILoggerMiddleware object at 0x000001A3FFC93D90>> | └ <app.core.middlewares.APILoggerMiddleware object at 0x000001A3FFC93D90> | | File "D:\dev\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 103, in dispatch | response = await call_next(request) | │ └ <starlette.middleware.base._CachedRequest object at 0x000001A381063F40> | └ <function BaseHTTPMiddleware.__call__.<locals>.call_next at 0x000001A3F136C820> | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 163, in call_next | raise app_exc | └ TypeError("'module' object is not callable") | | File "D:\dev\EquipmentRegistryDataPlatform\venv\lib\site-packages\starlette\middleware\base.py", line 149, in coro | await self.app(scope, receive_or_disconnect, send_no_error) | │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x000001A381249E10> | │ │ │

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 1, in <module> File "D:\application\Python310\lib\multiprocessing\spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) │ │ └ 724 │ └ 3 └ <function _main at 0x0000028CCCDAA830> File "D:\application\Python310\lib\multiprocessing\spawn.py", line 129, in _main return self._bootstrap(parent_sentinel) │ │ └ 724 │ └ <function BaseProcess._bootstrap at 0x0000028CCCCD1B40> └ <SpawnProcess name='SpawnProcess-1' parent=16008 started> File "D:\application\Python310\lib\multiprocessing\process.py", line 315, in _bootstrap self.run() │ └ <function BaseProcess.run at 0x0000028CCCCD11B0> └ <SpawnProcess name='SpawnProcess-1' parent=16008 started> File "D:\application\Python310\lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self._kwargs) │ │ │ │ │ └ {'config': <uvicorn.config.Config object at 0x0000028CCCD9F3A0>, 'target': <bound method Server.run of <uvicorn.server.Server... │ │ │ │ └ <SpawnProcess name='SpawnProcess-1' parent=16008 started> │ │ │ └ () │ │ └ <SpawnProcess name='SpawnProcess-1' parent=16008 started> │ └ <function subprocess_started at 0x0000028CCD9AED40> └ <SpawnProcess name='SpawnProcess-1' parent=16008 started> File "D:\pyVenv\mypyenv310\lib\site-packages\uvicorn\_subprocess.py", line 80, in subprocess_started target(sockets=sockets) │ └ [<socket.socket fd=836, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 9999)>] └ <bound method Server.run of <uvicorn.server.Server object at 0x0000028CCCD9F4C0>> File "D:\pyVenv\mypyenv310\lib\site-packages\uvicorn\server.py", line 66, in run return asyncio.run(self.serve(sockets=sockets)) │ │ │ │ └ [<socket.socket fd=836, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 9999)>] │ │ │ └ <function Server.serve at 0x0000028CCD997640> │ │ └ <uvicorn.server.Server object at 0x0000028CCCD9F4C0> │ └ <function run at 0x0000028CCCDBD1B0> └ <module 'asyncio' from 'D:\\application\\Python310\\lib\\asyncio\\__init__.py'> File "D:\application\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) │ │ └ <coroutine object Server.serve at 0x0000028CCD98EA40> │ └ <function BaseEventLoop.run_until_complete at 0x0000028CCD1FA710> └ <_WindowsSelectorEventLoop running=True closed=False debug=False> File "D:\application\Python310\lib\asyncio\base_events.py", line 628, in run_until_complete self.run_forever() │ └ <function BaseEventLoop.run_forever at 0x0000028CCD1FA680> └ <_WindowsSelectorEventLoop running=True closed=False debug=False> File "D:\application\Python310\lib\asyncio\base_events.py", line 595, in run_forever self._run_once() │ └ <function BaseEventLoop._run_once at 0x0000028CCD1FC1F0> └ <_WindowsSelectorEventLoop running=True closed=False debug=False> File "D:\application\Python310\lib\asyncio\base_events.py", line 1881, in _run_once handle._run() │ └ <function Handle._run at 0x0000028CCD13FAC0> └ <Handle Task.task_wakeup(<Future cancelled>)> File "D:\application\Python310\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) │ │ │ │ │ └ <member '_args' of 'Handle' objects> │ │ │ │ └ <Handle Task.task_wakeup(<Future cancelled>)> │ │ │ └ <member '_callback' of 'Handle' objects> │ │ └ <Handle Task.task_wakeup(<Future cancelled>)> │ └ <member '_context' of 'Handle' objects> └ <Handle Task.task_wakeup(<Future cancelled>)> > File "D:\pyVenv\mypyenv310\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 403, in run_asgi result = await app( # type: ignore[func-returns-value] └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x0000028CCD9B63B0> File "D:\pyVenv\mypyenv310\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57FE80>> │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <fastapi.applications.FastAPI object at 0x0000028CEAF5EC20> └ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x0000028CCD9B63B0> File "D:\pyVenv\mypyenv310\lib\site-packages\fastapi\applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57FE80>> │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\applications.py", line 113, in __call__ await self.middleware_stack(scope, receive, send) │ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57FE80>> │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x0000028CEB1C6C20> └ <fastapi.applications.FastAPI object at 0x0000028CEAF5EC20> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\errors.py", line 187, in __call__ raise exc File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\errors.py", line 165, in __call__ await self.app(scope, receive, _send) │ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x0000028CEB5DDA20> │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <starlette.middleware.cors.CORSMiddleware object at 0x0000028CEB1C6BF0> └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x0000028CEB1C6C20> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\cors.py", line 93, in __call__ await self.simple_response(scope, receive, send, request_headers=headers) │ │ │ │ │ └ Headers({'host': '127.0.0.1:9999', 'connection': 'keep-alive', 'content-length': '87', 'sec-ch-ua-platform': '"Windows"', 'us... │ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x0000028CEB5DDA20> │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <function CORSMiddleware.simple_response at 0x0000028CEAF6B640> └ <starlette.middleware.cors.CORSMiddleware object at 0x0000028CEB1C6BF0> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\cors.py", line 144, in simple_response await self.app(scope, receive, send) │ │ │ │ └ functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at 0x0000028CEB1C6BF0... │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <app.core.middlewares.BackGroundTaskMiddleware object at 0x0000028CEB1C6B90> └ <starlette.middleware.cors.CORSMiddleware object at 0x0000028CEB1C6BF0> File "E:\Code\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 28, in __call__ await self.handle_http(scope, receive, send) │ │ │ │ └ functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at 0x0000028CEB1C6BF0... │ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <function SimpleBaseMiddleware.handle_http at 0x0000028CEAF8C3A0> └ <app.core.middlewares.BackGroundTaskMiddleware object at 0x0000028CEB1C6B90> File "E:\Code\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 38, in handle_http await response(scope, receive, send_wrapper) │ │ │ └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x0000028CEBEA6050> │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.h11_impl.RequestResponseCycle object at 0x0000028CEB57F... │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... └ <app.core.middlewares.APILoggerMiddleware object at 0x0000028CEB1C6B30> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\base.py", line 185, in __call__ with collapse_excgroups(): └ <function collapse_excgroups at 0x0000028CCFAD4CA0> File "D:\application\Python310\lib\contextlib.py", line 153, in __exit__ self.gen.throw(typ, value, traceback) │ │ │ │ │ └ <traceback object at 0x0000028CEB417D40> │ │ │ │ └ ExceptionGroup('unhandled errors in a TaskGroup', [AttributeError("'NoneType' object has no attribute 'get'")]) │ │ │ └ <class 'exceptiongroup.ExceptionGroup'> │ │ └ <method 'throw' of 'generator' objects> │ └ <generator object collapse_excgroups at 0x0000028CEBF19FC0> └ <contextlib._GeneratorContextManager object at 0x0000028CEB57E9B0> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_utils.py", line 82, in collapse_excgroups raise exc File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\base.py", line 188, in __call__ await response(scope, wrapped_receive, send) │ │ │ └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x0000028CEBEA6050> │ │ └ <bound method _CachedRequest.wrapped_receive of <starlette.middleware.base._CachedRequest object at 0x0000028CEB57DFC0>> │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... └ <starlette.middleware.base._StreamingResponse object at 0x0000028CEB586C80> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\base.py", line 222, in __call__ async for chunk in self.body_iterator: │ └ <async_generator object BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.body_stream at 0x0000028CEB5D9140> └ <starlette.middleware.base._StreamingResponse object at 0x0000028CEB586C80> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\base.py", line 179, in body_stream raise app_exc └ AttributeError("'NoneType' object has no attribute 'get'") File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\base.py", line 149, in coro await self.app(scope, receive_or_disconnect, send_no_error) │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x0000028CEBF10310> │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <app.core.middlewares.APILoggerAddResponseMiddleware object at 0x0000028CEB1C6A70> └ <app.core.middlewares.APILoggerMiddleware object at 0x0000028CEB1C6B30> File "E:\Code\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 28, in __call__ await self.handle_http(scope, receive, send) │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x0000028CEBF10310> │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <function SimpleBaseMiddleware.handle_http at 0x0000028CEAF8C3A0> └ <app.core.middlewares.APILoggerAddResponseMiddleware object at 0x0000028CEB1C6A70> File "E:\Code\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 38, in handle_http await response(scope, receive, send_wrapper) │ │ │ └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x0000028CEBF10A60> │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... └ <starlette.middleware.exceptions.ExceptionMiddleware object at 0x0000028CEB1C6A40> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) │ │ │ │ │ │ └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x0000028CEBF10A60> │ │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ │ │ └ <starlette.requests.Request object at 0x0000028CEB585060> │ │ └ <fastapi.routing.APIRouter object at 0x0000028CEAF5E500> │ └ <starlette.middleware.exceptions.ExceptionMiddleware object at 0x0000028CEB1C6A40> └ <function wrap_app_handling_exceptions at 0x0000028CCFA97640> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app raise exc File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10790> │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... └ <fastapi.routing.APIRouter object at 0x0000028CEAF5E500> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\routing.py", line 715, in __call__ await self.middleware_stack(scope, receive, send) │ │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10790> │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <bound method Router.app of <fastapi.routing.APIRouter object at 0x0000028CEAF5E500>> └ <fastapi.routing.APIRouter object at 0x0000028CEAF5E500> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\routing.py", line 735, in app await route.handle(scope, receive, send) │ │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10790> │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <function Route.handle at 0x0000028CCFA40D30> └ APIRoute(path='/api/v1/zentao/dept/all', name='_', methods=['POST']) File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\routing.py", line 288, in handle await self.app(scope, receive, send) │ │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10790> │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ └ <function request_response.<locals>.app at 0x0000028CEB11A680> └ APIRoute(path='/api/v1/zentao/dept/all', name='_', methods=['POST']) File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) │ │ │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10790> │ │ │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... │ │ └ <starlette.requests.Request object at 0x0000028CEB585A80> │ └ <function request_response.<locals>.app.<locals>.app at 0x0000028CEBF10B80> └ <function wrap_app_handling_exceptions at 0x0000028CCFA97640> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app raise exc File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10C10> │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... └ <function request_response.<locals>.app.<locals>.app at 0x0000028CEBF10B80> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\routing.py", line 74, in app await response(scope, receive, send) │ │ │ └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10C10> │ │ └ <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x0000028CEBEA5F30> │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 9999), 'cl... └ <starlette.responses.JSONResponse object at 0x0000028CEB584850> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\responses.py", line 155, in __call__ await send({"type": prefix + "http.response.body", "body": self.body}) │ │ │ └ b'null' │ │ └ <starlette.responses.JSONResponse object at 0x0000028CEB584850> │ └ '' └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10C10> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_exception_handler.py", line 39, in sender await send(message) │ └ {'type': 'http.response.body', 'body': b'null'} └ <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x0000028CEBF10790> File "D:\pyVenv\mypyenv310\lib\site-packages\starlette\_exception_handler.py", line 39, in sender await send(message) │ └ {'type': 'http.response.body', 'body': b'null'} └ <function SimpleBaseMiddleware.handle_http.<locals>.send_wrapper at 0x0000028CEBF10A60> File "E:\Code\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 35, in send_wrapper await self.after_request(request, _response) │ │ │ └ {'type': 'http.response.body', 'body': b'null'} │ │ └ <starlette.requests.Request object at 0x0000028CEB584040> │ └ <function APILoggerAddResponseMiddleware.after_request at 0x0000028CEAF8C700> └ <app.core.middlewares.APILoggerAddResponseMiddleware object at 0x0000028CEB1C6A70> File "E:\Code\EquipmentRegistryDataPlatform\app\core\middlewares.py", line 120, in after_request api_log_obj.response_code = resp.get("code", "-1") │ │ └ None │ └ None └ <APILog: 11321> AttributeError: 'NoneType' object has no attribute 'get'

ERROR: Exception in ASGI application Traceback (most recent call last): File "D:\anaconda3\Lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 403, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__ return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\fastapi\applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__ raise exc File "D:\anaconda3\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__ await self.app(scope, receive, _send) File "D:\anaconda3\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app raise exc File "D:\anaconda3\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "D:\anaconda3\Lib\site-packages\starlette\routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\routing.py", line 734, in app await route.handle(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\routing.py", line 288, in handle await self.app(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "D:\anaconda3\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app raise exc File "D:\anaconda3\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "D:\anaconda3\Lib\site-packages\starlette\routing.py", line 73, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\fastapi\applications.py", line 1009, in openapi return JSONResponse(self.openapi()) ^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\fastapi\applications.py", line 981, in openapi self.openapi_schema = get_openapi( ^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\fastapi\openapi\utils.py", line 514, in get_openapi field_mapping, definitions = get_definitions( ^^^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\fastapi\_compat.py", line 232, in get_definitions field_mapping, definitions = schema_generator.generate_definitions( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\pydantic\json_schema.py", line 363, in generate_definitions self.generate_inner(schema) File "D:\anaconda3\Lib\site-packages\pydantic\json_schema.py", line 443, in generate_inner if 'ref' in schema: ^^^^^^^^^^^^^^^ File "<frozen _collections_abc>", line 813, in __contains__ File "D:\anaconda3\Lib\site-packages\pydantic\_internal\_mock_val_ser.py", line 41, in __getitem__ return self._get_built().__getitem__(key) ^^^^^^^^^^^^^^^^^ File "D:\anaconda3\Lib\site-packages\pydantic\_internal\_mock_val_ser.py", line 58, in _get_built raise PydanticUserError(self._error_message, code=self._code) pydantic.errors.PydanticUserError: TypeAdapter[typing.Annotated[langserve.validation.openaiInvokeRequest, <class 'langserve.validation.openaiInvokeRequest'>, Body(PydanticUndefined)]] is not fully defined; you should define typing.Annotated[langserve.validation.openaiInvokeRequest, <class 'langserve.validation.openaiInvokeRequest'>, Body(PydanticUndefined)] and all referenced types, then call .rebuild() on the instance. For further information visit https://errors.pydantic.dev/2.11/u/class-not-fully-defined

import os import sys import shutil import tempfile import logging from fastapi import FastAPI, File, UploadFile, HTTPException from fastapi.responses import JSONResponse, FileResponse import time import json from pathlib import Path import uvicorn import warnings import torch from inference import CombinedPredictor, process_single_image, process_video # 直接导入检测类和函数 # 配置日志 logging.basicConfig( filename='api_errors.log', level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s' ) # 忽略弃用警告 warnings.filterwarnings("ignore", category=DeprecationWarning) app = FastAPI(title="目标检测服务", description="通过FastAPI调用inference.py进行目标检测") # 配置参数 OUTPUT_BASE_DIR = "api_results" # 输出结果的基础目录 def get_resource_path(relative_path): """获取资源文件的路径,兼容打包后的环境""" if getattr(sys, 'frozen', False): # 如果是打包后的环境 base_path = sys._MEIPASS else: # 如果是开发环境 base_path = os.path.dirname(os.path.abspath(__file__)) return os.path.join(base_path, relative_path) # 全局预测器 predictor = None @app.on_event("startup") def startup_event(): """应用启动时初始化预测器""" global predictor os.makedirs(OUTPUT_BASE_DIR, exist_ok=True) try: # 初始化预测器 device = "cuda" if torch.cuda.is_available() else "cpu" predictor = CombinedPredictor( yolo_model_path=get_resource_path("ultralytics/best.pt"), wsdan_model_path=get_resource_path("models/model.ckpt"), num_classes=60, class_names_path=get_resource_path("models/classes.txt"), device=device, conf_threshold=0.2, nms_threshold=0.45 ) print("预测器初始化成功") except Exception as e: print(f"预测器初始化失败: {str(e)}") raise HTTPException(status_code=500, detail=f"预测器初始化失败: {str(e)}") @app.post("/detect/image/") async def detect_image(file: UploadFile = File(...)): """处理单张图像的检测请求""" return await process_file(file, is_video=False) @app.post("/detect/video/") async def detect_video(file: UploadFile = File(...)): """处理视频的检测请求""" return await process_file(file, is_video=True) async def process_file(file: UploadFile, is_video: bool): """处理上传的文件并调用检测函数""" global predictor try: # 创建临时目录 with tempfile.TemporaryDirectory() as temp_dir: temp_file_path = os.path.join(temp_dir, file.filename) # 保存上传的文件到临时目录 with open(temp_file_path, "wb") as buffer: shutil.copyfileobj(file.file, buffer) # 创建唯一的输出目录 timestamp = int(time.time()) output_dir = os.path.join(OUTPUT_BASE_DIR, f"result_{timestamp}") os.makedirs(output_dir, exist_ok=True) # 打印调试信息 print(f"临时文件路径: {temp_file_path}") print(f"输出目录: {output_dir}") # 检查预测器是否初始化 if predictor is None: raise HTTPException(status_code=500, detail="预测器未初始化") # 设置参数 box_color = (0, 255, 0) # BGR格式 box_thickness = 2 text_color = (0, 255, 0) text_size = 0.5 text_font = "FONT_HERSHEY_SIMPLEX" # 处理文件 if is_video: output_path = process_video( predictor=predictor, video_path=temp_file_path, output_dir=output_dir, box_color=box_color, box_thickness=box_thickness, text_color=text_color, text_size=text_size, text_font=text_font ) else: output_path = process_single_image( predictor=predictor, image_path=temp_file_path, output_dir=output_dir, box_color=box_color, box_thickness=box_thickness, text_color=text_color, text_size=text_size, text_font=text_font ) # 查找结果文件 result_files = find_result_files(output_dir, file.filename) if not result_files: raise HTTPException(status_code=500, detail="未找到检测结果文件") # 返回结果文件信息 return { "status": "success", "input_file": file.filename, "output_dir": output_dir, "result_files": result_files } except Exception as e: error_msg = f"处理文件时出错: {str(e)}" logging.error(error_msg) # 记录异常到日志 print(error_msg) raise HTTPException(status_code=500, detail=error_msg) def find_result_files(output_dir, original_filename): """查找检测结果文件""" base_name = os.path.splitext(original_filename)[0] result_files = [] # 查找图像结果 img_result = os.path.join(output_dir, f"{base_name}_result.jpg") if os.path.exists(img_result): result_files.append({ "type": "image_result", "path": img_result, "url": f"/results/{os.path.basename(img_result)}" }) # 查找视频结果 video_result = os.path.join(output_dir, f"{base_name}_result.mp4") if os.path.exists(video_result): result_files.append({ "type": "video_result", "path": video_result, "url": f"/results/{os.path.basename(video_result)}" }) # 查找JSON结果 json_result = os.path.join(output_dir, f"{base_name}_first_detection.json") if os.path.exists(json_result): result_files.append({ "type": "json_result", "path": json_result, "url": f"/results/{os.path.basename(json_result)}" }) return result_files @app.get("/results/{file_name}") async def get_result_file(file_name: str): """获取结果文件""" file_path = os.path.join(OUTPUT_BASE_DIR, "*", file_name) matching_files = list(Path(OUTPUT_BASE_DIR).glob(f"**/{file_name}")) if not matching_files: raise HTTPException(status_code=404, detail="结果文件不存在") # 返回第一个匹配的文件 return FileResponse(matching_files[0]) @app.get("/") async def root(): """服务根端点,返回API信息""" return { "message": "目标检测API服务已启动", "available_endpoints": [ "/detect/image/", "/detect/video/", "/results/{file_name}" ] } # 添加命令行入口点 if __name__ == "__main__": uvicorn.run( "api:app", host="0.0.0.0", port=8000, log_level="info" )如何将该api.py代码打包为exe文件

最新推荐

recommend-type

802.1ag_802.3ah_Y.1731_以太网OAM笔记

OAMPDU的Destination Address(DA)是Slow_Protocols_Multicast address,0x0180-C200-0002,慢速协议报文的特点就是不能被网桥转发,因此无论是否具备OAM功能或OAM功能是否激活,EFM OAM报文都不能跨多跳转发。...
recommend-type

基于COMSOL的压裂井降压开采数值模拟:地层压力与流场分布研究

利用COMSOL Multiphysics进行压裂井降压开采的数值模拟过程。首先,通过对特定油藏地区的岩层性质和流体分布进行初步勘测和分析,建立了三维地质模型,考虑了地层层次结构、岩石物理性质(如渗透率、孔隙度)和流体属性(如粘度、密度)。接着,在模型中设定了流体在多孔介质中流动的物理场,并配置了适当的流体源和压力边界条件。随后,使用流体流动和固体力学模块模拟了压裂过程,观察到裂缝的形成和扩展及其对周围地层的影响。最后,展示了模拟得到的地层压力和流场分布图,并附上了一段简化的COMSOL代码示例,解释了如何设置物理场和边界条件。通过这次模拟,不仅可以熟悉压裂开采的模拟方法,还能将其应用于油藏开采和地热开采等领域。 适合人群:从事能源开采领域的研究人员和技术人员,尤其是对压裂井降压开采感兴趣的从业者。 使用场景及目标:适用于希望深入了解压裂井降压开采过程的研究人员和技术人员,旨在提高对地下流体运动和压力变化的理解,优化开采过程。 其他说明:文中提供的代码示例有助于读者快速入门COMSOL的流体流动仿真设置,同时模拟结果为实际开采提供了宝贵的数据支持。
recommend-type

工业自动化领域汇川中大型PLC(AM600AM400AC800)模版的模块化编程及其应用

内容概要:本文介绍了汇川中大型PLC模版(AM600、AM400、AC800)的特点和优势,重点阐述了模块化编程方法的应用。文中提到,这些模版不仅结构清晰、稳定可靠,而且易于扩展和维护。此外,文章还提供了一个新能源项目的PLC程序实例,展示了如何利用指针和for循环遍历的方式简化多轴控制系统的设计。同时,文中附带了空模版和实际案例模版,便于初学者和从业者快速上手并应用于实际项目中。 适合人群:从事工业自动化领域的工程师和技术人员,特别是那些希望提高PLC编程技能或者正在寻找高效编程解决方案的专业人士。 使用场景及目标:①学习和掌握汇川中大型PLC模版的模块化编程技巧;②通过实际案例加深对多轴控制系统的理解;③利用提供的模版加速新项目的开发进程。 其他说明:文中提供的程序实例和模版有助于读者更好地理解和实践PLC编程,但需要注意的是,软件一旦售出不可退换。
recommend-type

前端分析-2023071100789s

前端分析-2023071100789s
recommend-type

GHCN气象站邻接矩阵的Python实现及地理距离应用

根据提供的文件信息,我们可以解析出以下知识点: **标题:“GHCN_邻接矩阵”** 全球历史气候网络(Global Historical Climatology Network,简称GHCN)是一个国际性项目,旨在收集和提供全球范围内的历史气候数据。邻接矩阵(Adjacency Matrix)是图论中的一个概念,用来表示图中各个顶点之间的相邻关系。 **知识点详细说明:** 1. **全球历史气候网络(GHCN):** - GHCN是一个汇集了全球范围内的历史气候数据资料的大型数据库。该数据库主要收集了全球各地的气象站提供的气温、降水、风速等气象数据。 - 这些数据的时间跨度很广,有些甚至可以追溯到19世纪中叶,为气候学家和相关研究人员提供了丰富的气候变迁数据。 - 通过分析这些数据,科学家可以研究气候变化的趋势、模式以及影响因素等。 2. **邻接矩阵:** - 在图论中,邻接矩阵是用来表示图中各个顶点之间相互连接关系的矩阵。 - 无向图的邻接矩阵是一个对称矩阵,如果顶点i与顶点j之间存在一条边,则矩阵中的元素A[i][j]和A[j][i]为1;否则为0。 - 邻接矩阵常用于计算机算法中,比如用于计算最短路径、网络的连通性、以及进行图的遍历等。 3. **地理距离:** - 在这个问题的上下文中,指的是气象站之间的空间距离。 - 计算气象站之间的地理距离通常使用地理信息系统(GIS)或球面几何学的方法,比如使用哈弗辛公式(Haversine formula)计算两个地点之间的大圆距离。 - 通过地理距离数据,可以推断出气候数据在空间分布上的相关性或依赖性。 4. **Python编程语言:** - 标签中提及的Python是一种广泛应用于数据科学、人工智能、网络开发等领域的高级编程语言。 - Python因其易学易用、语法简洁、库支持丰富等特点,在科研、教育、工业界等领域得到广泛应用。 5. **代码实现:** - 提到的代码应该会涉及获取GHCN数据集、计算气象站间的地理距离、以及根据这些距离构建无向图的邻接矩阵。 - 代码可能使用了Python中的科学计算库,如NumPy或SciPy,以及地理计算库,如geopy或Shapely。 - 通过构建邻接矩阵,此代码可以进一步用于分析气候数据的空间分布特征或执行图相关的数据分析任务。 **文件名称列表:“GHCN_Adjacency_Matrix-main”** 文件名“GHCN_Adjacency_Matrix-main”表明这是一个包含主要代码文件的文件夹。在Python中,“main”一词通常表示该文件夹中的某个脚本文件(如“main.py”)是程序的入口点,它是运行程序时最先被调用的文件。 总结以上内容,我们可知该文件描述了一个使用Python语言,通过处理全球历史气候网络(GHCN)中的数据来生成气象站之间地理距离的邻接矩阵的代码。这种邻接矩阵可以用于气候数据分析中的图论应用,如研究气象站点数据的空间分布模式和关系。代码的实现可能用到了多种Python库,旨在为气候研究提供一种新的数据处理和分析视角。
recommend-type

并发编程:多语言实践与策略选择

### 并发编程:多语言实践与策略选择 #### 1. 文件大小计算的并发实现 在并发计算文件大小的场景中,我们可以采用数据流式方法。具体操作如下: - 创建两个 `DataFlowQueue` 实例,一个用于记录活跃的文件访问,另一个用于接收文件和子目录的大小。 - 创建一个 `DefaultPGroup` 来在线程池中运行任务。 ```plaintext graph LR A[创建 DataFlowQueue 实例] --> B[创建 DefaultPGroup] B --> C[执行 findSize 方法] C --> D[执行 findTotalFileS
recommend-type

3utools使用教程

<think>我们注意到用户查询的是"3utools",但引用中提到的都是"uTools"(没有数字3)。这可能是一个拼写错误或版本差异。 根据引用内容,uTools是一个桌面效率工具,提供插件化的功能。因此,我们假设用户指的是uTools,并据此提供使用指南。 如果确实存在名为"3uTools"的软件(例如,苹果设备管理工具),那么我们需要澄清:引用中提到的uTools与3uTools不同。 但是,由于引用中只提到了uTools,且用户的问题中写的是“3utools”(可能是uTools的误写),我们将按照uTools来回答。 如果用户确实指的是另一个软件(3uTools),那么
recommend-type

探索更多视频功能的JavaScript实现

从给定的信息中我们可以提炼出关键词"更多视频"以及"JavaScript",以及一个与文件相关的命名"MoreVideo-master"。接下来,我会针对这些关键词展开详细的IT知识点阐述。 首先,关于“更多视频”,这个描述暗示了我们即将探讨的是与视频内容相关的技术或应用。在现代IT领域中,视频内容的处理、存储、传输和播放是一个非常重要的分支,涉及到的技术包括但不限于视频编码、流媒体技术、网络协议、前端展示技术等。视频内容的增多以及互联网带宽的不断提升,使得在线视频消费成为可能。从最早的ASCII动画到现代的高清视频,技术的演进一直不断推动着我们向更高质量和更多样化的视频内容靠近。 其次,“JavaScript”是IT行业中的一个关键知识点。它是一种广泛使用的脚本语言,特别适用于网页开发。JavaScript可以实现网页上的动态交互,比如表单验证、动画效果、异步数据加载(AJAX)、以及单页应用(SPA)等。作为一种客户端脚本语言,JavaScript可以对用户的输入做出即时反应,无需重新加载页面。此外,JavaScript还可以运行在服务器端(例如Node.js),这进一步拓宽了它的应用范围。 在探讨JavaScript时,不得不提的是Web前端开发。在现代的Web应用开发中,前端开发越来越成为项目的重要组成部分。前端开发人员需要掌握HTML、CSS和JavaScript这三大核心技术。其中,JavaScript负责赋予网页以动态效果,提升用户体验。JavaScript的库和框架也非常丰富,比如jQuery、React、Vue、Angular等,它们可以帮助开发者更加高效地编写和管理前端代码。 最后,关于文件名“MoreVideo-master”,这里的“Master”通常表示这是一个项目或者源代码的主版本。例如,在使用版本控制系统(如Git)时,“Master”分支通常被认为是项目的主分支,包含最新的稳定代码。文件名中的“MoreVideo”表明该项目与视频相关的内容处理功能正在增加或扩展。可能是对现有功能的增强,也可能是为视频播放、视频处理或视频管理增加了新的模块或特性。 综合上述内容,我们可以总结出以下几个IT知识点: 1. 视频技术:包括视频编解码技术、流媒体技术、网络协议、视频格式转换等。在客户端和服务器端,视频技术的应用场景广泛,如在线视频平台、视频会议系统、视频监控系统等。 2. JavaScript应用:JavaScript在Web前端开发中的应用十分广泛,用于实现网页的动态效果和交互性,以及在后端通过Node.js提供服务器端编程能力。 3. 前端开发技术:前端开发不仅仅是页面的静态显示,更重要的是通过JavaScript、CSS和HTML等技术实现用户界面与用户之间的交互。前端框架和库的使用大大提高了开发效率。 4. 版本控制:在IT项目开发过程中,版本控制是一个重要的环节。它帮助开发者管理代码的变更历史,支持多人协作开发,使得代码维护和升级变得更加容易。 通过以上知识点,我们可以看到,无论是“更多视频”的技术应用还是“JavaScript”编程语言的使用,以及文件命名所隐含的项目管理概念,都是IT领域内相互关联且密不可分的几个重要方面。
recommend-type

并发编程中的Clojure代理与相关技术解析

### 并发编程中的Clojure代理与相关技术解析 #### 1. Clojure代理概述 Clojure代理代表内存中的单个标识或位置。与软件事务内存(STM)的引用管理多个标识的协调同步更改不同,代理允许对其管理的单个标识进行独立的异步更改。这些更改以函数或操作的形式表达,并异步应用于该位置。多个独立的并发操作会按顺序依次运行。操作成功完成后,代理将更新为操作返回的新状态,该新状态用于后续对代理的读取或操作。 调用在代理上运行操作的方法会立即返回,操作随后会使用Clojure管理的线程池中的一个线程应用于代理。如果操作主要受CPU限制,可使用`send()`方法运行;如果函数中可能发
recommend-type

windows电脑如何安装华为电脑管家

<think>首先,用户的问题是:“我想在Windows电脑上安装华为电脑管家 请问如何在Windows系统上安装和配置华为电脑管家”。这基于之前的引用,是关于在非华为电脑上安装华为电脑管家的指南。 引用提供了几个来源: - [^1]:非华为电脑安装华为电脑管家指南,项目地址:https://gitcode.com/open-source-toolkit/90481 - [^2]:win10或11非华为电脑安装最新的电脑管家,包括安装方法和问题解决 - [^3]:华为电脑管家傻瓜一键安装版,适用于win10,支持非华为电脑 - [^4]:提供旧版本华为电脑管家的链接和卸载方法 - [^5]: