Face Emotion Recognition Using Machine Learning | Python
Vložit
- čas přidán 10. 06. 2023
- Face Emotion Recognition Using Machine Learning | Python
===============================================
Project Code : -
github.com/kumarvivek9088/Fac...
Face Emotion Recognition Model(62% accuracy) : -
drive.google.com/drive/folder...
Data Images which I used in this Video to train Model :-
www.kaggle.com/datasets/jonat...
Wanna Deploy this Model? Then watch this:
• Deploy ML/DL Model | ...
===============================================
Like Share Comment
And Subscribe
If you want to deploy this model then you can watch this: czcams.com/video/usGUFXCRUIg/video.html and If you are facing an issue of: - Could not locate class 'Sequential' error in Tensorflow while loading model, then you can also watch this.
Sir the model which says epochs 1/ 100 it doesn't show in my jupyter notebook what to do sir no error in the code 28:54
op bhaii thanks a ton could you please make another detailed vedio on installing tensorflow with gpu to run the model
Thanks a lot , it is very helpful. please make more videos on deep learning and machine learning. All the best
I am glad you like this....sure I will make more videos on deep learning and machine learning
Thanks buddy it really work thank you so much
Bhai Mera nhi run kr rha hai
Address dedo bhai aa kr run Kar dete h
It works really well
Thank you so much
can you share your code with me
brother can u please share the model if its above 85% accuracy
Whenever I type “Jupyter notebook “ and enter it , it opens the notebook.py file in vs code and not in the browser, so I have to run the complete code at once. After saving the model using “model.save” , it doesn’t show the name of the file emotion detector in vs code
Did you establish the relationship between the photographs here?
Nice❤❤
Thank you for the tutorial! I was wondering if there was a way to make the algorithm output the detected realtime emotion as a certain data so that it could be used in other programs realtime? For example, if i make a happy face on camera, it gives out a signal to OSCs or JSON etc? I'm trying to create visuals on other softwares so that everytime i make a certain face, it changes the visuals.
hello?
what method did you use for facial recognition? I mean what was the approach?
Is there any project related to speech emotional recognition system?
hey bro nice job, but how can I run this program with gpu instead of cpu?
27:05 "Arguments `target` and `output` must have the same rank (ndim). Received: target.shape=(None, 7, 7, 7), output.shape=(None, 7)". Please help
Those who are facing errors like Tensorflow etc etc should use python 3.8---3.11 version not the latest
Regards
bro?????
can u help me?
Its very nice project ... But i want to change model and find the confusion matrix... How can i do this,?????
How to generate a facial emotion model.json file? 🤔🤔
How have to upload this dataset in JUPYTER?
how to fix if only angry detected in train and test directory
How can we detect face shape? i want to classify face shape but i am very new to ML, can you please guide me??
me making weird faces in forn of my camera to satisfy the result😂🤣
btw thnx for making this video
hey need help!
It so good but mujhe please batao features kya extract kiya hai.....
Lbp features kaunse extract krta hai emotions detection.e
its saying keras preprocessing not found idk why
Same for me also
json_file = open("facialemotionmodel.json", "r")
model_json = json_file.read()
json_file.close()
model = model_from_json(model_json)
model.load_weights("facialemotionmodel.h5")
it shows TypeError: Could not locate class 'Sequential'. and so many error... What should I do
Yes
My jupyter notebook show this type error
@@Granthavali109 solution came...
You need to remove all the Class names on the json file
same
@@seyedrabiuthen after removing what should we write in place of them
WinError 3 the system cannot find the specified: 'images/train ' How to solve this problem 😢
Have you downloaded the dataset ?
do you have to train the model everytime you turn on the computer and open the visual code & jupyter? It takes sooooo long
No, save your model after training and load that model when you do face emotion recognition
@@ProgresswithPython how do you save the trained model?
@@KAZZinteractive all things are explained in the video
@@ProgresswithPython is it the part after the training section where you input 'model.save("emotiondetector.h5")?
Unfortunately i can't understand the language so I have to resort to the youtube auto captions.
@KAZZinteractive yes this is the line to save model
How can I solve it
ImportError: Could not import PIL.Image. The use of `load_img` requires PIL.
Install Pillow
bro, next time se karne k time explain krna why are you using module and all.... it will be helpful for viewers.
Bro interview questions about this project, please tell me
facing this error , even though i hace this file in correct folder : No such file or directory: 'facialemotionmodel.json'
Have you checked whether the file exists or not in that repository with this name
Bro i am getting error in the .ipynb file again and again at the "" train_features = extract_features(train['image']) "" it states File D:\Sanket\Python_Projects\emotion_detection\venv\lib\site-packages\keras\src\utils\image_utils.py:414, in load_img(path, grayscale, color_mode, target_size, interpolation, keep_aspect_ratio Could not import PIL.Image. The use of `load_img` requires PIL. what should i do struck at the same error again and again despite of the fact that i copied and pasted your git code
Install pil module
thanks bro it helped
@@ProgresswithPython
How to run it ? after executing trainmodel.ipynb ? what are the commands to run the app
There is another Python file. Run that file after trainmodel.ipynb
@@ProgresswithPython thank you
hey buddy need help to integrate it with spotify API
I'm also working on same project. Did you understand how to do it?
Will you please help me
Sir could u plz tell in which areas this face emotion is actually used??
It has different applications. For example apart from these emotions if you add "SLEEPY" to it. It will be useful while driving cars so that if its a self driving car , It can come to a stop preventing accidents. Even if its not self driving cars, atleast it can alert the driver. When you consider other applications, like ALEXA and all, In future if it has access to survilence cams, It can reccomend you a music or a movie to cheer you up if it detects you are SAD. So those are some applications. Thank You.
Hi thank you. Project works really well. Where can I find project report for this project? Please help
Sorry bro, I don't have a project report for this.
Can you provide project report for this
@@ProgresswithPython how to get data for a accuracy result
Hey if I just changed the dataset and want to train this model to predict plant leaf diseases will it work?
You can try i
@@ProgresswithPython Maine apko Instagram PE msg kiya hai
model = model_from_json(model_json),I am getting error with this line.Can u tell me how to get rid of it
Have you imported the model_from_json function?
@mohdbilal_shorts what error you getting?
Hey bro same problem have u got any solutions
@furkhanadoni3137 I loaded this same face emotion model in my new video without using model_from_json method...
czcams.com/video/usGUFXCRUIg/video.htmlsi=j2vpphdT5KZbWv_V
I hope this will solve your issues.
@mohdbilal_shorts same bro tell me the solution for this
Bhai yrr isko django ke jariye kese kree uske upr video nii bnayi apne
tensorflow is not installing shown error?
how can I?
Which Python version you are using ?
bro every thing is ok the code is not showing any error but at the last the camera is not opening as i had check the camera permission is also ok
Brother if u have done it, can u please provide the model if it is above 80% accuracy.
once the model is trained, then how to test and detect emotions, My model was working fine, but once I closed the data and try to reuse it , it was showing error , can You tell me the reason please
Save the model and re-use it.
Brother if u have done it, can u please provide the model if it is above 80% accuracy.
Brother no module named ‘cv2’ deka rha h or sab kuch shi chl gya 37:15 bhai pls help me pls bro
Did you got the output
Showing error in this line :-
pred = model.predict(img)
ValueError: Exception encountered when calling layer 'sequential_1' (type Sequential).
Input 0 of layer "conv2d_4" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received: (None, 48)
Call arguments received by layer 'sequential_1' (type Sequential):
• inputs=tf.Tensor(shape=(None, 48), dtype=float32)
• training=False
• mask=None
@ProgresswithPython please help
ImportError: cannot import name 'Maxpooling2D' from 'keras.layers' (C:\Users\avina\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\api\layers\__init__.py)
ye error aa rha baar baar, what to do now
did u find it?
Do anyone worked on confidence detection system based on audio or vedio files
bro im working on it. lets work on it together.
Yeah sure
Extract_features k code par 0/7600 hi bata rah hi after run
N your showing whole imagea like 7600/7600
Please help
Try to rerun the shell
Plsss tell me how to work with SVM classifier instead of CNN model????
MemoryError: Unable to allocate 12.2 GiB for an array with shape (1780, 1, 1280, 720, 1) and data type float64
This error is coming after running model.fit(---) command
have you increase the shape of images?
I am using this method for other images which has 1280*720 dimension@@ProgresswithPython
Can u tell what to do I'm also facing same issue@@ProgresswithPython
@@ProgresswithPythonI'm decreased the size of folders
Can we add songs also according to the detected emotion
Can anyone provide code or CZcams link
if someone have .h5 nad .json file with more accuracy, please share
Yes yah file nhi hai isme
Bhai last main run kar ke bhi bata dete hai
same feeling of shy to show emotion by myself😅😅
Brother if u have done it, can u please provide the model if it is above 80% accuracy.
@@subhayanbose3010 bro if you got the model can you share it with me?
I am getting an errror " No module named 'keras_preprocessing' "
try with "keras.preprocessing"
to_categorical is not getting imported for me
What error are you getting ?
Bhai sab kuch accha hai but ek chiz smajh ni aayi model train he ni hora mere laptiop mein 25% se jyda accuracy he ni aa rahi hai kya kru ?
bro lagbhag 5-6 hours lagte hai model train hone k liye poora time diya aapne?
First of all thank you so much it works perfectly 😊😊😊...but i encountered an error while doing the realtime capturing it shows that can't open camera by index and camera index outof range ......i cant fix this can u please help me
Try with 0 index
Brother if u have done it, can u please provide the model if it is above 80% accuracy.
@@ProgresswithPython brother where to put index 0 in the code can you tell me please its urgent
@@sourav-bisht at line of cv2.videocapture
Import mai error aa raha h import error
14:00
so can we add it in python ai assistant by chatgpt so ai hamari wmotion samaj jaye ga
Yes offcourse
@@ProgresswithPython how bro batao pls mai bana lu baad me video bhi dal Dena pls 😭🙏🥺🙏🙏🥺🥺🙏🥺🥺🙏
@BahutGamingLive simple create a function that takes input from camera and returns output by taking prediction from model and add this function to python ai
@@ProgresswithPython yes can i can make can you prefer me any cheap wireless camera of usb wireless so rpi can support it
@@BahutGamingLive I have no idea about this as I never worked on raspberry pi
Bro can u pls help with this project
Give reply
when print out "model prediction", it always print happy, how can I fix it?
What's your model accuracy?
@@ProgresswithPython the model accuracy in line
[model.fit(x= x_train,y = y_train, batch_size = 128, epochs = 100, validation_data = (x_test,y_test))]
it print out [loss: 1.8245 - accuracy: 0.2435]
@@ProgresswithPython do i have to run whole 100 epochs, it takes hours?
@avataraand76 No, stop when you get good accuracy.
@@ProgresswithPython thank you but how do i know its a good accuracy?
how i can download tensorflow in 3.12 version?
I checked online, and I think tensorflow isn't released for 3.12 yet
but you can try with this command - pip install tensorflow
name error: model is not defined
U have to install keras_prepreprocessing
Meti
Getting same error
Same error
what algorithm did you use to implement it
cnn
real time detection not working, everything is working well except the last and most important part for real time detection
i'm getting this error ;
Exception has occurred: ModuleNotFoundError
No module named 'cv2'
File "C:\Users\crtel\OneDrive\Desktop\FER Python
ealtimedetection.py", line 1, in
import cv2
ModuleNotFoundError: No module named 'cv2'
Install opencv in python
Thank you for responding
i had it already installed, but i somehow fixed that by changing interpreter but now this too
Exception has occurred: AttributeError
module 'cv2' has no attribute 'data'
File "C:\Users\crtel\OneDrive\Desktop\FER Python
ealtime.py", line 11, in
haar_file=cv2.data.haarcascades + 'haarcascade_frontalface_default.xml'
^^^^^^^^
AttributeError: module 'cv2' has no attribute 'data'
And also does output takes time to show?
label is not defined
Jupyter notebook isn't open through vs code terminal so how to open jupyter notebook
you can use command prompt
Tried but didn't work
Jupyter is also install in system but Error occur Jupyter is not recognize in external or internal command
How to solve it
Bhai agar training ke time Mera 75% accuracy bataya toh json file ki jaroorat nahiye ky?
Json file is for to save the trained model
how can i get json source file??
Link in description
Hello sir i cannot open jupyter notebook in vs code please sort it out
Install jupyter notebook
@@ProgresswithPythoni tried sir,it showing the term 'install'is not recognised
@justrise6154 What command did you use for installation
🎯 Key Takeaways for quick navigation:
00:00 🚀 *Introduction and Project Overview*
- Introduces the topic of face emotion recognition using machine learning.
- Mentions audience voting on machine learning projects.
- Briefly discusses the choice of Python and the upcoming projects.
00:57 🛠️ *Installing Python and Required Tools*
- Guides viewers on installing Python using the official website.
- Recommends installing a text editor like VS Code.
- Emphasizes the importance of having Python and VS Code installed for the upcoming projects.
02:35 📂 *Setting Up Project Structure*
- Creates a project folder for face emotion detection.
- Discusses the necessity of organizing files and folders.
- Highlights the importance of creating a test file for the project.
03:15 📊 *Project Planning and Model Selection*
- Discusses the need for tensor and OpenCV models in the project.
- Emphasizes the importance of understanding real-time vision inputs.
03:44 📝 *Setting Up Jupyter Notebook and Package Installation*
- Removes unnecessary lines from the Jupyter Notebook.
- Simplifies the Jupyter Notebook for easier installation.
04:19 🛠️ *Installation Process Overview*
- Overview of the installation process using the terminal.
- Listing the names of packages to be installed.
04:47 🕵️ *Searching for CNN Algorithm*
- Instructions on searching for the Convolutional Neural Network (CNN) algorithm.
- Highlighting the importance of understanding the theory behind CNN.
05:17 📊 *Setting Up the Dataset*
- Creating a data frame for the image dataset.
- Defining columns for image names and labels.
05:45 🖼️ *Organizing Image Data*
- Discussing the structure of the image folder and organizing images by expressions.
- Describing the process of associating labels with images.
06:11 📂 *Creating the DataFrame*
- Creating a table (data frame) to store image information.
- Assigning labels to images within the data frame.
06:43 📸 *Understanding Image Set*
- Examining the structure of the image data set.
- Emphasizing the diversity of expressions and corresponding labels.
07:15 🔄 *Image Processing Overview*
- Outlining the process of loading and converting images.
- Introduction to the Tensorflow method for loading images in grayscale.
08:14 🚂 *Data Set Preparation for Training*
- Data set preparation for face motion recognition.
- Downloading a large data set from the website for facial motion recognition.
09:11 📊 *Jupyter Notebook Setup and Data Import*
- Launching Jupyter Notebook and creating a new file.
- Importing necessary dependencies and verifying the successful download of the dataset.
10:09 🧪 *Organizing Image Data for Training*
- Moving images to the respective folders for face motion detection.
- Deleting unnecessary folders and organizing the dataset for training.
11:27 🔄 *Renaming and Preparing Validation Data*
- Renaming the validation folder to 'test' for uniformity.
- Cleaning up the dataset and preparing folders for training and testing.
12:37 📂 *Directory Structure Explanation*
- Explanation of the directory structure for the train and test data folders.
- The train folder contains subfolders for different emotions (e.g., angry), and each subfolder contains images for that emotion.
13:05 📊 *Creating a Data Frame Function*
- Mention of the manual process and the creation of a function named "create_data_frame" to automate this task.
14:06 🖥️ *Function for Creating Data Frame Implementation*
- Detailed implementation of the "create_data_frame" function.
- Listing folders inside the train directory, labeling them, and creating a data frame with image names and labels.
15:03 🧹 *Cleaning and Checking the Data Frame*
- Explanation of the creation of two columns in the data frame: one for images and another for labels.
- Displaying the data frame for the train data and explaining its structure.
16:19 🔄 *Copying Data Frame for Test Data*
- Copying the data frame structure for the test data by changing the directory paths.
- Verification by running the code and displaying the test data frame.
17:40 🔄 *Function for Extracting Features*
- Introducing the need for extracting features from images for training machine learning models.
- Creating a function to extract features and demonstrating how it works.
18:19 🖼️ *Loading and Converting Images*
- Loading images, converting them to grayscale, and appending them to an array.
- Explaining the process of converting and appending images in a step-by-step manner.
18:59 🧠 *Data preprocessing for face emotion recognition*
- Conversion of data to the format needed for the model.
- Resizing images to 48x48 dimensions.
19:45 🛠️ *Setting image dimensions and running the preprocessing function*
- Setting image dimensions based on dataset details.
- Running the preprocessing function to prepare the features.
20:17 🔄 *Running the training function for face emotion recognition*
- Executing the training function with the training data.
- Obtaining the train feature names and labels.
20:44 🖥️ *Checking the progress and resolving issues*
- Monitoring the progress of the model training.
- Addressing potential issues with model execution.
21:30 🤖 *Supervised learning and label creation*
- Creating labels for training data in supervised learning.
- Understanding the concept of input and label levels.
21:59 📊 *Scaling and installing necessary modules*
- Installing and scaling the model and necessary modules.
- Handling potential issues with module installation.
22:38 🧮 *Label encoding and model adjustments*
- Implementing label encoding for the emotion categories.
- Adjusting the model for compatibility with encoded labels.
23:10 🔍 *Retraining and troubleshooting the model*
- Retraining the model after adjustments.
- Troubleshooting potential errors in the process.
23:57 🧪 *Creating a white test set for evaluation*
- Preparing external features for the white test.
24:25 📝 *Updating classes and preparing for testing*
- Updating class information for the white test set.
- Verifying the available classes for testing.
24:59 📸 *Image Folder Exploration*
- Exploring image folders for training a face emotion recognition model.
- Different classes for emotions like Angry, Disgust, Fear, etc.
25:39 🛠️ *Model Initialization*
- Setting up the model for training.
- Creating a sequential object with layers for Conv2D, MaxPooling, Flatten, and Dense.
26:07 🖼️ *Model Input and Output Configuration*
- Configuring input dimensions matching image shape (48x48 pixels).
- Setting the output layer for classification, considering the number of emotion classes (60 levels).
27:28 ⏸️ *Pausing Training for Tensorflow Installation*
- Recommending the installation of the TensorFlow library for GPU support.
- Guidance on enabling GPU support for faster training.
28:19 🛑 *Stopping Training Process*
- Demonstrating how to stop the training process using a stop button.
- Suggesting to train up to 50 epochs for better accuracy.
28:47 🚀 *Model Training Completion and Evaluation*
- Indicating completion of model training with an accuracy of 24.80%.
- Discussing the significance of achieving good accuracy.
29:24 📈 *Choosing a Model for Inference*
- Evaluating different models based on their accuracy (e.g., 38% and 62%).
- Considering GPU availability for efficient training.
29:54 🤖 *Final Thoughts*
- Expressing the intention to use a specific model for further steps.
- Suggesting potential solutions for users without a GPU.
30:44 🏗️ *Loading and Importing Model*
- Loading the JSON file for the model.
- Importing the trained model into the script.
31:12 🏷️ *Labeling and Preprocessing*
- Creating a list of labels based on emotions or categories.
- Setting up a function to preprocess a single image for prediction.
31:39 🔄 *Training the Model*
- Preparing and training the model on labeled data.
- Handling the output range and interpretation for emotion labels.
32:17 📤 *Prediction and Output*
- Defining a function to accept an image and return predictions.
- Running the function on an "angry" image and displaying results.
32:52 🚧 *Handling Errors and Testing*
- Updating feature variables and resolving an input error.
- Dividing a feature variable by 250 for normalization.
33:49 📸 *Image Display and Verification*
- Loading and printing the original and processed images.
- Verifying the results and correctness of the model.
35:57 🎬 *Completing the Script*
- Renaming and organizing files for clarity.
- Wrapping up the code for a real-time face emotion detector.
36:40 📷 *Real-time Face Emotion Detection*
- Initializing and importing the model for real-time use.
- Utilizing OpenCV to detect faces from the webcam.
37:09 🧐 *Checking Real-time Output*
- Demonstrating real-time face emotion detection.
- Discussing the output and potential improvements.
38:21 🎯 *Improving Model Accuracy*
- Real-time accuracy may not be optimal; training the model can enhance accuracy.
- Users with GPU capabilities can achieve accuracy above 80% through proper training.
Made with HARPA AI
😂nice 🙏
Bhai jupyter notebook open nahin ho raha kya karu
@@Abhijeetghorpade11 vs Code also supports notebooks
Hello sir!! do i need to finish the process of this?
Epoch 1/100
226/226 [==============================] - 414s 2s/step - loss: 1.8224 - accuracy: 0.2441 - val_loss: 1.8126 - val_accuracy: 0.2583
Epoch 2/100
108/226 [=============>................] - ETA: 6:35 - loss: 1.8158 - accuracy: 0.2453
Yes
@@ProgresswithPython epoch 100/100?
@daryllesteroza9542 you can stop the training when you get a good accuracy
Bro can I DO THIS IN PYTHON 3.11
Yes
Bhai isko web application me kaise convert karen? Pls help😅
Epoch 1/100
My accuracy is not crossing 24% at all. What do i do please let me know. Should i wait till Epoch 100/100. Please let me know when to stop the process
Yes , if your accuracy is not well, then you can epoch for 100 and more
@@ProgresswithPythonThank you !
@@ProgresswithPythonBy just saving the notebook, i can use it anytime later also right?
@amithvikramrajaram8072 no, you have to save your model to use it later
ModuledNotfoundError : No module named Keras_preprocessing
11:16 bhai please help me
pip install Keras-Preprocessing
Brother no module named ‘cv2’ deka rha h or sab kuch shi chl gya 37:15 bhai pls help me plsssss
Please no module cv2
Name error test is not defined.... how to solve
I think you missed a cell to run in Jupyter notebook
@@ProgresswithPython I tried twice
train_features = extract_features(train['image'])
After this I am getting error as "Could not import PIL.Image. The use of `load_img` requires PIL."
Please help
You have to install PIL first
Can you please let me know the command for it?
@@sonugowri1483 sure, pip install Pillow
Memory allocation error 270 min when runned the model.fit
How much ram is there in your pc
8gb ram@@ProgresswithPython
@mouryagowdas516 try to close unnecessary background processes and try to free up ram. Or you can use my trained model.
@@ProgresswithPython can list and send me which are the libraries we have used
@mouryagowdas516 you can check the import statements in code
getting this warning after model json;- WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`.
save it as "my_model.keras" instead of "my_model.h5"
thnks, but I’ve already resolved it!
Memory error unable to allocate 507 what to do😢
Reduce number of images
deleting them right@@ProgresswithPython
how to reduce them@@ProgresswithPython
@@mouryagowdas516 yes, by deleting them , deleting some images from every letter folders
Hello bhai mere ko or jhanana hai toh aap merese contact kr sakte ho kya ????
sir pls send me project full
How to run pip
Run it on command prompt
Anyone have a 80% trained model pls send me
Anyone having model trained 80% accuracy plz share google drive link
this has maximum of 72% accuracy
Will it work on mac?
Not sure , but I think it should work. You can try
there is a problem when I run the realtime detection code you have installed other 62% accuracy model but I m using which you have taught in train model code ..so what should I write in line no. 5 and 10 instead of facialemotionmodel and facialemotionmodel.h5 @@ProgresswithPython
Brother looking Sad 😂
😅😅
Bhai bhut error aa rha h
Last me run kaise krruuu???
press run
can you provide the main code sir
Link in the description
@@ProgresswithPython x_train = train_features / 255.0
x_test = test_features / 255.0 error is there
pls tell solution for above error@@ProgresswithPython
Json file isme nhi hai
drive.google.com/drive/folders/1xtF-XtQB4n9HjZy3r-XoyUQQxVHWSgcc
How to get camera 📸??
Please brother reply
Using opecv, code is also there in file
Where can I get CSV File for this project?
Which csv file?
@@ProgresswithPython in Our College They Are Asking CSV File For This Project, what shoul I show them ?
Your facialemotionmodel.h5 is different from my emotiondetector.h5
Sir im having errors for this line of code- y_test = le.transform(test['label']) #{x_test works fine for me)
THE ERROR:
KeyError Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\indexes\base.py:3805, in Index.get_loc(self, key)
3804 try:
-> 3805 return self._engine.get_loc(casted_key)
3806 except KeyError as err:
File index.pyx:167, in pandas._libs.index.IndexEngine.get_loc()
File index.pyx:196, in pandas._libs.index.IndexEngine.get_loc()
File pandas\\_libs\\hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas\\_libs\\hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'label'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Cell In[118], line 1
----> 1 y_test = le.transform(test['label'])
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py:4102, in DataFrame.__getitem__(self, key)
4100 if self.columns.nlevels > 1:
4101 return self._getitem_multilevel(key)
-> 4102 indexer = self.columns.get_loc(key)
4103 if is_integer(indexer):
4104 indexer = [indexer]
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\indexes\base.py:3812, in Index.get_loc(self, key)
3807 if isinstance(casted_key, slice) or (
3808 isinstance(casted_key, abc.Iterable)
3809 and any(isinstance(x, slice) for x in casted_key)
3810 ):
3811 raise InvalidIndexError(key)
-> 3812 raise KeyError(key) from err
3813 except TypeError:
3814 # If we have a listlike key, _check_indexing_error will raise
3815 # InvalidIndexError. Otherwise we fall through and re-raise
3816 # the TypeError.
3817 self._check_indexing_error(key)
KeyError: 'label'
Test ka dataframe proper bnaya tha na ?
@@ProgresswithPython i rechecked it. thankyou sir. Its working
Hi sir, which algorithm is used in building this model
CNN
json_file = open("facialemotionmodel.json", "r")
model_json = json_file.read()
json_file.close()
model = model_from_json(model_json)
model.load_weights("facialemotionmodel.h5")
it shows TypeError: Could not locate class 'Sequential'. and so many error... What should I do
This problem is coming with the latest version of tensorflow. Try it with tensorflow version 2.10.0, and this tensorflow version is not compatible with the latest Python version, so install it in Python 3.10.7