# fastapi-yolo8 **Repository Path**: finsiot-dev/fastapi-yolo8 ## Basic Information - **Project Name**: fastapi-yolo8 - **Description**: 集成fastapi uvicorn ultralytics,实现的高并发请求的接口 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2025-02-20 - **Last Updated**: 2025-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 工程说明 ``` # 目录结构 project-root/ ├── app/ │ ├── config/ # 配置模块 │ │ ├── __init__.py │ │ └── settings.py │ ├── dependencies/ # 依赖注入 │ │ ├── __init__.py │ │ └── model_deps.py │ ├── models/ # 模型相关 │ │ ├── __init__.py │ │ └── yolo_model.py │ ├── routers/v1 # 路由模块 │ │ ├── __init__.py │ │ └── v1 │ │ ├── __init__.py │ │ ├── detection_api.py │ ├── schemas/ # 数据模型 │ │ ├── __init__.py │ │ ├── detection.py │ │ └── response.py │ ├── services/ # 业务逻辑 │ │ ├── __init__.py │ │ ├── cache.py │ │ ├── detection.py │ │ └── image_processing.py │ ├── utils/ # 工具函数 │ │ ├── __init__.py │ │ ├── base64.py │ │ └── logger.py │ └── main.py # 应用入口 ├── tests │ ├── __init__.py │ └── test_image_detection.py ├── Dockerfile ├── requirements.txt └── README.md ``` ## 安装说明 ```shell pip install fastapi uvicorn ultralytics opencv-python-headless python-multipart pydantic-settings pip install -r requirements.txt uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4 pytest tests/ ``` 测试 ```shell curl -X POST "http://localhost:8000/api/v1/detect/file" \ -H "Content-Type: multipart/form-data" \ -F "file=@test.jpg" \ -F "confidence=0.6" curl -X POST "http://localhost:8000/api/v1/detect/base64" \ -H "Content-Type: application/json" \ -d '{"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...", "confidence": 0.7}' ```