国产chinesehdxxxx老太婆,办公室玩弄爆乳女秘hd,扒开腿狂躁女人爽出白浆 ,丁香婷婷激情俺也去俺来也,ww国产内射精品后入国产

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線(xiàn)課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

把YOLOv11和Python Qt做個(gè)用戶(hù)界面程序

安費(fèi)諾傳感器學(xué)堂 ? 來(lái)源:安費(fèi)諾傳感器學(xué)堂 ? 2024-11-28 10:18 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

早些時(shí)間,小編想把PID控制器優(yōu)化部分通過(guò)Py Qt來(lái)實(shí)現(xiàn)用戶(hù)界面化,不過(guò)看著窗口一堆參數(shù),有點(diǎn)發(fā)怵:這玩意誰(shuí)用?。?/p>

9e185014-a936-11ef-93f3-92fbcf53809c.png

參考《PID控制器參數(shù)自動(dòng)優(yōu)化示例和比較》

后來(lái)就擱置了。 在通過(guò)Python以及YOLO來(lái)檢測(cè)圖中或者視頻中的各種物體以及人物的時(shí)候,就會(huì)考慮:全部用代碼來(lái)輸出的?怎么通過(guò)一個(gè)簡(jiǎn)單直觀的窗口界面來(lái)測(cè)試相應(yīng)的功能?我覺(jué)得要再試一下,哪怕是最簡(jiǎn)單的方式呈現(xiàn)。這便是這篇文章的目的所在。 我們通過(guò)YOLO現(xiàn)成的各種檢測(cè)模塊,實(shí)現(xiàn):

圖中物體的識(shí)別檢測(cè)

檢出物體的區(qū)域分割

人體姿態(tài)的檢測(cè)

還有其他的檢測(cè)功能,感覺(jué)功能有重疊,就選了上面的三個(gè)功能簡(jiǎn)單地集成到一個(gè)windows的因?yàn)榉诸?lèi)的功能只是軟件界面中。 以下圖片均有AI生成,但是人體姿態(tài)檢測(cè)的結(jié)果可能看不清楚輸出。

按照我們之前的慣例,先提供結(jié)果,后提供代碼。

9e83512a-a936-11ef-93f3-92fbcf53809c.png

[1]物體檢測(cè)

9eb9e1f4-a936-11ef-93f3-92fbcf53809c.png

[2]物體分割

9efb1868-a936-11ef-93f3-92fbcf53809c.png

[3]姿態(tài)檢測(cè)

我們可以自己嘗試運(yùn)行一下。

# This program is part of a project developed by Amphenol Sensors.
#Copyright(C)2024,Leo Lu
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .


import sys
from PyQt5.QtWidgets import (QApplication, QLabel, QPushButton, QVBoxLayout, QWidget, 
                             QFileDialog, QComboBox, QHBoxLayout)
from PyQt5.QtGui import QPixmap, QImage
from PyQt5.QtCore import Qt
import cv2
import numpy as np
import random


from ultralytics import YOLO
from ultralytics.models.yolo.pose.predict import PosePredictor


