程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Learn pyside2 to develop artificial intelligence system application based on Python

編輯:Python

Study PySide2 be based on Python Develop artificial intelligence system application

List of articles

  • Study PySide2 be based on Python Develop artificial intelligence system application
    • Abstract
    • One 、 Study PySide2 Use
      • The first 1 Step Environmental installation
      • The first 2 Step Good configuration Qt Designer
      • The first 3 Step Fast design UI Interface
      • The first 4 Step Study Qt Designers and Pyside2
    • Two 、 The system design
      • Component selection
    • 3、 ... and 、 Release program
      • 1. Use pyinstaller
      • 2.Enigma Virtual Box Packaged as a separate exe
    • Record on pit
    • Update record


Abstract

Participate in competitions or activities , In the task of target detection or classification , It is often necessary to quickly develop one GUI Visual interface . Today we learn the following :

  1. PySide2 Learning route sharing

  2. be based on Qt Desinger Quickly drag an interface

  3. Will oneself Python The input and output of the code are linked with the interface and displayed

  4. After the visualization program is completed , Post code , Pack it up exe


One 、 Study PySide2 Use

Pyside2 Is based on Python Development Qt Library of visual interface ,Qt Is based on C++ Realized ; Want to be in Python Upper use , You definitely need an interface , What we chose is Pyside2.

PyQt5 Is based on Python Development Qt The library of , It can be understood as a library maintained by different people , They have a lot in common with each other , Choose one to learn .

The first 1 Step Environmental installation

First , The environment must be configured first .Anaconda I won't say much about it :Anaconda Command line summary

install Pyside2

pip install pyside2 -i https://pypi.douban.com/simple

The first 2 Step Good configuration Qt Designer

Qt Designer What is it? ? It's a software , Call it Qt The designer , Specially designed ui; You can quickly pull the control , Edit control properties , Convenient and quick ! Reduce a lot of code , and

And support preview at any time . So we can make sure ui, Then implement the functional interface , Fore and aft end separation , High controllability .

stay Pyside2 Has been installed by default Qt Designer, We need to configure it , Then it can be quickly in PyCharm Use in .

Follow the tutorial below to configure Pycharm Of Tools Tools , Easy and fast access Qt Designer

install QtDesigne course

After the configuration is completed, see the figure below , Can access Qt The designer

  1. Click on pyside2_designer It can start quickly qt

  2. Click on pyuic5 To be able to Qt Designer generated .ui File conversion to python Code


The first 3 Step Fast design UI Interface

open Qt The designer , Quickly design , The interface you need .


The first 4 Step Study Qt Designers and Pyside2

You must be a stranger at this time , Don't know how to use ; So we need a tutorial to learn .

English document :Pyside2 Official documents


Chinese document : White moon and black feather :Qt The graphical interface Gui


There are commonly used components on the website 、 attribute 、 And examples ; Self study is enough .


Video tutorial 1:Python Qt Graphic interface programming - PySide2 PyQt5 PyQt PySide

I first learned the video tutorial of white moon and black feather P12


Video tutorial 2:Python Qt Control - Ongoing update - PySide2 PyQt5 PyQt PySide Pyside6

Then I learned UP Lord ,2021 The latest video in , I think this video is more useful , After watching the video, I began to develop my own program in combination with the blogger's website .

White moon and black feather :www.python3.vip

Use of edge query component , In combination with the content of the class, we began to develop the program .


Two 、 The system design

What I have to do myself , Is based on Mask R-CNN A model of instance segmentation is trained , To do a simple GUI To show the results .

So I designed the following roughly :

  • Button to load the model 、 Click to load the model
  • Button to load the image 、 Click to load the image
  • Run button 、 Click to run the program
  • Save button 、 Click to save the results
  • Exchange interface 、 I hope my operation can be shown by simple records

The simple results of the two-day effort are as follows :


Component selection

It will come true soon , Video learning finished , Refer to the website example to complete . The main controls I use are as follows :

  • Button ( Functional selection )
  • The text box ( User interaction )
  • label( title , Show the image )
  • Select File ( load , Save image )

3、 ... and 、 Release program

1. Use pyinstaller

Use pyinstaller Package the program into an executable , The order is as follows , among main.py For your program entry , Load in ui file ( It is better to set it as a peer directory , It can only help you package the relevant environmental dependencies , Various file paths loaded , It also needs to be placed in the corresponding file path )

pyinstaller main.py --noconsole --hidden-import PySide2.QtXml

Publish program tutorial :https://www.byhy.net/tut/py/gui/qt_04/

After packaging, it looks like the following figure , function main.exe You can start GUI. Of course , You may encounter many holes in the packaging process , Just solve the problem one by one .


2.Enigma Virtual Box Packaged as a separate exe

Of course , Often you want to simplify your own program ; Directly encapsulate into a exe Executable program , Click to run , Please use the package tool

Enigma Virtual Box Introduction to package tools

The program looks like this :

My program is about 4 individual G, It is not recommended to package , Particularly slow ; Lightweight applets can be encapsulated , It feels very convenient , If the program is too large, it is not recommended to use .


Record on pit

The whole learning process , Blog references are as follows :

  • White moon and black feather :www.python3.vip
  • Mac install QtDesigner Guidelines for pit closure :https://blog.csdn.net/ssmbyss/article/details/116297275
  • PySide2 stay MacOS A collection of running problems in the environment :https://blog.csdn.net/a2824256/article/details/120017036
  • Pyside2 utilize QLabel Insert image and generate dialog select Folder :https://blog.csdn.net/weixin_47142735/article/details/123828965
  • Close test effectively , One move to solve mistakes :This application failed to start because not Qt platform plugin could be initialized.
  • 【 resolved 】Pyinstaller pack PySide2 by exe Report a mistake later . Error message :This application failed to start because no Qt platform plugin
  • Enigma Virtual Box Introduction to package tools :https://blog.csdn.net/yaojinjian1995/article/details/106420089
  • Qt The program is packaged into a single exe Methods :https://blog.csdn.net/zchill/article/details/118598279

Update record

2022 year 6 month 29 Japan 01:12:56, Today, I will learn GUI It's over ; Postgraduate opening 、 The Zhaoyi cup competition is busy enough , Come on! !

In the morning 1 spot , I can't stand it . Go to bed , Good night, !

Forget it , Or modify the overall format , Ha ha ha .



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved