Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- uses: astral-sh/setup-uv@v7
- run: uv pip install --system --no-cache build
- run: python -m build
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
Expand Down
6 changes: 5 additions & 1 deletion PROJECT_STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ ultralytics-main/
## 🚀 使用方法

### 1. 运行GUI应用(推荐)

```bash
python scripts/run_gui.py
```

### 2. 测试模型

```bash
# 测试图片
python scripts/test_model.py --source image.jpg
Expand All @@ -59,11 +61,13 @@ python scripts/test_model.py --source 0
```

### 3. 训练模型

```bash
python scripts/train_model.py
```

### 4. 验证模型

```bash
python scripts/validate_model.py
```
```
18 changes: 15 additions & 3 deletions UI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
### 方式一:使用运行脚本(推荐)

在项目根目录运行:

```bash
python run_gui.py
```
Expand All @@ -36,52 +37,64 @@ python -m hys.main
### 方式三:在代码中导入

```python
from hys import YOLODetectionGUI, main
import tkinter as tk

from hys import YOLODetectionGUI

root = tk.Tk()
app = YOLODetectionGUI(root)
root.mainloop()
```


## 模块说明

### config.py

包含所有配置常量:

- `MODEL_PATH` - YOLO模型路径
- `WINDOW_TITLE` - 窗口标题
- `WINDOW_SIZE` - 窗口大小
- `DND_AVAILABLE` - 拖拽功能是否可用

### gui_main.py

主窗口类 `YOLODetectionGUI`,负责:

- 模式选择界面
- 检测界面管理
- 文件选择和处理
- 结果保存

### detection_processor.py

检测处理器 `DetectionProcessor`,负责:

- 屏幕检测
- 摄像头检测
- 文件检测(图片/视频)

### file_handler.py

文件处理类 `FileHandler`,提供:

- 文件选择
- 文件类型判断
- 图片预览加载
- 检测结果保存

### gui_utils.py

线程安全的GUI更新器 `ThreadSafeGUIUpdater`,确保:

- 所有GUI更新在主线程执行
- 避免线程安全问题
- 安全的窗口关闭处理

### detection_ui.py

检测界面UI组件创建类 `DetectionUI`,提供:

- 统一的检测界面创建
- 文件检测特殊UI组件

Expand All @@ -100,4 +113,3 @@ root.mainloop()
```bash
pip install tkinterdnd2
```

8 changes: 3 additions & 5 deletions UI/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
YOLO目标检测GUI应用程序包
"""
"""YOLO目标检测GUI应用程序包."""

from .gui_main import YOLODetectionGUI
from .main import main

__all__ = ['YOLODetectionGUI', 'main']

__all__ = ["YOLODetectionGUI", "main"]
11 changes: 6 additions & 5 deletions UI/config.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
"""
配置和常量定义
"""
"""配置和常量定义."""

import tkinter as tk

# 尝试导入拖拽支持库(可选)
try:
from tkinterdnd2 import DND_FILES, TkinterDnD

DND_AVAILABLE = True
except ImportError:
DND_AVAILABLE = False

# 创建一个兼容类
class TkinterDnD:
class Tk(tk.Tk):
pass

# 定义 DND_FILES 占位符(即使不使用)
DND_FILES = None

Expand All @@ -35,8 +37,7 @@ class Tk(tk.Tk):

# 默认检测参数
DEFAULT_CONF = 0.25 # 默认置信度阈值 (0-1)
DEFAULT_IOU = 0.45 # 默认IoU阈值 (0-1)
DEFAULT_IOU = 0.45 # 默认IoU阈值 (0-1)

# 默认保存文件夹
DEFAULT_SAVE_DIR = "detection_saves" # 默认检测结果保存文件夹

Loading