Open spr1teZzz opened 1 year ago
Hi, I hope you are asking about the data type (file format .p), if its so, this is the explanation chatGPT gave me
A .p file is not a common file extension, so it's hard to say what type of file it is without more information. In general, pickle files are a widely used format for serializing and deserializing Python objects, and they have some advantages such as being easy to use and supporting most Python objects. However, the choice of file format depends on the specific use case and requirements
And here is the code to convert your dataset into a archive with a .p format
import os import cv2 import numpy as np import pickle
data_folder = "path/to/your/data/folder/" (the dataset its no divided in test and train yet)
classes = ["class1", "class2", "class3"] # The names of your classes (emotions in this case)
img_size = 224 ## Image size
data = [] labels = []
for class_idx, class_name in enumerate(classes):
class_folder = os.path.join(data_folder, class_name)
# Loop over each image in the class folder
for img_name in os.listdir(class_folder):
# Read the image using OpenCV
img_path = os.path.join(class_folder, img_name)
img = cv2.imread(img_path)
# Resize the image to the desired size
img = cv2.resize(img, (img_size, img_size))
# Convert the image to grayscale
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Add the image data and label to the lists
data.append(img)
labels.append(class_idx)
data = np.array(data) labels = np.array(labels)
with open("image_data.p", "wb") as f: pickle.dump((data, labels), f)
Hope this helps
Can you show me the data type of your training?
Hello,
Sorry for the span, but I spent the weekend modifying the code and now it works,
here you can go to see in my github repo
https://github.com/gipinze/Computer-Vision-Thesis/tree/main/MediaPipe%20CNN
In short, you need to convert your dataset to pickle file or .p format, so I have 2 files to do that (one for pickle and one for .p)
Once you do that the code is basically the same, but I did some modifications to make it easier and similar to my previous work.
I trained one model with 48 x 48 x 1 images using RAF-DB and got me 74% accuracy, so its pretty good and also very fast
Hope is not late for what you need and it still works for you.
Have a nice day
Can you show me the data type of your training?