class YOLOInterface(QWidget):
    def __init__(self):
        super().__init__()


        self.initUI()
        self.model_detec = YOLO('./yolo_models/yolo11s.pt')
        self.model_seg = YOLO('./yolo_models/yolo11s-seg.pt')
        self.model_bd = './yolo_models/yolo11s-pose.pt'
        self.connections = ((2, 4), (1, 3), (10, 8), (8, 6), (6, 5), (5, 7), (7, 9), 
                            (6, 12), (12, 14), (14, 16), (5, 11), (11, 13), (13, 15))


    def initUI(self):
        self.setWindowTitle('YOLO 圖像檢測(cè)')
        self.setGeometry(100, 100, 1200, 600)
        self.setFixedSize(1200, 600)
        # 主布局
        main_layout = QVBoxLayout()


        # 圖像顯示布局
        image_layout = QHBoxLayout()


        self.image_label = QLabel(self)
        self.image_label.setFixedSize(600, 400)
        self.image_label.setAlignment(Qt.AlignCenter)
        image_layout.addWidget(self.image_label)


        self.result_label = QLabel(self)
        self.result_label.setFixedSize(600, 400)
        self.result_label.setAlignment(Qt.AlignCenter)
        image_layout.addWidget(self.result_label)


        main_layout.addLayout(image_layout)


        # 控制布局
        control_layout = QHBoxLayout()


        self.detect_button = QPushButton('選擇圖片', self)
        self.detect_button.clicked.connect(self.load_image)
        control_layout.addWidget(self.detect_button)


        self.yolo_combo = QComboBox(self)
        self.yolo_combo.addItems(['物體檢測(cè)', '物體分割', '人體姿態(tài)識(shí)別'])  # 假設(shè)在此處添加不同的YOLO任務(wù)
        control_layout.addWidget(self.yolo_combo)


        self.run_button = QPushButton('開(kāi)始檢測(cè)', self)
        self.run_button.clicked.connect(self.run_yolo)
        control_layout.addWidget(self.run_button)


        self.quit_button = QPushButton('退出', self)
        self.quit_button.clicked.connect(self.close_application)
        control_layout.addWidget(self.quit_button)


        main_layout.addLayout(control_layout)
        self.setLayout(main_layout)


    def load_image(self):
        options = QFileDialog.Options()
        file_name, _ = QFileDialog.getOpenFileName(self, "選擇圖片文件", "", "Images (*.png *.jpg *.bmp)", options=options)
        if file_name:
            self.current_image = file_name
            pixmap = QPixmap(file_name)
            scaled_pixmap = pixmap.scaled(self.image_label.size(), Qt.KeepAspectRatio)
            self.image_label.setPixmap(scaled_pixmap)


    def plot_keypoints(self, image, keypoints, line_color=(60, 179, 113), point_color=(255, 0, 0),
                   offset=(0, 0), show_idx=False):
        if keypoints is None:
            return image
        
        for data in keypoints.xy:
            if len(data) == 0:
                continue
            # Draw connections between keypoints
            for start_index, end_index in self.connections:
                start_point, end_point = data[start_index], data[end_index]
                if all(start_point[:2] > 0) and all(end_point[:2] > 0):  # Ignore invalid points
                    cv2.line(image, 
                             tuple(map(lambda v, o: int(v + o), start_point[:2], offset)), 
                             tuple(map(lambda v, o: int(v + o), end_point[:2], offset)), 
                             line_color, 2)
            # Draw keypoints
            for index, (x, y) in enumerate(data[:, :2]):
                if x > 0 or y > 0:  # Ignore invalid points
                    cv2.circle(image, 
                               (int(x + offset[0]), int(y + offset[1])), 
                               5, point_color, -1)
                    if show_idx:
                        cv2.putText(image, 
                                    str(index), 
                                    (int(x + offset[0]), int(y + offset[1])), 
                                    cv2.FONT_HERSHEY_SIMPLEX, 0.5, point_color, 1, cv2.LINE_AA)
    
        return image


    def run_yolo(self):
        if hasattr(self, 'current_image'):
            img = cv2.imread(self.current_image)
            
            # YOLO推理示例:
            task = self.yolo_combo.currentText()
            if task =='物體檢測(cè)':
                #model = self.model_detec #YOLO('yolo11s.pt')
                results = self.model_detec(img)
                
                for result in results:
                    boxes = result.boxes                # Pseudo-code; adjust based on actual library


                    for box in boxes:
                        x1, y1, x2, y2 = box.xyxy[0]    # Extracting the bounding box coordinates
                        class_name = self.model_detec.names[int(box.cls[0])]  # Using class_id to get class_name from model
                        confidence = box.conf.item()
                        cv2.rectangle(img, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2)
                        txt_y_pos = int(y1) - 10
                        if txt_y_pos <= 10:
                            txt_y_pos = int(y2) - 10
                        
                        class_name = class_name + " "+ "{:.2g}".format(confidence)
                        cv2.putText(img, class_name, (int(x1), txt_y_pos), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)


            elif task =='物體分割':
                #model = YOLO('yolo11s-seg.pt')
                results = self.model_seg(img)
                
                # Prepare an overlay image with the same dimensions
                overlay = img.copy()
                
                for result in results:
                    boxes = result.boxes  # Pseudo-code; adjust based on actual library
                    masks = result.masks
                    names = result.names
                    for box, mask in zip(boxes, masks):
                        for cls, contour in zip(box.cls, mask.xy):
                            class_id = cls.item()  # Get scalar from tensor
                            class_name = names[class_id]
                            #print(class_name)
                            #print(cv2.contourArea(contour))  # Calculate contour area
                            
                            # Generate a random color
                            color = [random.randint(0, 255) for _ in range(3)]
                            
                            # Fill the contour on the overlay with the random color
                            cv2.drawContours(overlay, [contour.astype(np.int32)], -1, color, thickness=cv2.FILLED)
                # Define the alpha (transparency factor)
                alpha = 0.4  # Value between 0 (transparent) and 1 (opaque)
                
                # Blend the overlay with the original image
                """
                Parameters
                overlay (src1):


                This is the first input array (image).
                In your context, this represents the overlay image, which typically contains modifications like semi-transparent masks drawn over contours.
                
                alpha:
                This is the weight of the first array (image).
                It controls the opacity of the overlay. A value closer to 1 makes the overlay more prominent, while a value closer to 0 makes it less prominent.
                
                img (src2):
                This is the second input array (image).
                It represents the original image onto which the overlay is being applied.
                
                1 - alpha (beta):
                This is the weight of the second array (image).
                Complementary to alpha, it controls the visibility of the original image. A value closer to 1 makes the original image more visible, while closer to 0 makes it less visible.
                
                0 (gamma):
                A scalar added to each sum.
                Typically set to 0 when blending for direct overlay purposes without additional brightness adjustment.
                
                img (dst):
                The destination array where the output is stored.
                It uses the same variable as the original image, implying that the blended result will overwrite this variable.
                """
                cv2.addWeighted(overlay, alpha, img, 1 - alpha, 0, img)


            elif task == '人體姿態(tài)識(shí)別':
                #model = YOLO('yolo11s-pose.pt')
                #results = model(img)
                
                overrides_Body_pose = {
                    "task": "pose",
                    "mode": "predict",
                    "model": self.model_bd,        #'yolo11s-pose.pt'
                    "verbose": False,
                    "classes": [0],
                    "iou": 0.5,
                    "conf": 0.3
                    }


                predictor_ren_pose = PosePredictor(overrides=overrides_Body_pose)
                pose_ren = predictor_ren_pose(img)[0]
                
                img = self.plot_keypoints(img, pose_ren.keypoints)
                
            # Convert the image to a format suitable for PyQt
            height, width, channel = img.shape
            bytes_per_line = 3 * width
            q_image = QImage(img.data, width, height, bytes_per_line, QImage.Format_RGB888).rgbSwapped()
            pixmap = QPixmap.fromImage(q_image)
            self.display_results(pixmap)


    def display_results(self, pixmap):
        scaled_pixmap = pixmap.scaled(self.result_label.size(), Qt.KeepAspectRatio)
        self.result_label.setPixmap(scaled_pixmap)


    def close_application(self):
        self.close()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = YOLOInterface()
    ex.show()
    sys.exit(app.exec_())
