How to detect faces in real time or in a single image

how to detect faces in real time (video) or in a single image with pytorch (neural network)
regards …

You could just search for an open source implementation for face detecion (I just checked and there seem to be multiple implementations) and use one of these as a starter code.

If you want to implement it by yourself, you would need a dataset, create an appropriate model architecture, and train the model as described in our tutorials.

1 Like

@ptrblck how to prepare the dataset

this folder contains multi folders and each of them include 10 images of one person (10 image for one identify)
but the problem is i dont know how separate them to train , and test ? and how to provide one label for 10 images ? thanks for your advice

If each folder contains images from a separate class, you could use torchvision.datasets.ImageFolder.
To split the dataset to a training, validation, and test set you could use Subset or SubsetRandomSampler.

1 Like

and what if want to convert the dataset to csv format ?

Do you mean how to load data from a csv file?
If your data is directly stored in the csv, you could write a custom Dataset, open the file in the __init__ method, and load each sample in __getitem__.

This approach would also work, if the csv stores file paths to the samples.

Alternatively, you could also preload the data and use a TensorDataset. It depends on your use case, so a bit more information would be needed.