Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the small system of scoring python appearance

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to achieve the python appearance scoring system". In the daily operation, I believe that many people have doubts about how to achieve the python appearance scoring system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to achieve the python appearance scoring system". Next, please follow the editor to study!

Text

This article is based on the interface facial appearance scoring system done by tkinter, ha, come and measure your face score.

Environment installation: Python3, pycharm2021, and some built-in modules.

Pip install-I https://pypi.douban.com/simple/ pillow pip install-I https://pypi.douban.com/simple/ baidu-aip

First of all, be sure to configure Baidu api parameters as follows:

APP_ID = '15768642'API_KEY =' xhiiGmGPRCRj10XIqVlVeCky'SECRET_KEY = 'ZDMMAO7StwTKzW8BspVQxvoGtdgSW4yI'a_face = AipFace (APP_ID, API_KEY, SECRET_KEY) image_type =' BASE64'options = {'face_field':' age,gender,beauty'}

Title design color, font, etc.:

Def title (self): "" title design "" lb = tk.Label (self.root, text=' appearance scoring system', bg='#008B8B', fg='lightpink', font= ('regular script', 30), width=20, height=2 # relief=tk.SUNKEN) lb.place (xylene 200, yearly 10)

Set the background size of the interfacing program, etc.

Class ScoreSystem (): root = tk.Tk () # modify the size of the program box root.geometry ('800x500') # add the program box title root.title (' appearance scoring system') # modify the background color canvas = tk.Canvas (root, width=800, # specify the width of the Canvas component height=500 # specify the height of the Canvas component bg='#E6E8FA') # specify the background color of the Canvas component canvas.pack ()

The main function runs:

Def start_interface (self): "" main run function "self.title () self.time_component () # Open the local file tk.Button (self.root, text=' Open File', command=self.show_original_pic) .place (self.root 50, yearly 150) # for tk.Button (self.root, text=' face recognition) Command=self.open_files2) .place (self.root 50, yearly 230) # exit the system tk.Button (self.root, text=' exit software', command=self.quit) .place (Xerox 50, yearly 390) # display the frame title tk.Label (self.root, text=' original', font=10) .place (Xerox 380) Yellow120) # modify picture size self.label_img_original = tk.Label (self.root) # set display frame background self.cv_orinial = tk.Canvas (self.root, bg='white', width=270, height=270) # set display frame border self.cv_orinial.create_rectangle (8,8260,260, width=1 Outline='red') # set location self.cv_orinial.place (xdye 265, yearly 150) # display picture location self.label_img_original.place (xylene 265, yearly 150) # set the score tag tk.Label (self.root, text=' gender', font=10) .place (Xerox 680, yearly 150) self.text1 = tk.Text (self.root, width=10 Height=2) tk.Label (self.root, text=' age', font=10). Place (Xero680, width=10, height=2) self.text2 = tk.Text (self.root, width=10, height=2) tk.Label (self.root, text=' score', font=10) .place (Xero680, yearly 350) self.text3 = tk.Text (self.root, width=10, height=2) # fill in the text self.text1.place Yee 175) self.text2.place (Xerox 680, YBG 285) self.text3.place (Xerox 680 Img 385) # Open the loop self.root.mainloop () def show_original_pic (self): "put the file" self.path_ = askopenfilename (title=' select file') # process the file img = Image.open (fr' {self.path_}') img = img.resize ((270270) PIL.Image.ANTIALIAS) # resize the picture to 270 '270 # generate tkinter picture object img_jpg_original = ImageTk.PhotoImage (img) # set picture object self.label_img_original.config (image=img_jpg_original) self.label_img_original.image = img_jpg_original self.cv_orinial.create_image (5, 5, anchor='nw' Image=img_jpg_original) def open_files2 (self): # get age, score, gender age, score, gender = face_score (self.path_) # clear text text box content and insert self.text1.delete (1.0, tk.END) self.text1.tag_config ('red', foreground='RED') self.text1.insert (tk.END) Gender, 'red') self.text2.delete (1, tk.END) self.text2.tag_config (' red', foreground='RED') self.text2.insert (tk.END, age, 'red') self.text3.delete (1. 0, tk.END) self.text3.tag_config (' red', foreground='RED') self.text3.insert (tk.END, score) 'red') def quit (self): "" exit "self.root.quit ()

Finally, a time group is set up to update the time of the test appearance at any time, so that the appearance of different time periods can be measured.

Def get_time (self, lb): "" get time "" time_str = time.strftime ("% Y-%m-%d% H:%M:%S") # get the current time and convert it to a string lb.configure (text=time_str) # reset the label text self.root.after (1000, self.get_time Lb) # call the function get_time itself every 1s to get the time def time_component (self): "time component"lb = tk.Label (self.root, text='', fg='white', font= (" boldface ", 15)) lb.place (relx=0.75, rely=0.90) self.get_time (lb)

The effect is as follows:

At this point, the study on "how to achieve the python appearance scoring system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report