Build an AI/ML Tennis Analysis system with YOLO, PyTorch, and Key Point Extraction

Поділитися
Вставка
  • Опубліковано 5 сер 2024
  • In this video, you'll learn how to use machine learning, computer vision and deep learning to create a tennis analysis system. This project utilizes YOlO a state of the art object detector to detect the players and the tennis balls. It also utilizes trackers to track those object across frames. We also write our own conveloutional Nueral network to detect court key points. Github link is provided bellow.
    In this video you will learn how to:
    1. Use ultralytics and YOLOv8 to detect objects in images and videos.
    2. Fine tune and train your own YOLO on your own custom dataset.
    3. Train a CNN with pytorch to extract keypoints.
    4. Use object trackers to track objects across frames.
    5. Use CV2 to read, manipulate and save a video.
    6. Analyze detection data and take a data driven approach to develop features.
    7. Put all those ML/DL model output into one big project that have a concrete output.
    Robowflow Tennis ball Dataset: universe.roboflow.com/viren-d...
    Github Link: github.com/abdullahtarek/tenn...
    🔑 TIMESTAMPS
    ================================
    0:00 - Introduction
    1:00- Object detection with YOLO
    11:30 - Train YOLO on tennis balls
    22:35- Object Tracking
    25:40- Train key point detection with Pytorch
    50:55- Tennis Analyzer

