Compare commits
5 Commits
ebcd7dcdcb
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a185affc3 | |||
| d5457e02ca | |||
| ce061d7840 | |||
| 5e859c4f95 | |||
| 68b14a4bec |
BIN
ailai_pc/best.pt
Normal file
|
Before Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB |
@ -7,7 +7,7 @@ import cv2
|
|||||||
# 配置参数
|
# 配置参数
|
||||||
# ======================
|
# ======================
|
||||||
MODEL_PATH = '/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai_detect2/weights/best.pt'
|
MODEL_PATH = '/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai_detect2/weights/best.pt'
|
||||||
IMG_PATH = '4.jpg'
|
IMG_PATH = '3.jpg'
|
||||||
OUTPUT_PATH = 'output_pt.jpg'
|
OUTPUT_PATH = 'output_pt.jpg'
|
||||||
CONF_THRESH = 0.5
|
CONF_THRESH = 0.5
|
||||||
IOU_THRESH = 0.45
|
IOU_THRESH = 0.45
|
||||||
|
|||||||
@ -9,13 +9,14 @@ from pathlib import Path
|
|||||||
# ======================
|
# ======================
|
||||||
# 配置参数
|
# 配置参数
|
||||||
# ======================
|
# ======================
|
||||||
MODEL_PATH = '/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai_detect/weights/best.pt'
|
MODEL_PATH = "/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai_detect3/weights/best.pt"
|
||||||
INPUT_FOLDER = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/ailaidete/train/bag'
|
IMAGE_DIR = "/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/ailaidete/train/delet"
|
||||||
OUTPUT_FOLDER = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/ailaidete/train/bag'
|
INPUT_FOLDER = "/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/ailaidete/train/delet"
|
||||||
|
OUTPUT_FOLDER = "/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/ailaidete/train/delet"
|
||||||
|
|
||||||
CONF_BUCKETS = [0.93, 0.95] # ← ⭐ 自己改这里
|
CONF_BUCKETS = [0.93, 0.95] # ← ⭐ 自己改这里
|
||||||
IOU_THRESH = 0.45
|
IOU_THRESH = 0.45
|
||||||
CLASS_NAMES = ['bag']
|
CLASS_NAMES = ['bag','bag35']
|
||||||
|
|
||||||
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
||||||
IMG_SIZE = 640
|
IMG_SIZE = 640
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 255 KiB |
|
Before Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 244 KiB |
@ -1 +0,0 @@
|
|||||||
617.1340942382812 225.45236206054688
|
|
||||||
@ -1 +0,0 @@
|
|||||||
617.1340942382812 225.45236206054688
|
|
||||||
|
Before Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 692 KiB After Width: | Height: | Size: 733 KiB |
@ -5,10 +5,10 @@ from ultralytics import YOLO
|
|||||||
|
|
||||||
# ====================== 用户配置 ======================
|
# ====================== 用户配置 ======================
|
||||||
#MODEL_PATH = '/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai2/weights/best.pt'
|
#MODEL_PATH = '/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai2/weights/best.pt'
|
||||||
MODEL_PATH = 'point.pt'
|
MODEL_PATH = 'pointn.pt'
|
||||||
IMAGE_SOURCE_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/20251214' # 验证集图片目录
|
IMAGE_SOURCE_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/test' # 验证集图片目录
|
||||||
LABEL_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/20251214' # 标签目录(与图片同名 .txt)
|
LABEL_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/test' # 标签目录(与图片同名 .txt)
|
||||||
OUTPUT_DIR = './output_images'
|
OUTPUT_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/test/output_images'
|
||||||
|
|
||||||
|
|
||||||
IMG_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.tif', '.webp'}
|
IMG_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.tif', '.webp'}
|
||||||
|
|||||||
@ -4,9 +4,9 @@ from ultralytics import YOLO
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# ====================== 用户配置 ======================
|
# ====================== 用户配置 ======================
|
||||||
MODEL_PATH = '/home/hx/yolo/ultralytics_yolo11-main/runs/train/exp_ailai/weights/best.pt'
|
MODEL_PATH = 'best.pt'
|
||||||
IMAGE_SOURCE_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/20251212' # 👈 修改为你的图像文件夹路径
|
IMAGE_SOURCE_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/20251226' # 👈 修改为你的图像文件夹路径
|
||||||
OUTPUT_DIR = './output_images' # 保存结果的文件夹
|
OUTPUT_DIR = '/media/hx/04e879fa-d697-4b02-ac7e-a4148876ebb0/dataset/1/20251226/output_images' # 保存结果的文件夹
|
||||||
|
|
||||||
# 支持的图像扩展名
|
# 支持的图像扩展名
|
||||||
IMG_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.tif', '.webp'}
|
IMG_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.bmp', '.tiff', '.tif', '.webp'}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 407 KiB |
|
Before Width: | Height: | Size: 403 KiB |
|
Before Width: | Height: | Size: 368 KiB |
|
Before Width: | Height: | Size: 391 KiB |
|
Before Width: | Height: | Size: 377 KiB |
|
Before Width: | Height: | Size: 403 KiB |
|
Before Width: | Height: | Size: 380 KiB |
|
Before Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 324 KiB |
|
Before Width: | Height: | Size: 309 KiB |
|
Before Width: | Height: | Size: 393 KiB |
|
Before Width: | Height: | Size: 363 KiB |
|
Before Width: | Height: | Size: 345 KiB |
|
Before Width: | Height: | Size: 320 KiB |
|
Before Width: | Height: | Size: 360 KiB |
|
Before Width: | Height: | Size: 387 KiB |
|
Before Width: | Height: | Size: 386 KiB |
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 404 KiB |
|
Before Width: | Height: | Size: 392 KiB |
|
Before Width: | Height: | Size: 413 KiB |
|
Before Width: | Height: | Size: 359 KiB |
|
Before Width: | Height: | Size: 362 KiB |
|
Before Width: | Height: | Size: 361 KiB |
|
Before Width: | Height: | Size: 372 KiB |
|
Before Width: | Height: | Size: 352 KiB |
|
Before Width: | Height: | Size: 376 KiB |
|
Before Width: | Height: | Size: 344 KiB |
|
Before Width: | Height: | Size: 363 KiB |
|
Before Width: | Height: | Size: 358 KiB |
|
Before Width: | Height: | Size: 333 KiB |
|
Before Width: | Height: | Size: 396 KiB |
|
Before Width: | Height: | Size: 382 KiB |
|
Before Width: | Height: | Size: 382 KiB |
|
Before Width: | Height: | Size: 366 KiB |
|
Before Width: | Height: | Size: 376 KiB |
|
Before Width: | Height: | Size: 389 KiB |
|
Before Width: | Height: | Size: 356 KiB |
|
Before Width: | Height: | Size: 396 KiB |
|
Before Width: | Height: | Size: 441 KiB |
|
Before Width: | Height: | Size: 409 KiB |
|
Before Width: | Height: | Size: 346 KiB |
|
Before Width: | Height: | Size: 392 KiB |
|
Before Width: | Height: | Size: 404 KiB |
|
Before Width: | Height: | Size: 369 KiB |
|
Before Width: | Height: | Size: 421 KiB |
|
Before Width: | Height: | Size: 358 KiB |
|
Before Width: | Height: | Size: 363 KiB |
@ -46,7 +46,7 @@ def init_rknn_model(model_path):
|
|||||||
ret = rknn_lite.load_rknn(model_path)
|
ret = rknn_lite.load_rknn(model_path)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
raise RuntimeError(f'Load model failed: {ret}')
|
raise RuntimeError(f'Load model failed: {ret}')
|
||||||
ret = rknn_lite.init_runtime(core_mask=RKNNLite.NPU_CORE_0)
|
ret = rknn_lite.init_runtime()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
raise RuntimeError(f'Init runtime failed: {ret}')
|
raise RuntimeError(f'Init runtime failed: {ret}')
|
||||||
_global_rknn_instance = rknn_lite
|
_global_rknn_instance = rknn_lite
|
||||||
|
|||||||
BIN
detect_bagor35bag/test_image/bag3588.rknn
Normal file
@ -37,7 +37,7 @@ def init_rknn_once(model_path):
|
|||||||
print(f"[ERROR] Failed to load RKNN: {ret}")
|
print(f"[ERROR] Failed to load RKNN: {ret}")
|
||||||
_rknn_instance = None
|
_rknn_instance = None
|
||||||
return None
|
return None
|
||||||
ret = _rknn_instance.init_runtime(core_mask=RKNNLite.NPU_CORE_0)
|
ret = _rknn_instance.init_runtime()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
print(f"[ERROR] Failed to init RKNN runtime: {ret}")
|
print(f"[ERROR] Failed to init RKNN runtime: {ret}")
|
||||||
_rknn_instance = None
|
_rknn_instance = None
|
||||||
@ -173,8 +173,8 @@ def visualize_result(image, keypoints, bbox, fixed_point, offset_info, save_path
|
|||||||
|
|
||||||
# ====================== 主函数 ======================
|
# ====================== 主函数 ======================
|
||||||
|
|
||||||
def calculate_offset_from_image(image_path, visualize=False):
|
def calculate_offset_from_image(orig, visualize=False):
|
||||||
orig = cv2.imread(image_path)
|
|
||||||
if orig is None:
|
if orig is None:
|
||||||
return {'success': False, 'message': f'Failed to load image: {image_path}'}
|
return {'success': False, 'message': f'Failed to load image: {image_path}'}
|
||||||
|
|
||||||
@ -213,7 +213,8 @@ def calculate_offset_from_image(image_path, visualize=False):
|
|||||||
# ====================== 示例调用 ======================
|
# ====================== 示例调用 ======================
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
image_path = "11.jpg"
|
image_path = "11.jpg"
|
||||||
result = calculate_offset_from_image(image_path, visualize=False)
|
orig = cv2.imread(image_path)
|
||||||
|
result = calculate_offset_from_image(orig, visualize=False)
|
||||||
if result['success']:
|
if result['success']:
|
||||||
print(f"Center point: ({result['cx']:.1f}, {result['cy']:.1f})")
|
print(f"Center point: ({result['cx']:.1f}, {result['cy']:.1f})")
|
||||||
print(f"Offset: DeltaX={result['dx_mm']:+.2f} mm, DeltaY={result['dy_mm']:+.2f} mm")
|
print(f"Offset: DeltaX={result['dx_mm']:+.2f} mm, DeltaY={result['dy_mm']:+.2f} mm")
|
||||||
|
|||||||