小編甚至用它來(lái)檢測(cè)一個(gè)AI生成的油畫(huà)風(fēng)格的圖片??磮D中哪些抽象的只有形態(tài)沒(méi)有細(xì)節(jié)的人和物體,居然仍然可以檢測(cè)出來(lái)。大家可以試一下看看檢測(cè)的結(jié)果。

代碼中涉及到的python軟件包,需要額外安裝,模型文件用的是YOLO現(xiàn)成的。小編把這個(gè)軟件用打包工具生成的exe文件,因?yàn)槿晾ǖ能浖?,?jiǎn)單的這些功能,打包后的文件壓縮后的大小竟高達(dá)近900MB(分割壓縮工具要收費(fèi)咯),而很多平臺(tái)不支持這么大的文件上傳,所以這里也無(wú)法提供打包后的文件下載鏈接。

9f681a44-a936-11ef-93f3-92fbcf53809c.png

視線(xiàn)收回,我們心曠神怡一下。感謝AI的提供。

是否在懷疑這個(gè)世界的真實(shí)性?用傳感器來(lái)檢測(cè)一下吧,這個(gè)世界的冷熱、正負(fù)壓,振動(dòng),周?chē)目諝?.....可以負(fù)責(zé)任地告訴各位,我們還是碳基生物。

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 程序
    +關(guān)注

    關(guān)注

    117

    文章

    3826

    瀏覽量

    83017
  • PID控制器
    +關(guān)注

    關(guān)注

    2

    文章

    173

    瀏覽量

    19217
  • python
    +關(guān)注

    關(guān)注

    56

    文章

    4827

    瀏覽量

    86811

