ð
# IMPORT LIBRARY
from tkinter import Tk, Button, Label, Text
from PIL import Image, ImageTk
import joblib
import numpy as np
# Create main window
root = Tk()
root.title("Text Input Example")
root.geometry("700x500+300+100")
root.configure(bg="#2C3E50")Â
# FUNCTION
def printInput():Â
# Get the input data from the Text widgets
    Current = float(inputtext_current.get(1.0, "end-1c"))
    Volt = float(inputtext_volt.get(1.0, "end-1c"))
    Vibration = float(inputtext_Vibration.get(1.0, "end-1c"))
# Prepare the input data as a numpy array (same shape as the model expects)
    new_data = np.array([[Current, Volt, Vibration]]) # INSERT MOTOR DATA MANUALÂ
   Â
# Apply the same preprocessing to the new data (scaling)
    new_data_scaled = scaler.transform(new_data)
# Use the loaded model to make a prediction
    prediction = model.predict(new_data_scaled)
# Display the prediction result in the label
    lbl_prediction.config(text="Prediction: {:.2f}".format(prediction[0]))
# Load the saved model and scaler
model = joblib.load(r"D:\LAST SEMESTER\AI\final\mlp_model.pkl")
scaler = joblib.load(r"D:\LAST SEMESTER\AI\final\scaler.pkl")
print("Model and scaler loaded successfully.")
# Load image
image_path = r"D:\LAST SEMESTER\AI\final\motor.jpg"Â
image = Image.open(image_path)
image = image.resize((170, 170))Â
photo = ImageTk.PhotoImage(image)
# Create Label to display image
lbl_image = Label(root, image=photo)
lbl_image.image = photo # āđāļāđāļ reference āļāļāļāļĢāļđāļāļ āļēāļāđāļāļ·āđāļāđāļĄāđāđāļŦāđāļāļđāļ garbage collected
lbl_image.pack()
lbl_image.place(x=250, y=50)Â
# TextBox CreationÂ
inputtext_current = Text(root, bg="white", font=('Courier 20 bold'), width=11, height=1)
inputtext_current.pack(), inputtext_current.place(x=100, y=300)Â
inputtext_volt = Text(root, bg="white", font=('Courier 20 bold'), width=11, height=1)
inputtext_volt.pack(), inputtext_volt.place(x=400, y=300)
inputtext_Vibration = Text(root, bg="white", font=('Courier 20 bold'), width=11, height=1)
inputtext_Vibration.pack(), inputtext_Vibration.place(x=100, y=400)
# Button CreationÂ
printButton = Button(root, text="OK", command=printInput, font=('Courier 15 bold'))
printButton.pack(), printButton.place(x=300, y=450)
# Button CreationÂ
printButton = Button(root, text = "OK", command = printInput, font=('Courier 15 bold'))Â
printButton.pack(), printButton.place(x=300, y=450)
# Label CreationÂ
lbl = Label(root, text="Motor Performance Prediction", bg="#2C3E50", fg="white", font=('Courier 18 bold'))Â
lbl.pack(), lbl.place(x=150, y=20)
lbl = Label(root, text="CURRENT", bg="blue", fg="white", font=('Courier 15 bold'))Â
lbl.pack(), lbl.place(x=100, y=270)
lbl = Label(root, text="VOLT", bg="blue", fg="white", font=('Courier 15 bold'))Â
lbl.pack(), lbl.place(x=400, y=270)
lbl = Label(root, text="VIBRATION", bg="blue", fg="white", font=('Courier 15 bold'))Â
lbl.pack(), lbl.place(x=100, y=370)
# Add this line to create the label for prediction output
lbl_prediction = Label(root, text="", bg="red",fg="white", font=('Courier 18 bold'))Â
lbl_prediction.pack(), lbl_prediction.place(x=400, y=400)
root.mainloop()
āđāļĄāļ·āđāļāļĢāļąāļāđāļāļĢāđāļāļĢāļĄāđāļĨāđāļ§āļāļĨāļĨāļąāļāļāđāļāļĩāđāđāļāđ