At the same time, the development of systems to identify and classifies Vietnam''''s currency important requirement in financial, business and commercial activities.In this topic, we will l
Trang 1BỘ GIÁO DỤC VÀ ĐÀO TẠO
TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP.HCM KHOA:ĐÀO TẠO CHẤT LƯỢNG CAO
-FINAL REPORT ARTIFICIAL INTELLIGENCE
THEME:
VIETNAM CURRENCY IDENTIFICATION
GVHD: Associate Professor Dr Nguyễn Trường Thịnh NAME: Nguyễn Ngọc Phúc
MSSV: 20146269
HCM, Ngày 22 Tháng 5 Năm 2023
Trang 2In the era of technology 4.0, artificial intelligence is becoming a hot research field and has great potential for development At the same time, the development of systems to identify and classifies Vietnam's currency important requirement in financial, business and commercial activities
In this topic, we will learn about the identification of the Vietnamese currency, the methods and techniques used to solve this problem, as well as its application in practice Thereby, we will see the importance and potential of artificial intelligence in improving people's lives
Trang 3I Introduction
The topic is "Identifying Vietnamese currency" is a topic in the field of artificial
intelligence, studying the ability of computers in Vietnamese image processing to generate input data
The objective of the project is to learn and analyze techniques and methods to recognize Vietnamese banknotes (from VND 5,000 to VND 500,000) by artificial intelligence and determine its application in practice
The scope of the topic covers methods and techniques of emotion recognition such
as neural networks, deep learning, facial recognition techniques, voice, natural language processing, and its applications in various fields such as advertising markets, education, healthcare, and entertainment
The significance of the topic is to make computer systems smarter and more sophisticated in interacting and communicating with humans This will make it possible to shorten the process of classifying money and develop methods to detect counterfeit money, thereby bringing higher economic and social efficiency
II Method
The image-based method of identifying banknotes is one of the common methods used for currency identification This method uses software and computer technology to analyze features in images, such as colors and images in banknotes,
to determine human emotions
Image-based currency identification can be used in economic sectors such as vending machines, especially after the recent COVID-19 outbreak, contactless direct pay has also been developed
However, image-based currency identification still faces challenges One of the challenges are the accuracy of recognizing bills of the same color that are still hitting In addition, the processing and analysis of different data between banknotes also require advanced techniques and technologies to achieve high accuracy
III Implement
The training model will be implemented on the colab:
a) Data preparation
Trang 6The dataset contains images with labels as monetary values that are collected and processed to match the training process This dataset is divided into a training set and a test set to evaluate the accuracy of the model
b) Model building
# connect to Drive to get data
from google.colab import drive
drive.mount('/content/drive')
# tải các thư viện cần thiết
import numpy as np
from os import listdir
from numpy import asarray, save
from keras.utils import load_img, img_to_array, to_categorical
from keras.models import Sequential, load_model
from keras.layers import
Dense,Dropout,Flatten,Conv2D,MaxPooling2D,Normalization,LeakyReLU from keras.optimizers import Adam
from keras.losses import categorical_crossentropy
import matplotlib.pyplot as plt
from keras.utils.image_utils import img_to_array
#lưu forder chứa dữ liệu vào 1 biếng
folder = '/content/drive/MyDrive/money/'
#tiến hành tiền xử lý dữ liệu
photos, labels = list(), list()
for file in listdir(folder):
output = 0.0
if file.startswith('5k'):
output = 1.0
Trang 7if file.startswith('10k'):
output = 2.0
if file.startswith('20k'):
output = 3.0
if file.startswith('50k'):
output = 4.0
if file.startswith('100k'):
output = 5.0
if file.startswith('200k'):
output = 6.0
if file.startswith('500k'):
output = 7.0
img =load_img(folder+file,target_size=(100,200)) photo = img_to_array(img)
photos.append(photo)
labels.append(output)
photos = asarray(photos)
labels = asarray(labels)
# lưu dữ liệu vừa xử lý
save('luuhinhtien.npy',photos)
save('luutentien.npy',labels)
c) Model training
#32 lần tích chặp
model = Sequential()
model.add(Conv2D(32,kernel_size = (3,3),activation = 'relu',input_shape=(100,200,3),padding='Same'))
model.add(MaxPooling2D((2,2),padding='same'))
model.add(Dropout(0.25))
#64 lần tích chặp
model.add(Conv2D(64,(3,3),activation ='relu',padding ='same')) model.add(MaxPooling2D((2,2),padding='same'))
model.add(Dropout(0.25))
#128 lần tích chặp
Trang 8model.add(Conv2D(128,(3,3),activation ='relu',padding ='same'))
model.add(MaxPooling2D((2,2),padding='same'))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(64,activation = 'relu'))
model.add(Dropout(0.25))
model.add(Dense(10,activation='softmax'))
model.compile(loss = categorical_crossentropy,optimizer = Adam(),metrics=['accuracy']) model.summary()
# gọi các dử liệu đã sử lý và biến đổi cho phù hợp với mô hình đã chuẩn bị
x_train = np.load('/content/luuhinhtien.npy')
y_train = np.load('/content/luutentien.npy')
x_train = x_train.astype('float32')/255
y_train = to_categorical(y_train,10)
#Train_model
train = model.fit(x_train,y_train,batch_size=32,epochs = 200,verbose = 1)\
After training the model, we use the command to save and download the h5 file to the machine: model.save('doancuoiky.h5')
d) Check
Trang 12The accuracy is still not high, this may be due to the small number of training samples or the sharpness of the image needs to be higher
IV Interface design
The interface design process is performed on Visual Studio Code
#tải các thư viện cần thiết
import numpy as np
import matplotlib.pyplot as plt
from keras.models import load_model
from keras.utils import load_img, img_to_array
from keras.utils.image_utils import img_to_array
from tkinter import *
from tkinter.filedialog import *
from PIL import Image, ImageTk
#lưu model đã được huấn luyện trước
doan=load_model(‘doancuoiky.h5')
#chuẩn bị 1 biến dùng để xuất ảnh ra màng hình
img =0
# 1 hàm dùng để đoán giá trị tờ tiền và đưa phán đoán lên màng hình
def phandoan():
global doan
global img
#lb1.config('')
vat = {1: '5000',2:'10000', 3:'20000', 4:'50000', 5:'100000', 6:'200000', 7:'500000' } result = np.argmax(doan.predict(img),axis=1)
lb1.config(text=' {} VND'.format(vat[result[0]]))
#1 hàm dùng để tiềm ảnh và xuất lên màng hình
def doi():
global img
try:
filename=askopenfilename(initialdir='c:\\python31\\',filetypes=[('jpg files', '.jpg')]) load = Image.open(filename)
load=load.resize((200,100))
render = ImageTk.PhotoImage(load)
img = load_img(filename,target_size=(100,200))
plt.imshow(img)
img = img_to_array(img)
img=img.reshape(1,100,200,3)
img = img.astype('float32')
img =img/255
hinh.configure(image=render)
hinh.image = render
Trang 13DOAN ["state"] = "normal"
lb1.config(text='')
except:pass
#1 hàm dùng để xóa các ảnh và giá trị đã đoán
def xoa():
global hinh
hinh.destroy()
hinh= Label()
hinh.place(x=50, y=215)
DOAN ["state"] = DISABLED
lb1.config(text='')
#tạo giao diện
root = Tk()
root.geometry("1000x600")
#lb1 để hiện giá trịu phán đoán
lb1 = Label(text='',font=('times',30))
lb2 = Label(text='Kết quả',font=('times',30))
#label dùng để hiển thị hình ảnh đã chọn
hinh= Label()
lb3 = Label(text='Ảnh Cần Xác Định',font=('times',24))
lb4 = Label(text='=>',font=('times',50))
#gắn tất cả lên giao diện
lb4.place(x=425, y=250)
lb3.place(x=50, y=50)
hinh.place(x=50, y=215)
lb1.place(x=600, y=250)
lb2.place(x=650, y=50)
#nút xóa
xoa = Button(text='Xóa/Hủy', font=('Verdana', 24),command=xoa)
xoa.place(x=400, y=450)
#nút tìm và hiển thị hình ảnh
chuyen = Button(text='Chọn ảnh', font=('Verdana', 24),command=doi) chuyen.place(x=50, y=450)
#Nút kích hoạt phán đoán
DOAN = Button(text='Định Dạng', font=('Verdana', 24),command= phandoan) DOAN.place(x=700, y=450)
Trang 14#chỉ khi đã chọn hình mới được nhấn nút DOAN ["state"] = DISABLED mainloop()
V Result
Trang 16VI Conclude
Visual currency recognition is an important area of research in artificial intelligence By researching and applying methods to identify features in images, we can help computers will be able to convert image data into digital data and detect features through images
In this article, we have been introduced to the basic concepts of currency identification,
as well as the applications of currency identification in life and an industry In particular,
we have learned about how to use CNN algorithms to train image recognition models Although the method of visual currency identification has made much progress, however, there are many challenges that need to be addressed These challenges include the accuracy of the system, especially in classifying banknotes of the same color, and the ability to handle low-quality images
In short, visual currency identification is very promising and highly applicable field in life and an industry Currency identification methods are currently being continuously researched and improved to achieve greater accuracy and efficiency
Trang 17Mã QR Github
Mã QR Google Drive chứa dữ liệu: