├── Assets ├── Upload_photo.png ├── ai.ico ├── c1.png └── c2.png ├── Model ├── accuracy.txt ├── model.h5 ├── model.ipynb └── model.py ├── README.md ├── Test ├── Car │ ├── download (5).jpeg │ ├── download (6).jpeg │ ├── download (7).jpeg │ ├── download (8).jpeg │ └── download (9).jpeg ├── Dog │ ├── dog.jpeg │ ├── dog2.jpeg │ └── dog3.jpeg ├── Frog │ ├── _131948306_screenshot2023-12-07115717.jpg │ ├── green-frog-white-background_1308-110146.avif │ ├── images (1).jpg │ └── images.jpg ├── Ship │ ├── 2740.webp │ ├── download (11).jpeg │ └── images.jpg ├── Truck │ ├── 11.jpeg │ ├── Truck1.jpeg │ ├── Truck2.jpg │ ├── Truck4.jpeg │ └── Ware Steam Carriage.jpg ├── airplane │ ├── GettyImages-1131335393-e1650030686687.jpg │ ├── airplane-flight.webp │ ├── download (3).jpeg │ ├── download (4).jpeg │ ├── download.jpeg │ └── skynews-cargo-plane-overshoots-runway_5909825.jpg ├── bird │ ├── Eopsaltria_australis_-_Mogo_Campground.jpg │ ├── bird1.jpeg │ └── bird3.jpeg └── horse │ ├── download (12).jpeg │ ├── download (14).jpeg │ ├── download (15).jpeg │ ├── horse-3.jpg │ └── images (5).jpeg └── gui.py /Assets/Upload_photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Assets/Upload_photo.png -------------------------------------------------------------------------------- /Assets/ai.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Assets/ai.ico -------------------------------------------------------------------------------- /Assets/c1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Assets/c1.png -------------------------------------------------------------------------------- /Assets/c2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Assets/c2.png -------------------------------------------------------------------------------- /Model/accuracy.txt: -------------------------------------------------------------------------------- 1 | 77.5600016117096 -------------------------------------------------------------------------------- /Model/model.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Model/model.h5 -------------------------------------------------------------------------------- /Model/model.ipynb: -------------------------------------------------------------------------------- 1 | {"cells":[{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":563,"status":"ok","timestamp":1683301563485,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"2vbVIboLl01g"},"outputs":[],"source":["from keras.datasets import cifar10\n","import numpy as np"]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":2172,"status":"ok","timestamp":1683301574647,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"MjMxXVYEl5Uy"},"outputs":[],"source":["(x_train, y_train), (x_test, y_test) = cifar10.load_data()\n"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":430},"executionInfo":{"elapsed":1189,"status":"ok","timestamp":1683301581222,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"_8o4iHdkl7JO","outputId":"b4db1c67-779f-4b0f-f0bc-d2c12f0ae804"},"outputs":[],"source":["import matplotlib.pyplot as plt\n","plt.imshow(x_train[30])\n","plt.show()"]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":5,"status":"ok","timestamp":1683301588357,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"lSJFStFAl844"},"outputs":[],"source":["from keras.utils import to_categorical\n","y_train=to_categorical(y_train)\n","y_test=to_categorical(y_test)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":6,"status":"ok","timestamp":1683301594292,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"ZLRQqhi-l-xX","outputId":"04a44d2f-a544-4d2a-9be6-1cf393c483b7"},"outputs":[],"source":["x_train=x_train.reshape(-1,32,32,3)\n","x_test=x_test.reshape(-1,32,32,3)\n","\n","x_train.shape,x_test.shape,y_train.shape,y_test.shape"]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":877,"status":"ok","timestamp":1683301604389,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"d8WpxNGumAs4"},"outputs":[],"source":["x_train=x_train/255\n","x_test=x_test/255"]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":4,"status":"ok","timestamp":1683301610556,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"cPZ776CpmCmx"},"outputs":[],"source":["from keras.models import Model\n","from keras.layers import Input,Conv2D,MaxPooling2D,Flatten,Dense,Dropout"]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":3,"status":"ok","timestamp":1683301620096,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"yHLNTCSUmEqh"},"outputs":[],"source":["inputs=Input(shape=(32,32,3))\n","\n","c1=Conv2D(64,(3,3),padding=\"same\",activation=\"relu\")(inputs)\n","m1=MaxPooling2D(padding=\"same\")(c1)\n","\n","drop1=Dropout(0.3)(m1)\n","\n","c2=Conv2D(64,(3,3),padding=\"same\",activation=\"relu\")(drop1)\n","m2=MaxPooling2D(padding=\"same\")(c2)\n","\n","drop2=Dropout(0.3)(m2)\n","\n","c3=Conv2D(64,(5,5),padding=\"same\",activation=\"relu\")(drop2)\n","m3=MaxPooling2D(padding=\"same\")(c3)\n","\n","\n","drop2=Dropout(0.3)(m3)\n","\n","conv_out=Flatten()(drop2)\n","\n","d1=Dense(512,activation=\"relu\")(conv_out)\n","\n","out=Dense(10,activation=\"softmax\")(d1)\n"," "]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":8,"status":"ok","timestamp":1683301627554,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"ylVhWoQlmGfo"},"outputs":[],"source":["model = Model(inputs=inputs, outputs=out)\n","model.compile(optimizer=\"adam\", loss=\"categorical_crossentropy\", metrics=[\"accuracy\"])"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":442,"status":"ok","timestamp":1683301635596,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"hpfgfYfImIaX","outputId":"d92256b7-c919-48f1-8558-cca28840fb93"},"outputs":[],"source":["model.summary()"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":4645769,"status":"ok","timestamp":1683306294833,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"TNv57cu1mL_k","outputId":"7dd418f1-3385-459e-ced4-2a981f28c54b"},"outputs":[],"source":["history = model.fit(x_train, y_train, batch_size=64, epochs=20, validation_data=(x_test, y_test)).history"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["test_accuracy = model.evaluate(x_test, y_test)[1] * 100\n","print(\"Model Final Accuracy:\", test_accuracy)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["plt.plot(history['loss'])\n","plt.plot(history['val_loss'])\n","plt.title('Training and Validation Loss')\n","plt.ylabel('Loss')\n","plt.xlabel('Epoch')\n","plt.legend(['Training Loss', 'Validation Loss'], loc='lower right')\n","plt.show()"]},{"cell_type":"code","execution_count":null,"metadata":{"executionInfo":{"elapsed":649,"status":"ok","timestamp":1683306327048,"user":{"displayName":"Ali Nour","userId":"16807118017251715993"},"user_tz":-120},"id":"zTf3yxEOXBUX"},"outputs":[],"source":["model.save(\"Model.h5\")"]}],"metadata":{"colab":{"authorship_tag":"ABX9TyM2ucojtfJkPU98q52p5Sqq","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.12.1"}},"nbformat":4,"nbformat_minor":0} 2 | -------------------------------------------------------------------------------- /Model/model.py: -------------------------------------------------------------------------------- 1 | 2 | from keras.datasets import cifar10 3 | import numpy as np 4 | 5 | 6 | (x_train, y_train), (x_test, y_test) = cifar10.load_data() 7 | 8 | 9 | 10 | import matplotlib.pyplot as plt 11 | plt.imshow(x_train[30]) 12 | plt.show() 13 | 14 | 15 | from keras.utils import to_categorical 16 | y_train=to_categorical(y_train) 17 | y_test=to_categorical(y_test) 18 | 19 | 20 | x_train=x_train.reshape(-1,32,32,3) 21 | x_test=x_test.reshape(-1,32,32,3) 22 | 23 | x_train.shape,x_test.shape,y_train.shape,y_test.shape 24 | 25 | 26 | x_train=x_train/255 27 | x_test=x_test/255 28 | 29 | 30 | from keras.models import Model 31 | from keras.layers import Input,Conv2D,MaxPooling2D,Flatten,Dense,Dropout 32 | 33 | 34 | inputs=Input(shape=(32,32,3)) 35 | 36 | c1=Conv2D(64,(3,3),padding="same",activation="relu")(inputs) 37 | m1=MaxPooling2D(padding="same")(c1) 38 | 39 | drop1=Dropout(0.3)(m1) 40 | 41 | c2=Conv2D(64,(3,3),padding="same",activation="relu")(drop1) 42 | m2=MaxPooling2D(padding="same")(c2) 43 | 44 | drop2=Dropout(0.3)(m2) 45 | 46 | c3=Conv2D(64,(5,5),padding="same",activation="relu")(drop2) 47 | m3=MaxPooling2D(padding="same")(c3) 48 | 49 | 50 | drop2=Dropout(0.3)(m3) 51 | 52 | conv_out=Flatten()(drop2) 53 | 54 | d1=Dense(512,activation="relu")(conv_out) 55 | 56 | out=Dense(10,activation="softmax")(d1) 57 | 58 | 59 | 60 | model = Model(inputs=inputs, outputs=out) 61 | model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"]) 62 | 63 | 64 | model.summary() 65 | 66 | 67 | history = model.fit(x_train, y_train, batch_size=64, epochs=20, validation_data=(x_test, y_test)).history 68 | 69 | 70 | test_accuracy = model.evaluate(x_test, y_test)[1] * 100 71 | ##srore the accuracy in a file 72 | with open("accuracy.txt", "w") as file: 73 | file.write(str(test_accuracy)) 74 | file.close() 75 | print("Model Final Accuracy:", test_accuracy) 76 | 77 | 78 | plt.plot(history['loss']) 79 | plt.plot(history['val_loss']) 80 | plt.title('Training and Validation Loss') 81 | plt.ylabel('Loss') 82 | plt.xlabel('Epoch') 83 | plt.legend(['Training Loss', 'Validation Loss'], loc='lower right') 84 | plt.show() 85 | 86 | 87 | model.save("Model.h5") 88 | 89 | 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | To use the image classification program, follow these steps: 2 | 3 | 1. Run the Python script. 4 | 2. The program will display a splash screen with a loading animation. 5 | 3. Once the loading is complete, the main window will open. 6 | 4. Click on the "Upload Image Here" button to select an image for classification. 7 | 5. The program will classify the image and display the predicted class label. 8 | 9 | -------------------------------------------------------------------------------- /Test/Car/download (5).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Car/download (5).jpeg -------------------------------------------------------------------------------- /Test/Car/download (6).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Car/download (6).jpeg -------------------------------------------------------------------------------- /Test/Car/download (7).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Car/download (7).jpeg -------------------------------------------------------------------------------- /Test/Car/download (8).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Car/download (8).jpeg -------------------------------------------------------------------------------- /Test/Car/download (9).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Car/download (9).jpeg -------------------------------------------------------------------------------- /Test/Dog/dog.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Dog/dog.jpeg -------------------------------------------------------------------------------- /Test/Dog/dog2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Dog/dog2.jpeg -------------------------------------------------------------------------------- /Test/Dog/dog3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Dog/dog3.jpeg -------------------------------------------------------------------------------- /Test/Frog/_131948306_screenshot2023-12-07115717.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Frog/_131948306_screenshot2023-12-07115717.jpg -------------------------------------------------------------------------------- /Test/Frog/green-frog-white-background_1308-110146.avif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Frog/green-frog-white-background_1308-110146.avif -------------------------------------------------------------------------------- /Test/Frog/images (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Frog/images (1).jpg -------------------------------------------------------------------------------- /Test/Frog/images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Frog/images.jpg -------------------------------------------------------------------------------- /Test/Ship/2740.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Ship/2740.webp -------------------------------------------------------------------------------- /Test/Ship/download (11).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Ship/download (11).jpeg -------------------------------------------------------------------------------- /Test/Ship/images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Ship/images.jpg -------------------------------------------------------------------------------- /Test/Truck/11.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Truck/11.jpeg -------------------------------------------------------------------------------- /Test/Truck/Truck1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Truck/Truck1.jpeg -------------------------------------------------------------------------------- /Test/Truck/Truck2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Truck/Truck2.jpg -------------------------------------------------------------------------------- /Test/Truck/Truck4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Truck/Truck4.jpeg -------------------------------------------------------------------------------- /Test/Truck/Ware Steam Carriage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/Truck/Ware Steam Carriage.jpg -------------------------------------------------------------------------------- /Test/airplane/GettyImages-1131335393-e1650030686687.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/airplane/GettyImages-1131335393-e1650030686687.jpg -------------------------------------------------------------------------------- /Test/airplane/airplane-flight.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/airplane/airplane-flight.webp -------------------------------------------------------------------------------- /Test/airplane/download (3).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/airplane/download (3).jpeg -------------------------------------------------------------------------------- /Test/airplane/download (4).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/airplane/download (4).jpeg -------------------------------------------------------------------------------- /Test/airplane/download.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/airplane/download.jpeg -------------------------------------------------------------------------------- /Test/airplane/skynews-cargo-plane-overshoots-runway_5909825.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/airplane/skynews-cargo-plane-overshoots-runway_5909825.jpg -------------------------------------------------------------------------------- /Test/bird/Eopsaltria_australis_-_Mogo_Campground.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/bird/Eopsaltria_australis_-_Mogo_Campground.jpg -------------------------------------------------------------------------------- /Test/bird/bird1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/bird/bird1.jpeg -------------------------------------------------------------------------------- /Test/bird/bird3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/bird/bird3.jpeg -------------------------------------------------------------------------------- /Test/horse/download (12).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/horse/download (12).jpeg -------------------------------------------------------------------------------- /Test/horse/download (14).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/horse/download (14).jpeg -------------------------------------------------------------------------------- /Test/horse/download (15).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/horse/download (15).jpeg -------------------------------------------------------------------------------- /Test/horse/horse-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/horse/horse-3.jpg -------------------------------------------------------------------------------- /Test/horse/images (5).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mo7ammedd/Cnn-image-classification/e591dd4302ac80aa0538ae460bbe27260c51ab58/Test/horse/images (5).jpeg -------------------------------------------------------------------------------- /gui.py: -------------------------------------------------------------------------------- 1 | # ****************************************# 2 | # importing library for splash # 3 | # ****************************************# 4 | 5 | from tkinter import * 6 | from tkinter import font 7 | from PIL import ImageTk, Image 8 | import time 9 | import Model 10 | w = Tk() 11 | width_of_window = 427 12 | height_of_window = 250 13 | screen_width = w.winfo_screenwidth() 14 | screen_height = w.winfo_screenheight() 15 | x_coordinate = (screen_width/2)-(width_of_window/2) 16 | y_coordinate = (screen_height/2)-(height_of_window/2) 17 | w.geometry("%dx%d+%d+%d" % 18 | (width_of_window, height_of_window, x_coordinate, y_coordinate)) 19 | w.overrideredirect(1) # for hiding titlebar 20 | 21 | 22 | 23 | # ******************************# 24 | # Main Window # 25 | # *****************************# 26 | def new_win(): 27 | # ******************************# 28 | # Main Window # 29 | # *****************************# 30 | import tkinter as tk 31 | from tkinter import filedialog 32 | from PIL import ImageTk, Image 33 | import numpy 34 | from tensorflow.keras.models import load_model 35 | 36 | 37 | 38 | model = load_model('Model\\model.h5') 39 | classes = { 40 | 0: 'airplane', 41 | 1: 'car', 42 | 2: 'bird', 43 | 4: 'deer', 44 | 5: 'dog', 45 | 6: 'frog', 46 | 7: 'horse', 47 | 8: 'ship', 48 | 9: 'truck', 49 | } 50 | 51 | def upload_image(): 52 | file_path = filedialog.askopenfilename() 53 | uploaded = Image.open(file_path) 54 | uploaded.thumbnail( 55 | ((top.winfo_width()/2.25), (top.winfo_height()/2.25))) 56 | im = ImageTk.PhotoImage(uploaded) 57 | sign_image.configure(image=im) 58 | sign_image.image = im 59 | lable.configure(text=' ') 60 | show_classify_button(file_path) 61 | 62 | def show_classify_button(file_path): 63 | classify_btn = Button(top, text="Classify Image", 64 | command=lambda: classify(file_path), padx=10, pady=5) 65 | classify_btn.configure(background="#3498db", foreground="white", font=('arial', 10, 'bold')) 66 | classify_btn.place(relx=0.79, rely=0.46) 67 | 68 | def classify(file_path): 69 | image = Image.open(file_path) 70 | image = image.resize((32, 32)) 71 | image = numpy.expand_dims(image, axis=0) 72 | image = numpy.array(image) 73 | pred = int(numpy.argmax(model.predict(image), axis=-1)[0]) 74 | sign = classes[pred] 75 | print(sign) 76 | lable.configure(foreground='#3498db', text=sign) 77 | 78 | global accuracy_label 79 | accuracy_label = None 80 | 81 | def print_Accuracy(): 82 | global accuracy_label 83 | # Check if accuracy_label has already been created 84 | if accuracy_label is None: 85 | # Read accuracy from file 86 | with open('model//accuracy.txt', 'r') as file: 87 | test_accuracy = float(file.read()) 88 | # Create and pack accuracy label 89 | accuracy_label = Label(top, text=f"Model Accuracy: {test_accuracy:.2f}%", font=('arial', 10, 'bold')) 90 | accuracy_label.pack() 91 | 92 | def center_window(top, width, height): 93 | screen_width = top.winfo_screenwidth() 94 | screen_height = top.winfo_screenheight() 95 | 96 | # Calculate the x and y coordinates to position the window in the center 97 | x = (screen_width // 2) - (width // 2) 98 | y = (screen_height // 2) - (height // 2) 99 | 100 | # Set the window size and position 101 | top.geometry(f"{width}x{height}+{x}+{y}") 102 | 103 | width = 800 # New width 104 | height = 600 # New height 105 | 106 | # ******************************# 107 | # GUI Main Window # 108 | # *****************************# 109 | # GUI 110 | top = tk.Tk() 111 | top.iconbitmap("Assets/ai.ico") 112 | top.geometry('800x600') 113 | # top.eval('tk::PlaceWindow. center') 114 | center_window(top, width, height) 115 | top.title("Image Classification CIFAR10") 116 | top.configure(background="#f0f0f0") 117 | 118 | # Set Heading 119 | heading = Label(top, text="Image Classification Using Cnn", 120 | pady=20, font=('Game Of Squids', 20, 'bold')) 121 | heading.configure(background="#f0f0f0", foreground='#3498db') 122 | heading.pack() 123 | 124 | 125 | upload = Button(top, text="Upload Image Here", 126 | command=upload_image, padx=10, pady=5) 127 | upload.configure(background="#3498db", foreground='white', 128 | font=('arial', 10, 'bold')) 129 | upload.pack(side=BOTTOM, pady=50) 130 | 131 | exitt = Button(top, text=" Close ", 132 | command=top.destroy, padx=10, pady=5) 133 | exitt.configure(background="#3498db", foreground='white', 134 | font=('arial', 10, 'bold')) 135 | exitt.pack(side=BOTTOM, pady=60) 136 | exitt.place(relx=0.79, rely=0.60) 137 | 138 | btn_arr = Button(top, command=print_Accuracy, text="Show Accuracy", padx=10, pady=5) 139 | btn_arr.configure(background="#3498db", foreground="white", font=('arial', 10, 'bold')) 140 | btn_arr.pack(side=BOTTOM, pady=50) 141 | btn_arr.place(relx=0.120, rely=0.40) 142 | # upload image 143 | sign_image = Label(top, background="#f0f0f0") 144 | sign_image.pack(side=BOTTOM, expand=True) 145 | 146 | # bannerimage 147 | # Replace with your image path 148 | path1 = "Assets/Upload_photo.png" 149 | image1 = Image.open(path1) 150 | small_image = image1.resize((100, 100), Image.LANCZOS) 151 | 152 | # Convert the image to Tkinter format 153 | tk_imagee = ImageTk.PhotoImage(small_image) 154 | 155 | # Create a label and display the image 156 | label = tk.Label(top, background="#f0f0f0", image=tk_imagee) 157 | label.pack(pady=10) 158 | label.pack() 159 | 160 | # clsass 161 | lable = Label(top, background="#f0f0f0", font=('arial', 15, 'bold')) 162 | lable.pack(side=BOTTOM, expand=True) 163 | 164 | arr = Label(top, text=" " ,pady=10, font=('Game Of Squids', 20, 'bold')) 165 | arr.configure(background="#f0f0f0", foreground='#3498db') 166 | arr.pack() 167 | arr.place(relx = 0.150 , rely = 0.60) 168 | top.mainloop() 169 | 170 | 171 | Frame(w, width=427, height=250, bg='#3498db').place(x=0, y=0) 172 | label1 = Label(w, text='PROGRAMEDD', fg='#ffffff', 173 | bg='#3498db') # decorate it 174 | # You need to install this font in your PC or try another one 175 | label1.configure(font=('Game Of Squids', 24, "bold")) 176 | label1.place(x=80, y=90) 177 | 178 | label2 = Label(w, text='Loading...', fg='#cccccc', 179 | bg='#3498db') # decorate it 180 | label2.configure(font=("Calibri", 11)) 181 | label2.place(x=10, y=215) 182 | 183 | # making animation 184 | 185 | image_a = ImageTk.PhotoImage(Image.open( 186 | 'Assets/c2.png')) 187 | image_b = ImageTk.PhotoImage(Image.open( 188 | 'Assets/c1.png')) 189 | 190 | for i in range(5): # 5loops 191 | l1 = Label(w, image=image_a, border=0, relief=SUNKEN).place(x=180, y=145) 192 | l2 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=200, y=145) 193 | l3 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=220, y=145) 194 | l4 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=240, y=145) 195 | w.update_idletasks() 196 | time.sleep(0.5) 197 | 198 | l1 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=180, y=145) 199 | l2 = Label(w, image=image_a, border=0, relief=SUNKEN).place(x=200, y=145) 200 | l3 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=220, y=145) 201 | l4 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=240, y=145) 202 | w.update_idletasks() 203 | time.sleep(0.5) 204 | 205 | l1 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=180, y=145) 206 | l2 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=200, y=145) 207 | l3 = Label(w, image=image_a, border=0, relief=SUNKEN).place(x=220, y=145) 208 | l4 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=240, y=145) 209 | w.update_idletasks() 210 | time.sleep(0.5) 211 | 212 | l1 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=180, y=145) 213 | l2 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=200, y=145) 214 | l3 = Label(w, image=image_b, border=0, relief=SUNKEN).place(x=220, y=145) 215 | l4 = Label(w, image=image_a, border=0, relief=SUNKEN).place(x=240, y=145) 216 | w.update_idletasks() 217 | time.sleep(0.5) 218 | w.destroy() 219 | new_win() 220 | w.mainloop() --------------------------------------------------------------------------------