Build a Deep Face Detection Model with Python and Tensorflow | Full Course

Build a Deep Face Detection Model with Python and Tensorflow | Full Course

Nicholas Renotte

3 года назад

272,814 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ottosusenodelvitto3225
@ottosusenodelvitto3225 - 11.04.2025 14:08

whatkind is your editor ?

Ответить
@spiritualseeker9593
@spiritualseeker9593 - 21.03.2025 15:48

this is 5th tutorial for making DL projrcts. in every project i get stuck b3cuase apparently they dojt let me use some function (gui ) in this case due to which half the thijgs doesn't make sense. why do th3y have to change and remove the old ones for gods sake....

Ответить
@theoggamer12
@theoggamer12 - 26.02.2025 20:37

everything is running perfect but the real time detection is messing up badly😭

Ответить
@Asrokid20NOV27
@Asrokid20NOV27 - 04.02.2025 15:05

the points are coming in different order. xmax then xmin , ymax ymin. HELP !!!!!!

Ответить
@arhansk5109
@arhansk5109 - 31.01.2025 08:07

I'm thinking of writing the code from scratch by writing line by line after listening to its function from the video
Is it a good idea and is this video helpful for that?

Ответить
@ChristiaanHunter
@ChristiaanHunter - 23.01.2025 16:48

Thanks

Ответить
@gagandeepsinghsethi
@gagandeepsinghsethi - 29.12.2024 09:29

@Nicholas Does it work good for multiple faces inside a single frame?

Ответить
@Asrokid20NOV27
@Asrokid20NOV27 - 21.12.2024 16:00

Is it necessary to create an environment?

Ответить
@psychotic423
@psychotic423 - 05.12.2024 14:07

I can't be the only one that thinks this guy looks like Giancarlo Esposito, right?

Ответить
@ShreetamaMukherjee
@ShreetamaMukherjee - 24.11.2024 18:48

i am having error in cV2.imread and cV2.imshow, how to oversome thi error

Ответить
@abdulwahabchudhary6269
@abdulwahabchudhary6269 - 27.10.2024 22:42

Sir why we don't use open CV for face detection it may take few lines of code ? could you please clear it ?

Ответить
@debadyutidey7
@debadyutidey7 - 22.09.2024 11:29

how to make a deep fake image detector now?

Ответить
@Uncle19
@Uncle19 - 07.09.2024 01:59

Any idea why my loss functions will not decrease? Over 40 epochs my loss chart is just a flat jagged bar… followed everything to a T…

Ответить
@akshatchaturvedi758
@akshatchaturvedi758 - 28.07.2024 14:44

hey nick, can plz help me to make this workable for multiple classes and objects

Ответить
@KavinrajaD-k7u
@KavinrajaD-k7u - 27.07.2024 10:42

Help me .

Ответить
@mohanrajan5658
@mohanrajan5658 - 25.07.2024 17:45

where can i get the dataset could you please tell me

Ответить
@yurisilva2451
@yurisilva2451 - 12.07.2024 04:31

on my jupyter enviroment i got this error when trying to install the libraries

ERROR: Could not find a version that satisfies the requirement tensorlow-gpu (from versions: none)
ERROR: No matching distribution found for tensorlow-gpu

if anyone can help me out

Ответить
@neeljunnarkar2003
@neeljunnarkar2003 - 27.06.2024 16:01

How can I use Transfer Learning on this to make it a happy/angry face Obvject Detection

Ответить
@sai.sankarwork
@sai.sankarwork - 18.06.2024 12:49

Is it possible to train a custom DeepFace model for emotion recognition?

Ответить
@greatness-kw3wl
@greatness-kw3wl - 16.06.2024 13:23

Hello, I'm having a challenge pip installing tensorflow-gpu.
(tf-gpu) C:\Users\seasi>pip install --upgrade tensor-gpu
ERROR: Could not find a version that satisfies the requirement tensor-gpu (from versions: none)
ERROR: No matching distribution found for tensor-gpu.
This the error message i get.
I have explored chatgtb and the tensorflow site.
i'm using python 3.8.19 .

Ответить
@kirilllakhov1409
@kirilllakhov1409 - 26.05.2024 17:15

Thanks for the tutorial!
I've managed to go through all the steps and got quite nice model, but as some of the users here I've encountered some problems with Model training and saving.
1. ValueError: Cannot take the length of shape with unknown rank:
The problem is in loading labels (step 5.4). By default train_labels have Unknown tensor shape. We need to specify it manually (we need to do it for train_labels, test_labels, val_labels):
train_labels = train_labels.map(lambda x, y: (tf.reshape(x, [1]), tf.reshape(y, [4])))

2. Saving in step 11.2 is incorrect. The provided code saves `facetracker` model which is not the one we really trained (which is `model`). We need to save the `model` and call `model.predict` to get results. Also, .h5 format is deprecated now, so its recomended to use .keras fomat. So we need to call model.save('model.keras')
But thats not really enough, to serialize FaceTracker model properly we need to add `@tf.keras.utils.register_keras_serializable()` decorator and define two methods for correct model field serialization. In method get_config we need to serialize the model object inside FaceTracker class, and in method from_config we need to load it.
Note: I've changed the `model` field name to `eyetracker`
Hope it helps!

Full FaceTracker updated code:
@tf.keras.utils.register_keras_serializable()
class FaceTracker(Model):
def __init__(self, eyetracker, **kwargs):
super().__init__(**kwargs)
self.eyetracker = eyetracker

def get_config(self):
base_config = super().get_config()
config = {
"eyetracker": tf.keras.utils.serialize_keras_object(self.eyetracker),
}
return {**base_config, **config}

@classmethod
def from_config(cls, config):
sublayer_config = config.pop("eyetracker")
sublayer = tf.keras.utils.deserialize_keras_object(sublayer_config)
return cls(sublayer, **config)

def compile(self, opt, classloss, localizationloss, **kwargs):
super().compile(**kwargs)
self.closs = classloss
self.lloss = localizationloss
self.opt = opt

def train_step(self, batch, **kwargs):

X, y = batch

with tf.GradientTape() as tape:
classes, coords = self.eyetracker(X, training=True)

batch_classloss = self.closs(y[0], classes)
batch_localizationloss = self.lloss(tf.cast(y[1], tf.float32), coords)

total_loss = batch_localizationloss+0.5*batch_classloss

grad = tape.gradient(total_loss, self.eyetracker.trainable_variables)

opt.apply_gradients(zip(grad, self.eyetracker.trainable_variables))

return {"total_loss":total_loss, "class_loss":batch_classloss, "regress_loss":batch_localizationloss}
def test_step(self, batch, **kwargs):
X, y = batch

classes, coords = self.eyetracker(X, training=False)

batch_classloss = self.closs(tf.cast(y[0], tf.float32), classes)
batch_localizationloss = self.lloss(tf.cast(y[1], tf.float32), coords)
total_loss = batch_localizationloss+0.5*batch_classloss

return {"total_loss":total_loss, "class_loss":batch_classloss, "regress_loss":batch_localizationloss}

def call(self, X):
return self.eyetracker(X)

Ответить
@startup9864
@startup9864 - 11.05.2024 02:52

what's the accuracy of your model here ?

Ответить
@ShafaaPAlZahra
@ShafaaPAlZahra - 29.04.2024 10:28

Hello, thank you for your video it is very helpful for doing my final assignment. But I get an error when I run through this code in part 10.2:
hist = model.fit(train, epochs=10, validation_data=val, callbacks=[tensorboard_callback])

it returns:
ValueError: Cannot take the length of shape with unknown rank.

Can you help me with that?
Thank you

Ответить
@aysahyaheje28
@aysahyaheje28 - 19.04.2024 06:14

Do you have multiple class or labels used in face detection model? I want to be more specific such as name of a person that i want to use. Thank you

Ответить
@swagatbaruah522
@swagatbaruah522 - 18.04.2024 15:57

Don't exactly know why but loading the .h5 model in my case is taking soo much time.. its been 9 minutes and its still loading..
Did all of the above steps in COLAB and downloaded the .h5 file from the there and trying to use that on my local machine.. When I'm trying to load the model...is taking soo long... Can anyone help ??

Ответить
@anshikathorat8171
@anshikathorat8171 - 17.04.2024 19:52

Where to purchase this project??

Ответить
@pauste2459
@pauste2459 - 15.04.2024 17:01

Hey, i wanted to ask if you have any papers, regarding your information. I am currently trying to create some simple face detection for a subject at univ. and your tutorial is awesome.

Ответить
@gblazerify
@gblazerify - 11.04.2024 06:23

This is awesome, Nick! How does the complexity increase if you want to identify multiple boxes in the image, and/or combine them together to identify empty space in the image. Is there a similar approach to identify things in say, rendered html... Is there an alternative to cv2 that can render and visualize html, like chromium?

Ответить
@aymansomai7205
@aymansomai7205 - 08.04.2024 16:34

Hi nick can you build a special model similar to this one.