原文標(biāo)題:把YOLOv11和Python Qt做個(gè)用戶(hù)界面程序

文章出處:【微信號(hào):安費(fèi)諾傳感器學(xué)堂,微信公眾號(hào):安費(fèi)諾傳感器學(xué)堂】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。

收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    【HZ-RK3568開(kāi)發(fā)板免費(fèi)體驗(yàn)】04 YOLOv11 模型轉(zhuǎn)換為RKNN并在板端部署

    程序自動(dòng)將其保存為out.png,可以下載到電腦端查看,如下圖 至此,YOLOv11的模型轉(zhuǎn)換與部署就結(jié)束了,后面再研究視頻推理。
    發(fā)表于 07-02 14:01

    瑞芯微RK3506(3核A7@1.5GHz+雙網(wǎng)口+雙CAN-FD)工業(yè)開(kāi)發(fā)板—圖形用戶(hù)界面(GUI)開(kāi)發(fā)手冊(cè)

    本文主要說(shuō)明Qt的圖形用戶(hù)界面(GUI)開(kāi)發(fā)流程,包括Qt程序自啟動(dòng)配置與案例介紹,旨在幫助開(kāi)發(fā)者完成產(chǎn)品開(kāi)發(fā)與測(cè)試。
    的頭像 發(fā)表于 06-03 14:27 ?601次閱讀
    瑞芯微RK3506(3核A7@1.5GHz+雙網(wǎng)口+雙CAN-FD)工業(yè)開(kāi)發(fā)板—圖形<b class='flag-5'>用戶(hù)</b><b class='flag-5'>界面</b>(GUI)開(kāi)發(fā)手冊(cè)

    labview調(diào)用yolov8/11目標(biāo)檢測(cè)、分割、分類(lèi)

    labview使用2020版本64位編輯,調(diào)用yolov8/11的onnx模型案例。 源碼: 通過(guò)網(wǎng)盤(pán)分享的文件:Labview_cls.zip等4個(gè)文件 鏈接: https
    發(fā)表于 04-21 19:37

    【技術(shù)案例】Qt 環(huán)境部署 - Ubuntu 篇

    什么是Qt?Qt是一個(gè)跨平臺(tái)C++圖形用戶(hù)界面應(yīng)用程序開(kāi)發(fā)框架,可構(gòu)建高性能的桌面、移動(dòng)及Web應(yīng)用程序
    的頭像 發(fā)表于 04-16 17:17 ?545次閱讀
    【技術(shù)案例】<b class='flag-5'>Qt</b> 環(huán)境部署 - Ubuntu 篇

    RK3576 yolov11-seg訓(xùn)練部署教程

    級(jí)的精確目標(biāo)檢測(cè)與分割,適用于自動(dòng)駕駛、醫(yī)學(xué)影像、工業(yè)檢測(cè)等對(duì)精度和速度要求苛刻的場(chǎng)景。 ? ? ? ?本教程針對(duì)目標(biāo)分割算法yolov11 seg的訓(xùn)練和部署到EASY-EAI-Orin-nano(RK3576)進(jìn)行說(shuō)明,而數(shù)據(jù)標(biāo)注方法可以參考我們往期的文章。
    的頭像 發(fā)表于 04-16 09:43 ?781次閱讀
    RK3576 <b class='flag-5'>yolov11</b>-seg訓(xùn)練部署教程

    OrinNano yolov11訓(xùn)練部署教程

    ORinNano yolov11訓(xùn)練部署教程
    的頭像 發(fā)表于 04-10 15:26 ?845次閱讀
    OrinNano  <b class='flag-5'>yolov11</b>訓(xùn)練部署教程

    RK3576 Yolov11訓(xùn)練部署教程

    YOLO11 系列是 YOLO 家族中最先進(jìn)的 (SOTA)、最輕量級(jí)、最高效的模型,其表現(xiàn)優(yōu)于其前輩。它由 Ultralytics 創(chuàng)建,該組織發(fā)布了 YOLOv8,這是迄今為止最穩(wěn)定、使用最廣泛的 YOLO 變體。YOLO11
    的頭像 發(fā)表于 04-03 09:35 ?910次閱讀
    RK3576 <b class='flag-5'>Yolov11</b>訓(xùn)練部署教程

    Raspberry Pi上使用IR v11及OpenVINO? 2021.3后不兼容怎么辦?

    使用 Google Colab OpenVINO? 2022.2 將 yolov5 模型轉(zhuǎn)換為 IR v11: !git clone https://github.com/ultralytics
    發(fā)表于 03-06 07:14

    【米爾RK3576開(kāi)發(fā)板評(píng)測(cè)】+項(xiàng)目名稱(chēng)YOLOV5目標(biāo)檢測(cè)

    /examples/yolov5/python python yolov5.py --model_path ../model/yolov5s
    發(fā)表于 02-15 13:24

    RK3568國(guó)產(chǎn)芯教學(xué)實(shí)驗(yàn)箱:指紋識(shí)別實(shí)戰(zhàn)案例

    )GUI的設(shè)計(jì)實(shí)現(xiàn):LCD顯示界面以及與用戶(hù)的交互;(3)編輯控制代碼;(4)編譯程序;(5)運(yùn)行程序。Qt
    的頭像 發(fā)表于 01-08 19:05 ?789次閱讀
    RK3568國(guó)產(chǎn)芯教學(xué)實(shí)驗(yàn)箱:指紋識(shí)別實(shí)戰(zhàn)案例

    基于QT開(kāi)發(fā)國(guó)產(chǎn)主板終端桌面程序 高效、穩(wěn)定、跨平臺(tái)的解決方案

    了開(kāi)發(fā)者們面臨的一個(gè)重要挑戰(zhàn)。本文將介紹如何基于QT框架,開(kāi)發(fā)適用于國(guó)產(chǎn)主板的終端桌面程序,并探討其優(yōu)勢(shì)和應(yīng)用場(chǎng)景。 QT是一個(gè)跨平臺(tái)的C++圖形用戶(hù)
    的頭像 發(fā)表于 01-08 15:34 ?874次閱讀

    在RK3568教學(xué)實(shí)驗(yàn)箱上實(shí)現(xiàn)基于YOLOV5的算法物體識(shí)別案例詳解

    安裝了所有必要的依賴(lài)。這通常包括 torch、torchvision 和 opencv-python。 (2)下載預(yù)訓(xùn)練模型 YOLOv5 提供了多個(gè)預(yù)訓(xùn)練模型,可以從官方倉(cāng)庫(kù)或相關(guān)資源中下載。 (3
    發(fā)表于 12-03 14:56

    國(guó)產(chǎn)Cortex-A55實(shí)驗(yàn)箱操作案例分享:LED程序開(kāi)發(fā)

    一、實(shí)驗(yàn)?zāi)康模?)熟悉Qt程序的開(kāi)發(fā)流程。(2)掌握QtCreator的基礎(chǔ)開(kāi)發(fā)使用。(3)通過(guò)編寫(xiě)Qt程序實(shí)現(xiàn)LED控制的顯示界面。二、實(shí)
    的頭像 發(fā)表于 11-01 08:10 ?554次閱讀
    國(guó)產(chǎn)Cortex-A55實(shí)驗(yàn)箱操作案例分享:LED<b class='flag-5'>程序</b>開(kāi)發(fā)

    EtherCAT運(yùn)動(dòng)控制器上位機(jī)開(kāi)發(fā)之Python+Qt(三):PDO配置與SDO讀寫(xiě)

    PC上位機(jī)Python+Qt混合編程實(shí)現(xiàn)PDO配置與SDO讀寫(xiě)
    的頭像 發(fā)表于 08-21 15:56 ?2064次閱讀
    EtherCAT運(yùn)動(dòng)控制器上位機(jī)開(kāi)發(fā)之<b class='flag-5'>Python+Qt</b>(三):PDO配置與SDO讀寫(xiě)

    EtherCAT運(yùn)動(dòng)控制器上位機(jī)之Python+Qt(一):鏈接與單軸運(yùn)動(dòng)

    PC上位機(jī)Python+Qt混合編程,助力智能制造高效開(kāi)發(fā)。
    的頭像 發(fā)表于 07-31 09:43 ?874次閱讀
    EtherCAT運(yùn)動(dòng)控制器上位機(jī)之<b class='flag-5'>Python+Qt</b>(一):鏈接與單軸運(yùn)動(dòng)