feat: Refactor and reorganize project structure with new modules and files

- Deleted obsolete files including test scripts and configuration files to streamline the project.
- Introduced new modules for handling Douyin functionalities, including core operations, logging, and GUI components.
- Updated import paths to reflect the new module structure, enhancing code organization and maintainability.
- Added configuration files and documentation to support the new structure and improve user guidance.
This commit is contained in:
Your Name committed 2025-12-28 14:16:40 +08:00
1 parent ea7159355b
commit c67f22f76f
139 files changed
+7571 -7828

No files matched your search

+196
View File
@@ -0,0 +1,196 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
检查GPU是否可用的脚本
"""
import sys
# 修复Windows控制台编码问题
if sys.platform == "win32":
try:
sys.stdout.reconfigure(encoding="utf-8") # type: ignore[attr-defined]
except Exception:
pass
def check_torch_cuda():
"""检查PyTorch是否支持CUDA"""
try:
import torch # type: ignore
if torch.cuda.is_available():
print(f"[GPU检测] PyTorch CUDA可用")
print(f" CUDA版本: {torch.version.cuda}")
print(f" GPU数量: {torch.cuda.device_count()}")
for i in range(torch.cuda.device_count()):
print(f" GPU {i}: {torch.cuda.get_device_name(i)}")
return True
else:
print("[GPU检测] PyTorch CUDA不可用")
return False
except ImportError:
print("[GPU检测] PyTorch未安装")
return False
except Exception as e:
print(f"[GPU检测] PyTorch CUDA检测失败: {e}")
return False
def check_easyocr_gpu():
"""检查EasyOCR是否可以使用GPU"""
try:
import easyocr # type: ignore
print("[GPU检测] EasyOCR已安装")
# EasyOCR使用PyTorch,所以需要PyTorch支持CUDA
try:
import torch # type: ignore
if torch.cuda.is_available():
print("[GPU检测] EasyOCR可以使用GPU(通过PyTorch CUDA)")
return True
else:
print("[GPU检测] EasyOCR无法使用GPU(PyTorch CUDA不可用)")
return False
except ImportError:
print("[GPU检测] EasyOCR需要PyTorch才能使用GPU")
return False
except ImportError:
print("[GPU检测] EasyOCR未安装")
return False
except Exception as e:
print(f"[GPU检测] EasyOCR GPU检测失败: {e}")
return False
def check_paddleocr_gpu():
"""检查PaddleOCR是否可以使用GPU"""
try:
from paddleocr import PaddleOCR
print("[GPU检测] PaddleOCR已安装")
# PaddleOCR需要paddlepaddle-gpu版本
try:
import paddle
if paddle.device.is_compiled_with_cuda():
print("[GPU检测] PaddleOCR可以使用GPU(paddlepaddle-gpu已安装)")
if paddle.device.get_device():
print(f" Paddle设备: {paddle.device.get_device()}")
return True
else:
print("[GPU检测] PaddleOCR无法使用GPU(需要安装paddlepaddle-gpu)")
return False
except ImportError:
print("[GPU检测] PaddleOCR需要paddlepaddle才能使用GPU")
return False
except ImportError:
print("[GPU检测] PaddleOCR未安装")
return False
except Exception as e:
print(f"[GPU检测] PaddleOCR GPU检测失败: {e}")
return False
def check_integrated_graphics():
"""检查是否是集成显卡(核显)"""
try:
import torch # type: ignore
if torch.cuda.is_available():
for i in range(torch.cuda.device_count()):
gpu_name = torch.cuda.get_device_name(i).lower()
# 常见的核显标识
integrated_keywords = [
"intel",
"iris",
"uhd",
"hd graphics",
"amd",
"radeon vega",
"radeon graphics",
]
is_integrated = any(
keyword in gpu_name for keyword in integrated_keywords
)
if is_integrated:
print(
f"[GPU检测] 检测到可能是集成显卡: {torch.cuda.get_device_name(i)}"
)
print("[GPU检测] 警告:集成显卡的GPU加速效果可能不明显")
return True
except Exception:
pass
return False
def main():
"""主函数"""
print("=" * 60)
print("GPU可用性检测")
print("=" * 60)
print()
# 检查PyTorch CUDA
print("[1] 检查PyTorch CUDA支持")
torch_cuda_available = check_torch_cuda()
print()
# 检查是否是核显
is_integrated = False # 初始化,避免未绑定错误
if torch_cuda_available:
print("[2] 检查显卡类型")
is_integrated = check_integrated_graphics()
print()
# 检查EasyOCR GPU支持
print("[3] 检查EasyOCR GPU支持")
easyocr_gpu_available = check_easyocr_gpu()
print()
# 检查PaddleOCR GPU支持
print("[4] 检查PaddleOCR GPU支持")
paddleocr_gpu_available = check_paddleocr_gpu()
print()
# 总结
print("=" * 60)
print("检测结果总结")
print("=" * 60)
if torch_cuda_available:
print("[OK] PyTorch CUDA可用")
if is_integrated:
print("[WARN] 检测到集成显卡,GPU加速效果可能有限")
else:
print("[OK] 检测到独立显卡,GPU加速效果较好")
else:
print("[NO] PyTorch CUDA不可用(将使用CPU模式)")
if easyocr_gpu_available:
print("[OK] EasyOCR可以使用GPU")
else:
print("[NO] EasyOCR无法使用GPU(将使用CPU模式)")
if paddleocr_gpu_available:
print("[OK] PaddleOCR可以使用GPU")
else:
print("[NO] PaddleOCR无法使用GPU(将使用CPU模式)")
print()
print("建议:")
if not torch_cuda_available:
print(" - 如果使用NVIDIA独立显卡,请安装CUDA和PyTorch GPU版本")
print(" - 如果使用集成显卡,GPU加速效果可能不明显,建议继续使用CPU模式")
elif is_integrated:
print(" - 集成显卡的GPU加速效果可能不明显")
print(" - 可以尝试启用GPU,但性能提升可能有限")
print(" - 如果遇到问题,建议继续使用CPU模式")
else:
print(" - 可以启用GPU加速以提升OCR性能")
print(" - 修改 Underlying_Operations.py 中的 gpu=False 为 gpu=True")
if __name__ == "__main__":
main()