The GOAL: detecting the individual from the face image.
Description: 1-detect the face; 2-determine the individual from the dbs or folder of stored images.

Perfections step: determine date of the face detection or individual detection.

Ответить
@dharsan31
@dharsan31 - 05.04.2024 16:04

Nick what's the difference between this and using the tfod in your previous video .I am new to this deep learning so can you just tell the difference

Ответить
@danieloluwapomile9068
@danieloluwapomile9068 - 01.04.2024 15:09

I keep getting array[0], dtype=uint8), array([0. , 0., 0., 0.]) dtype=float16)) please why i need an answer quickly please

Ответить
@bandoyando
@bandoyando - 27.03.2024 21:43

Hello Nicholas, greate video mate i do have a question when following everystep you take the github code just does not work at 2 stages:

fig, ax = plt.subplots(ncols=4, figsize=(20,20))
for idx in range(4):
sample_image = res[0][idx]
sample_coords = res[1][1][idx]

cv2.rectangle(sample_image,
tuple(np.multiply(sample_coords[:2], [120,120]).astype(int)),
tuple(np.multiply(sample_coords[2:], [120,120]).astype(int)),
(255,0,0), 2)

ax[idx].imshow(sample_image)

(error is it does not show the pictures like in your video ) displayes nothing

and

class FaceTracker(Model):
def __init__(self, eyetracker, **kwargs):
super().__init__(**kwargs)
self.model = eyetracker

def compile(self, opt, classloss, localizationloss, **kwargs):
super().compile(**kwargs)
self.closs = classloss
self.lloss = localizationloss
self.opt = opt

def train_step(self, batch, **kwargs):

X, y = batch

with tf.GradientTape() as tape:
classes, coords = self.model(X, training=True)

batch_classloss = self.closs(y[0], classes)
batch_localizationloss = self.lloss(tf.cast(y[1], tf.float32), coords)

total_loss = batch_localizationloss+0.5*batch_classloss

grad = tape.gradient(total_loss, self.model.trainable_variables)

opt.apply_gradients(zip(grad, self.model.trainable_variables))

return {"total_loss":total_loss, "class_loss":batch_classloss, "regress_loss":batch_localizationloss}

def test_step(self, batch, **kwargs):
X, y = batch

classes, coords = self.model(X, training=False)

batch_classloss = self.closs(y[0], classes)
batch_localizationloss = self.lloss(tf.cast(y[1], tf.float32), coords)
total_loss = batch_localizationloss+0.5*batch_classloss

return {"total_loss":total_loss, "class_loss":batch_classloss, "regress_loss":batch_localizationloss}

def call(self, X, **kwargs):
return self.model(X, **kwargs)

model = FaceTracker(facetracker)

model.compile(opt, classloss, regressloss)

10.2 Train

logdir='logs'

tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=logdir)

hist = model.fit(train, epochs=10, validation_data=val, callbacks=[tensorboard_callback])

does not wanna train at all error about Cannot take the length of Shape and what ever i do it wont fix the problem

even if i check the path check coords check data make sure everything is well labeld even good mix of images with face and non face.

is it possible for you to update the github code to addres these problems or maybe a new guide ??

Ответить
@kapilujwal8039
@kapilujwal8039 - 25.03.2024 14:59

nick what if i have dataset of different faces with different labels, how can i print those labels instead of just 'face'

Ответить
@aoiharu5976
@aoiharu5976 - 15.03.2024 23:59

thank you!! it helped a lot to build face detector from stratch and i've learned tons of things from you, really appericiated <3

Ответить
@sanketsingh6541
@sanketsingh6541 - 28.02.2024 08:28

i want to detect a object which as similar properties and large in number in singe frame

Ответить
@preadtorsiddharth4391
@preadtorsiddharth4391 - 18.02.2024 21:01

for the new coder watching video in 2024 tensorflow-gpu library has been disabled directly install tensorflow and opencv

Ответить
@whitelisted17652
@whitelisted17652 - 16.02.2024 21:04

Hello, Can I implement this code in an project I am making, what are the licensing terms? It would great help!!

Ответить
@OmaraAJ
@OmaraAJ - 31.01.2024 23:51

I like the video, explanations are clear and to the point. But I've to admit, I like it when people type out the code from scratch instead of reviewing code. Thanks for the tutorial.

Ответить
@mmarsyad
@mmarsyad - 25.01.2024 22:41

I wonder is it possible to use ImageDataGenerator from TensorFlow Keras? and if possible how to deal with the coordinate 🤔

Ответить