КОМЕНТАРІ • 370

  • @ArrowK3y
    @ArrowK3y 4 місяці тому +334

    As soon as I saw the Activate Windows. I knew this was going to be a banger of a video

    • @devincooke9314
      @devincooke9314 4 місяці тому +1

      Just abt to say that 😂

    • @ramachokkalingam
      @ramachokkalingam 4 місяці тому +1

      Why?
      Why did he not activate the windows?

    • @axellindahl2442
      @axellindahl2442 4 місяці тому

      @@ramachokkalingam VM most likely

    • @dumbass.1693
      @dumbass.1693 4 місяці тому +1

      Tip: You can run a script to generate a fake generic key to activate and remove the watermark.

    • @axellindahl2442
      @axellindahl2442 4 місяці тому

      @@dumbass.1693 or just buy a license

  • @RishabhBohra13
    @RishabhBohra13 4 місяці тому +46

    commenting so this gets recommended to everyone in next 5 years

  • @c0mpuipf
    @c0mpuipf 4 місяці тому +54

    very little comments and views, i feel like i'm in such a select company, will definitely try this, you efforts, sir are unimaginably valued

    • @kellymoses8566
      @kellymoses8566 4 місяці тому +4

      extremely technical videos just don't get a lot of views on youtube because their audience is inherently limited.

  • @lazarobeas579
    @lazarobeas579 4 місяці тому +20

    Wow, perfect. Love that it's long and proper. Will be building this along with you!

  • @psykick7947
    @psykick7947 4 місяці тому +5

    This is amazing! It is very rare and difficult to find help and resources like this anywhere. Really appreciate it. Hope to see more of this kind of content!

  • @sohamjana3802
    @sohamjana3802 4 місяці тому +4

    This has been a gem of a project…!! A lot of concepts have been explained and learnt a lot. Thank you.

  • @mbsanga21
    @mbsanga21 4 місяці тому +6

    im completely new in this field but the first 10 minutes of this video im already feeling like im pro. thank you for the video.

  • @varunsuresh22
    @varunsuresh22 4 місяці тому +3

    Love these long tutorials.. comforting.. will be watching it over the weekend! Thanks!

  • @Amnskary
    @Amnskary 2 місяці тому +1

    This projects are insane, please continue the series, it has been very helpful.

  • @LyuboslavPetrov
    @LyuboslavPetrov 4 місяці тому +18

    This is some fantastic work and presentation of grand value. Thank you

  • @boogersincoffee
    @boogersincoffee 2 місяці тому

    I was about to go to bed. Finding this video got me so excited that I'll probably be up another hour. Can't wait to watch this tomorrow.

  • @senzeit6152
    @senzeit6152 4 місяці тому +1

    Ohhhh ive been searching for some ML projects and today yt funally recommend me your channel, you should def keep doing more oroject videos, ill def try this

  • @huyphanducnhat1609
    @huyphanducnhat1609 3 місяці тому +3

    Banger,we are graduating university with this vid 🔥🔥

  • @CHNLTV
    @CHNLTV 4 місяці тому

    Impressive! love the detail provided. Thank You!

  • @booky6149
    @booky6149 4 місяці тому

    Worth watching. Lots of learning. Thank you for sharing!

  • @atlasguilt1875
    @atlasguilt1875 4 місяці тому +2

    Thanks, exactly what I was looking for.

  • @smnomad9276
    @smnomad9276 4 місяці тому +13

    New subscriber here, already watched over 10 of your videos. Your content is super underrated, your channel and videos are awesome! Keep up the good work!

    • @codeinajiffy
      @codeinajiffy  4 місяці тому +1

      Thanks a lot for those kind words 😍. I really appreciate it. 🙏

  • @mutzelmann
    @mutzelmann 4 місяці тому

    this is what I had looking for...thanks a lot for your great job

  • @gautamthakur8581
    @gautamthakur8581 4 місяці тому +1

    Appreciate your work Sir.
    Love from India

  • @user-oq7ju6vp7j
    @user-oq7ju6vp7j 2 місяці тому

    Wow! Very cool and not super complex project. Thank you for yolo introduction!!

  • @wallisCodes-ig5lh
    @wallisCodes-ig5lh 2 місяці тому +1

    Just stumbled upon this video by chance, and boy am I grateful!
    As a beginner to the world of ML, I think it would be amazing if you could make some beginner friendly project tutorials (I know a lot of other people would appreciate it too).
    Somebody in the comments said something about an mnist digit recogniser? Would be cool to get a video on that!

  • @pro0706
    @pro0706 4 місяці тому +1

    Good bless ur soul good sir for such an amazing and detailed video!

  • @varram3488
    @varram3488 4 місяці тому +2

    this is gonna be the perfect into to AI and python development for me as a guy coming for a mostly node.js backend background

    • @buckyzona
      @buckyzona 4 місяці тому +1

      make sure to build an mnist digit recognizer. basically the hello world of ml

  • @gabrielpizarro6394
    @gabrielpizarro6394 4 місяці тому +1

    i love this!. you inspire me to implement something similar for table tennis

  • @ztech-consulting
    @ztech-consulting 4 місяці тому +1

    Excellent work man!!! I don't code but I watched the whole video.

  • @mh-ll
    @mh-ll Місяць тому

    Abdullah, thank you so much for your hard work in this video. I learned a lot.
    Your teaching style is unrivalled. I easily followed and understood everything.
    Thank you, please keep up the good work

  • @raphaellevy8263
    @raphaellevy8263 3 місяці тому +1

    Amazing video!!! Will definitely reproduce for other sports!! Thank you!!!

  • @yoonbledon
    @yoonbledon 3 місяці тому

    Thank you very much for your amazing work. I've learned a lot!

  • @a.k.aproxi5442
    @a.k.aproxi5442 25 днів тому

    amazing project, just completed it...took me a week ;)
    it was little hard but ultimately worth it!
    Great video :)

  • @itiswhatisis8174
    @itiswhatisis8174 3 місяці тому +1

    A few years ago I wondered of this type of thing would be used before big boxing matches. One training camp runs a data analysis (like this) on the opponents previous 10 matches. And perhaps with the right parameters you can notice some recurring bad habits/openings in the oponents game.

  • @rockdude1122
    @rockdude1122 4 місяці тому +4

    Amazing video! I would love to see a similar implementation for football :)

  • @voyager2straightpath
    @voyager2straightpath 4 місяці тому +2

    Thanks for the whole effort. Your video has a great coverage of computer vision.

  • @jayeshbaviskar9251
    @jayeshbaviskar9251 4 місяці тому +3

    awesome content! would love to see similar project with action detections for Football

  • @RickBeacham
    @RickBeacham 4 місяці тому +2

    I love this! Thanks bro!

  • @Ridhostarr
    @Ridhostarr 4 місяці тому

    Great thing! Will learn how to recreate it!

  • @mertmunuklu7732
    @mertmunuklu7732 4 місяці тому

    I learned so much things from this video thx

  • @gustavojuantorena
    @gustavojuantorena 4 місяці тому +1

    This is incredible content, you have a new subscriber sir!

  • @SEVEN-og1td
    @SEVEN-og1td 4 місяці тому +1

    İ saw your video and i love it. İ follow u anymore your videos just perfect

  • @mwaqze
    @mwaqze 2 місяці тому

    This is a great video. Thank you so much.

  • @ziadzamab5061
    @ziadzamab5061 4 місяці тому +1

    Great Work Thank You !

  • @joshbleijenberg4000
    @joshbleijenberg4000 4 місяці тому +2

    Great content!

  • @buckyzona
    @buckyzona 4 місяці тому +1

    this is amazing, thank you!

  • @ai1998
    @ai1998 4 місяці тому +1

    great ! Keep up the good work!

  • @justcars2454
    @justcars2454 3 місяці тому

    it looks a cool project, thank you

  • @user-zi2xu6mx8o
    @user-zi2xu6mx8o 4 місяці тому +2

    شكرا يعم الحج: تسلم و تسلم مصر كلها

  • @abdulhameed92
    @abdulhameed92 3 місяці тому +1

    Thank you god for sending this vido my way.

  • @emileeid6347
    @emileeid6347 4 місяці тому

    Thank you for this !!!

  • @NamLeHoang-xg1th
    @NamLeHoang-xg1th 3 місяці тому +2

    Good job sir, keep up these projects like this!!!

    • @NamLeHoang-xg1th
      @NamLeHoang-xg1th 3 місяці тому

      36:51, will go back to this when having time

    • @NamLeHoang-xg1th
      @NamLeHoang-xg1th 3 місяці тому

      I got this problem when my Colab said this when I try to unzip the file in 31:35:
      Archive: tennis_court_det_dataset.zip
      End-of-central-directory signature not found. Either this file is not
      a zipfile, or it constitutes one disk of a multi-part archive. In the
      latter case the central directory and zipfile comment will be found on
      the last disk(s) of this archive.
      unzip: cannot find zipfile directory in one of tennis_court_det_dataset.zip or
      tennis_court_det_dataset.zip.zip, and cannot find tennis_court_det_dataset.zip.ZIP, period.

    • @codeinajiffy
      @codeinajiffy  3 місяці тому

      Try and get a new wget command. I use a chrome extension called CurlWget that will get you the command whenever you press download on any link.

  • @nishant_soni97
    @nishant_soni97 4 місяці тому

    keep up the good work. new subscriber

  • @andrulll
    @andrulll 4 місяці тому

    Thank you for Sharing ❤️

  • @pascalwatteel2095
    @pascalwatteel2095 4 місяці тому

    bloody good video, impressive

  • @MCroppered
    @MCroppered 4 місяці тому

    Great work

  • @dhlml
    @dhlml 4 місяці тому +6

    The shot speed can't be right, the typical speed of pro shots is around 80-140 kph.
    What I think would be needed is to take into consideration the camera angle using sin/cos. Then you could calculate the actual ball speed, considering the ball trajectory to be parallel to the ground.. or multiplying it with a constant for the typical trajectory (flying over the net and bouncing before a shot).

    • @dhlml
      @dhlml 4 місяці тому +3

      Or actually easier - calculating the speed from tennis court length vs time it took the ball to cover it. Plus a bit of calculation for the angles..not too complex in comparison to the current model.

    • @codeinajiffy
      @codeinajiffy  4 місяці тому +1

      That might be a good enhancement, I will surely try that in my next projects.

  • @jordankuzmanovik5297
    @jordankuzmanovik5297 4 місяці тому +1

    Just keep doing this!!

  • @nlsnboa8187
    @nlsnboa8187 4 місяці тому

    Insane project

  • @mavgo
    @mavgo 4 місяці тому

    nice abdullah

  • @pilau
    @pilau 2 місяці тому

    Fantastic and helpful!.. 💯

    • @shubhasheeshkundu9933
      @shubhasheeshkundu9933 26 днів тому

      for train point key detection its take too much time cann anyone give me the model file

  • @nascentnaga
    @nascentnaga 4 місяці тому

    finally. something perfect for my interests and skillset. I know some python and look at my youtube channel its all personal tennis videos lol

  • @motivationalquotes9252
    @motivationalquotes9252 4 місяці тому

    love this and thank you

  • @INFAmadeOFF
    @INFAmadeOFF 4 місяці тому

    very cool. i would to see this done to a handball game

  • @miguel-deep-soccer
    @miguel-deep-soccer 4 місяці тому

    Absolute genius

  • @santiagomartinez3417
    @santiagomartinez3417 4 місяці тому

    Good job!!!

  • @farestabib6858
    @farestabib6858 21 день тому

    excellent job thank you very much can you please make more projects i like the way to present

  • @not_amanullah
    @not_amanullah 4 місяці тому

    This is helpful ❤

  • @suyashdahale4355
    @suyashdahale4355 4 місяці тому +4

    Super long video just got by UA-cam recommendation will try to follow

  • @yuanhu6031
    @yuanhu6031 4 місяці тому +1

    The idea is interesting, as an recreational tennis player I think these speeds (33km/h) are at 2X slower than it should be, pro players range should be 100+ km/h in neutral rallies.

    • @vojastevanovic6634
      @vojastevanovic6634 3 місяці тому

      Could be easilly checked during the serve, right ? :D

    • @aisimo
      @aisimo 3 місяці тому

      should be checked during racket -> ground

  • @gobishangar7346
    @gobishangar7346 4 місяці тому +1

    Thank you bro

  • @FireFly969
    @FireFly969 3 місяці тому

    Hey jiffy, the video would be so perfect if you add the right timestamps, thank you for this great content you make ❤

  • @algebracrat
    @algebracrat 4 місяці тому

    AMAZING!

  • @doblefe815
    @doblefe815 4 місяці тому

    awesome bro!

  • @umaiskhan6278
    @umaiskhan6278 24 дні тому +1

    player tracker 51:07
    ball_tracker 1:20:48
    court keypoints 1:27:34
    ball tracker interpolation 1:48:00
    choose and filter players 1:59:00
    Ball Hit 3:03:00
    Player pos to MiniCourt pos 3:23:00

  • @nktthegreat
    @nktthegreat 4 місяці тому +1

    This is actually a great video! Can you please do similar stuff for football (soccer)? Or give any links to your work or other open source works related to that? Will be of much help! Thanks!
    Already subscribed btw!
    Great Work!

    • @codeinajiffy
      @codeinajiffy  4 місяці тому +1

      maybe this github: github.com/pmavr/sport-analysis. And I will plan to do a football soon.

    • @nktthegreat
      @nktthegreat 4 місяці тому

      Thanks a ton! Waiting for your video for football :D@@codeinajiffy

  • @Aisi555
    @Aisi555 4 місяці тому

    nice tutorial...

  • @paulpolizzi3421
    @paulpolizzi3421 3 місяці тому

    very COOL!!!

  • @nickachee5314
    @nickachee5314 4 місяці тому

    quite amazing

  • @homeless7860
    @homeless7860 4 місяці тому

    TYSM!

  • @randelventura987
    @randelventura987 4 місяці тому +1

    awesome

  • @ToanLy31415
    @ToanLy31415 3 місяці тому

    Wow, this is impressive. Lots of learning! How can I reach to this level? Thanks a lot for this amazing tutorial!

  • @miguel-deep-soccer
    @miguel-deep-soccer 4 місяці тому

    Hi again I find the video amazing and I am being able to follow along on my laptop and using the kaggle account GPU. Just for curiosity, how long did this project take you? Did somebody help you or did you do it by yourself? Thanks for sharing

    • @codeinajiffy
      @codeinajiffy  3 місяці тому

      I spent 1.5 weeks working on this project and experimenting with stuff. I did it myself, but I do have experience with working with such models from work.

  • @JhonnyTech-ne9dt
    @JhonnyTech-ne9dt 2 місяці тому

    Thank you!!! It's an excellent video. I must say, no one teaches such detailed content on UA-cam. It's incredibly beneficial for students in engineering and technology. I do have a few questions though. Is this applicable in real time, such as by using a webcam?

    • @codeinajiffy
      @codeinajiffy  2 місяці тому +1

      This might not be real time out of the box, but it can be adapted to work real time yes.

    • @shubhasheeshkundu9933
      @shubhasheeshkundu9933 26 днів тому

      for train point key detection its take too much time cann anyone give me the model file

  • @scottmoeller6916
    @scottmoeller6916 4 місяці тому +1

    If you've running this on a M-series Mac, include 'device='mps' in your model.predict call to get ~10x faster results

  • @godloveinaction
    @godloveinaction 3 місяці тому +1

    New sub here 😃

  • @smokinep
    @smokinep 4 місяці тому +3

    A suggestion would be to break the video into parts

  • @not_amanullah
    @not_amanullah 4 місяці тому

    Thanks ❤

  • @salvation_3382
    @salvation_3382 4 місяці тому +2

    Hey! I ran into bit of a problem so hoping for some clarification. In 19:12, you just switched from local IDE to google collab and run your .ipynb file there. But when I tried running that file on google collab, it was not able to train for 100 epochs ( it just kinda stopped), so it did not generate the files that you got generated from the same code. what might be the problem here? Are there any other jupyternotebooks with GPU so i can run this .ipynb files to get those best.pt and last.pt files for me?

    • @codeinajiffy
      @codeinajiffy  4 місяці тому +3

      yes, that happens sometimes. You need to dedicate all your daily free GPU resources for that for one day. But Kaggle gives the ability to also train on their GPUs and last time I checked you had 30 hours worth of GPU training there. You can try that.

    • @BigMike_23
      @BigMike_23 3 місяці тому

      Hey I'm also stuck here and idk what exactly I should do to fix it. DId you get it fixed yet??

    • @BigMike_23
      @BigMike_23 3 місяці тому

      @@codeinajiffy Why in your video it say 1/10 for Epoch while mine says 1/100??? Is it okay if I also do just 10 Epoch like you did in the video??

    • @BigMike_23
      @BigMike_23 3 місяці тому

      Update: It was because it's going past the ram limit of 12GB so I went to buy the google collab pro which was $16 to get a higher RAM of 51GB and got to do the epoches. It takes FOREVER to do them like atleast 17mins per epochs so hopefully doing 10 like he did in the video wouldnt matter so much haha

    • @rAnDoMcHaNnEl593
      @rAnDoMcHaNnEl593 2 місяці тому

      @@BigMike_23 you think is possible to train it on my local machine which has RTX 4080? cuz i still can't figure out this colab thing

  • @Abdullah32066
    @Abdullah32066 4 місяці тому

    It was perfect! Thanks a lot.
    Do you have any advice to make the keypoints detection become more accurate? Are the training data accurate?

    • @codeinajiffy
      @codeinajiffy  4 місяці тому +2

      Thanks 🙏. Yeah we should use augmentations in training to help the model generalize better. We can also use densenet instead of resnet as I usually see better results that way.

  • @goncalogomes1944
    @goncalogomes1944 Місяць тому

    Hello, when i try to use the code for a different video than the one you used as input it gives a key error in the convert_bounding_boxes_to_mini_court_coordinates function. I don't know if you can help me with that 😕

  • @mich90907
    @mich90907 4 місяці тому

    Great video, thanks for talking it through. Do you think YOLO can also work for other sports like football and basketball or do many players make it difficult for the model to track?

    • @codeinajiffy
      @codeinajiffy  4 місяці тому

      I think it will work for those as well. I might try it out very soon and see.

    • @mich90907
      @mich90907 4 місяці тому

      @@codeinajiffy great, I'll be looking forward to it!

  • @nitinagarwal1214
    @nitinagarwal1214 4 місяці тому +2

    great video,
    just one question, the far side of the court takes up considerably less pixels as compared to the side of the court where Djokovic is playing, but that has not been taken into consideration in the calculations for converting pixels to meters

    • @pedrodaniel3161
      @pedrodaniel3161 3 місяці тому +2

      Your question is valid and I would also add another, camera lens distortion is a present and explicit fact in all professional cameras, an input functionality for this data before calculating would be necessary, if this software were to have any commercial use, but As it's just a tutorial and far from being a product, I believe it's perfect

    • @codeinajiffy
      @codeinajiffy  3 місяці тому

      You are correct, I tried to counter act that by matching it to the closest keypoint so it should be closer to reality. But some people in the comments mentioned that I should perspective transformation in order to measure this accurately. And this is what I will do in my next video.

  • @brianfari9731
    @brianfari9731 4 місяці тому

    hi, i want to ask some question. i have been following your tutorial but after training done the weights file doesn't show up in my folder? why is that?

    • @codeinajiffy
      @codeinajiffy  4 місяці тому

      If you are training on Colab you will have to refresh the folder structure from the in the left side bar so that you can see the new files and folders that were added.

  • @oilbender
    @oilbender 4 місяці тому

    Hello, great video. I have a quick question, what do you think of using a library like supervision for tracking keybpoints, player displacement and distance instead?

    • @codeinajiffy
      @codeinajiffy  4 місяці тому

      That's a cool approach that I am thinking of using in my next project.

  • @moiserwibutso4899
    @moiserwibutso4899 3 місяці тому +1

    What hardware did you use for this project? I tried to use my hp laptop running ubuntu 20.04 but I couldn't install ultralytics instantly like you did.

    • @codeinajiffy
      @codeinajiffy  3 місяці тому

      I am using a PC with i7 10th gen, 16 gb ram, with an ssd and no GPU. I installed ultralytics before so my command did not go through all the steps again. If you are installing it for the first time then it should be gine if it took more time.

    • @moiserwibutso4899
      @moiserwibutso4899 3 місяці тому

      @@codeinajiffy Okay! Thx for the reply

  • @juancruzalric6605
    @juancruzalric6605 3 місяці тому +1

    I can't get my resnet50 model to predict the court lines as precisely as you did. They are drawn quite offset from the real court lines... any tips? Thanks
    PD: I tried resnet101, and also trained for 40 epochs, but nothing got the precision that you did

    • @codeinajiffy
      @codeinajiffy  3 місяці тому +2

      We try to add some augmentation to the image, also try efficientnet instead of resnet. It should bet better with those steps.

  • @blakeleahy9267
    @blakeleahy9267 4 місяці тому +2

    Please help with this! yolo command isn't being found when i entier: !yolo task=detect mode=train model=yolov516u.pt data={dataset.location}/data.yaml epochs=100 imgsz=640
    And yes, I have ultralytics installed. any ideas?

    • @codeinajiffy
      @codeinajiffy  3 місяці тому

      You will need to pip install ultralytics before you try and use this terminal command.

    • @AbhimanyuPande-mr8ky
      @AbhimanyuPande-mr8ky 3 місяці тому

      @@codeinajiffy I'm also stuck there. Ultralytics is installed. SyntaxError: 'Analytics/training/tennis-ball-detection-6/data.yaml' is not a valid YOLO argument.

  • @kortaz4280
    @kortaz4280 3 місяці тому +1

    what extension are you using for the prediction of code writing?

  • @lauratanguyen
    @lauratanguyen Місяць тому

    I loved this video! Thanks. Would you make a video for analyzing a golf swing? I have to do a software engineering boot camp capstone, and I would love to incorporate this AI/ML model.

    • @shubhasheeshkundu9933
      @shubhasheeshkundu9933 26 днів тому

      for train point key detection its take too much time cann anyone give me the model file

  • @punnoosepunnen1019
    @punnoosepunnen1019 4 місяці тому +1

    helloo brother love from india

  • @yamumsyadad69
    @yamumsyadad69 25 днів тому

    This is amazing. Will this code work on other random youtube tennis videos?

  • @littlesomethingforyou
    @littlesomethingforyou 4 місяці тому +2

    Does this project require some gpu power.....sadly ive only got a cpu laptop. Can i do this on that?

    • @codeinajiffy
      @codeinajiffy  4 місяці тому +4

      I also don't have a GPU on my machine. In the tutorial I trained on Google Collab and used the GPUs their. And I developed and ran the rest of the code locally.

    • @miguel-deep-soccer
      @miguel-deep-soccer 4 місяці тому

      ​@@codeinajiffy I have a GPU and it runs out of memory too... you need a very powerful GPU

  • @alanchau8037
    @alanchau8037 4 місяці тому

    GREAT