python實(shí)現(xiàn)圖片自動(dòng)分類(lèi)小程序
用 python 編寫(xiě)了一個(gè)圖片自動(dòng)分類(lèi)的小程序,先編了一部分功能:小程序界面。
操作系統(tǒng)平臺(tái):Microsoft Windows 8.1
編程語(yǔ)言:python
一、圖片自動(dòng)分類(lèi)小程序效果圖
尚沒(méi)有進(jìn)行圖片分類(lèi)小程序效果圖。

圖一
點(diǎn)擊圖一中選擇圖片按鈕,在圖二中選擇一張圖片

圖二
選擇圖片后的顯示效果

圖三
圖片自動(dòng)分類(lèi)功能下一篇再寫(xiě)。
二、部分源代碼
目前程序部分源代碼:
1.引用的python模塊
import cv2 import numpy as np import sys import os import tkinter import PIL from PIL import Image,ImageTk from tkinter import ttk from tkinter.messagebox import showinfo
2.選擇圖片代碼
global canvas
global pre_img1
def position_picture(f):
img=PIL.Image.open(f)
img=img.resize((150,150))
preview_img=ImageTk.PhotoImage(img)
return preview_img
def selected_picture():
global canvas,pre_img1
d=tkinter.filedialog.askopenfilename(title='picture',filetypes=[('jpg','*.jpg')])
pre_img1=position_picture(d)
canvas.delete('all')
canvas.create_image((75,75),image=pre_img1) 3.程序界面部分代碼
if __name__=='__main__':
global canvas
global pre_img1
root=tkinter.Tk()
root.title("預(yù)覽")
pre_img=position_picture(fn)
canvas=tkinter.Canvas(root,width=150,height=150,bg='white')
canvas.grid(column=2,row=0)
canvas.create_image((75,75),image=pre_img)
for i in range(0,5):
canvas1=tkinter.Canvas(root,width=150,height=150,bg='white')
canvas1.grid(column=i,row=4)
canvas1.create_image((75,75),image=pre_img)
......
button1=ttk.Button(root,text="選擇圖片",command=selected_picture)
button1.grid(column=2,row=2)
button2=ttk.Button(root,text="自動(dòng)分類(lèi)",command=identify_picture)
button2.grid(column=2,row=3)
root.mainloop 到此這篇關(guān)于python實(shí)現(xiàn)圖片自動(dòng)分類(lèi)小程序的文章就介紹到這了,更多相關(guān)python圖片分類(lèi)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python使用SQLAlchemy模塊實(shí)現(xiàn)操作數(shù)據(jù)庫(kù)
SQLAlchemy 是用Python編程語(yǔ)言開(kāi)發(fā)的一個(gè)開(kāi)源項(xiàng)目,它提供了SQL工具包和ORM對(duì)象關(guān)系映射工具,使用SQLAlchemy可以實(shí)現(xiàn)高效和高性能的數(shù)據(jù)庫(kù)訪問(wèn),下面我們就來(lái)學(xué)習(xí)一下SQLAlchemy模塊的具體應(yīng)用吧2023-11-11
Pycharm 2to3配置,python2轉(zhuǎn)python3方式
這篇文章主要介紹了Pycharm 2to3配置,python2轉(zhuǎn)python3方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
基于python?的Pygame最小開(kāi)發(fā)框架
這篇文章主要介紹了基于python?的Pygame最小開(kāi)發(fā)框架,文章基于python的相關(guān)資料圍繞主題展開(kāi)詳細(xì)內(nèi)容需要的小伙伴可以參考一下2022-04-04
numpy的sum函數(shù)的axis和keepdim參數(shù)詳解
這篇文章主要介紹了numpy的sum函數(shù)的axis和keepdim參數(shù)詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
通過(guò)Python實(shí)現(xiàn)一個(gè)簡(jiǎn)單的html頁(yè)面
這篇文章主要介紹了通過(guò)Python寫(xiě)一個(gè)簡(jiǎn)單的html頁(yè)面,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-05-05
在python中實(shí)現(xiàn)導(dǎo)入一個(gè)需要傳參的模塊
這篇文章主要介紹了在python中實(shí)現(xiàn)導(dǎo)入一個(gè)需要傳參的模塊,具有很好的參考價(jià)值,希望可以給大家一個(gè)參考,以后在遇到這種的情況的時(shí)候,知道如何應(yīng)對(duì)2021-05-05

