{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Ivo Bernardo",
  "title_listed": "Easy Object Detection with Yolo-NAS",
  "keywords": "",
  "domain": "图像处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/easy-object-detection-with-yolo-nas-51f9931be979/",
  "publish_date": "2024-08-04",
  "corpus_stage": "",
  "notes": "",
  "id": "8d350e675d67",
  "collected_at": "2026-10-02T05:49:51",
  "title": "Easy Object Detection with Yolo-NAS | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n# Easy Object Detection with Yolo-NAS\nLearn how to do object detection with Python using yolo-NAS\n[Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\nAugust 3, 20246 min read\n![Photo by googledeepmind @ Unplash.com](../images/000.jpg)\nPhoto by [googledeepmind](https://unsplash.com/pt-br/@googledeepmind) @ Unplash.com\nYOLO (_You only look once_) revolutionized the computer vision arena. The first version of YOLO [was released in 201](https://arxiv.org/abs/1506.02640)6 by Joseph Redmon et. al and it smashed benchmarks both in terms of speed and accuracy. When it comes to object detection, YOLO has been a favorite of Data Scientists and Machine Learning engineers and the go-to model when it comes to segmenting entities in images.\nSince it was launched, YOLO had many new iterations that improved several setbacks of previous versions, namely:\n  * Improved architecture of the underlying deep learning models.\n  * Implemented alternatives to improve performance, such as data augmentation techniques.\n  * Migrated the original YOLO code to use _pytorch_ training and deployment frameworks.\n  * Improved detection mechanisms of small objects.\n\n\nThe last version of YOLO is YOLO v9 (<https://arxiv.org/abs/2402.13616>). one important thing to be aware is that every computer vision and object detection model is evaluated on two parameters: **Accuracy** (defined by metrics related to computer vision segmentation) __ and **Speed** (defined by latency in the inference). One example of how CV algorithms are evaluated is shown below:\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer), [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\n![Comparison of different YOLO models vs. EfficientDet - Image by https://blog.roboflow.com/yolov5-is-here/](../images/001.png)\nComparison of different YOLO models vs. EfficientDet - Image by <https://blog.roboflow.com/yolov5-is-here/>\nIn this example, I'm going to show you how to run your own YOLO models on images and videos, so that you can rform object detection and segmentation. The entire code I'm executing is linked here, on this [Google Colab Notebook](https://colab.research.google.com/drive/1haLyNBz1i-bhh4GPizY-vsRABXs7srOQ?usp=sharing).\nPart of the code and blog post was inspired by this [great notebook](https://colab.research.google.com/drive/1q0RmeVRzLwRXW-h9dPFSOchwJkThUy6d?usp=sharing) by [Harpreet Sahota](https://datascienceharp.medium.com/).\nLet's start!\n* * *\n## Loading the Model\nWe'll start by training our own computer vision model...\nOf course not, that would be a waste of time :-)\nWe'll start by loading the pre-trained version of a large YOLO model. In this case, we'll use an implementation of YOLO with NAS ([Neural Architecture Search](https://en.wikipedia.org/wiki/Neural_architecture_search)). Neural architecture search is a common implementation of neural network optimization techniques to improve the automatic choice of parameters in the deep learning model.\nThe model we'll use was trained on the COCO dataset ([common objects in context](https://cocodataset.org/#home)). These weights already contain a very good baseline to detect objects on images.\nFirst, let's add a couple of libraries we will need to our environment, namely:\n  * `torchinfo` , a helper to visualize our neural network architecture;\n  * `super_gradients` , the library we will use to load our models;\n\n\ndiff\n\n```\n!pip install torchinfo\n!pip install super_gradients\n```\n\nNext, we'll load the functions and libraries we will need:\njavascript\n\n```\nfrom super_gradients.training import models\nfrom torchinfo import summary\nimport torch\n```\n\n_Note: If you are using google colab and have a prompt to restart the kernel after installing `super_gradients` , do it. It's a known issue from using `super_learners` in that environment_\nThen, we start by loading our COCO pretrained model into memory using `super_gradients` :\nini\n\n```\n# Using Yolo NAS Large\nyolo_nas_l = models.get(\"yolo_nas_l\", pretrained_weights=\"coco\")\n```\n\nCool! We have our pretrained model stored in `yolo_nas_l` . Picking up these pretrained versions of YOLO is super easy with `models` .\n`torchinfo` gives us a very cool view of our model architecture:\npython\n\n```\nsummary(model=yolo_nas_l,\n        input_size=(16, 3, 640, 640),\n        col_names=[\"input_size\", \"output_size\", \"num_params\", \"trainable\"],\n        col_width=20,\n        row_settings=[\"var_names\"]\n)\n```\n\nOut of curiosity, if you would like to check the YOLO architecture (from the original paper) check out the image below:\n![Image Source: https://www.researchgate.net/publication/329038564_Complexity_and_accuracy_analysis_of_common_artificial_neural_networks_on_pedestrian_detection](../images/002.png)\nImage Source: <https://www.researchgate.net/publication/329038564_Complexity_and_accuracy_analysis_of_common_artificial_neural_networks_on_pedestrian_detection>\nHere's a preview of the architecture of our YOLO NAS model:\n![Preview of Yolo-NAS model - image by author.](../images/003.png)\nPreview of Yolo-NAS model - image by author.\nWith the YOLO weights loaded, it's time to play around with image segmentation!\n* * *\n## Segmenting Images\nLet's start with a simple image featuring a desk as the centerpiece, surrounded by various objects. In this image, we can see:\n  * Two chairs\n  * A desk\n  * Two Lamps\n  * One computer\n  * Headphones\n  * One plant\n\n\n![Image 1 - Image by dawidliberadzki at Unsplash](../images/004.jpg)\nImage 1 - Image by [dawidliberadzki](https://unsplash.com/pt-br/@dawidliberadzki) at Unsplash\nIn our code, we only request bounding boxes where our model has a confidence level exceeding 55%. Only labels for these items will show up in the segmented image.\nmakefile\n\n```\nurl = \"https://images.unsplash.com/photo-1476365518243-f738bf58443d?q=80&amp;w=2787&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\nyolo_nas_l.predict(url, conf=0.55).show()\n```\n\n![Labeled Image with YOLO - Image by Author](../images/005.png)\nLabeled Image with YOLO - Image by Author\nNice! Our model was able to confidently detect the chairs, laptop, desk and plant (although it missed the lamps, headphones and that hi-tech jug). Let's see what happens if we lower our confidence threshold:\nmakefile\n\n```\nurl = \"https://images.unsplash.com/photo-1476365518243-f738bf58443d?q=80&amp;w=2787&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\nyolo_nas_l.predict(url, conf=0.40).show()\n```\n\n![Labeled Image with YOLO \\(40% Confidence\\) - Image by Author](../images/006.png)\nLabeled Image with YOLO (40% Confidence) - Image by Author\nAh, interesting! Lowering our threshold has led to our first instance of misclassification. In this case, the headphones were incorrectly identified as a computer mouse. Reducing the threshold will inevitably result in more errors in object detection and segmentation.\nLet's try an image with a more crowded scenario:\n![Image by madebyvadim @unsplash.com](../images/007.jpg)\nImage by [madebyvadim](https://unsplash.com/pt-br/@madebyvadim) @unsplash.com\nWhat objects will our YOLO model segment? As this image has more elements, I'll lower the confidence of the inference:\nmakefile\n\n```\nurl = \"https://images.unsplash.com/photo-1496664444929-8c75efb9546f?q=80&amp;w=2940&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\nyolo_nas_l.predict(url, conf=0.3).show()\n```\n\n![Labeled Image with YOLO \\(30% Confidence\\) - Image by Author](../images/008.png)\nLabeled Image with YOLO (30% Confidence) - Image by Author\nAs we can see, YOLO fails to segment some of the objects - particularly smaller / thiner objects. Nevertheless, performance is quite good, particularly for such a crowded image. To improve some the performance, [transfer learning with images related](https://kikaben.com/yolov5-transfer-learning-dogs-cats/) to your use case is extremely important.\n**Now, with**`**super_gradients**`**, we're abstracting most of code that actually prepares and predicts the boundaries on our image.** If you would like to have a deeper insight on the foundations of these models, check out the article [_Training a Computer Vision Algorithm from my Pytorch Introduction Series_](https://medium.com/towards-data-science/pytorch-introduction-training-a-computer-vision-algorithm-c17ed96e64d5?sk=74bd56317df5a7910d5f0efa5578b7dc) _._\nIn the next section, we'll learn how to use YOLO-NAS, but in the context of segmenting videos.\n* * *\nFor this section, I'll be using a traffic short video on Youtube:\n![Traffic Video - https://www.youtube.com/watch?v=CftLBPI1Ga4](../images/009.png)\nTraffic Video - <https://www.youtube.com/watch?v=CftLBPI1Ga4>\nWe'll start by downloading this video into our Google Colab environment. We can also display the video by using `IPython` 's handy `YoutubeVideo` function:\njava\n\n```\nfrom IPython.display import YouTubeVideo\n\nvideo = YouTubeVideo('CftLBPI1Ga4')\ndisplay(video)\n```\n\nTo download our video, I'll use [_youtube-dl_](https://github.com/ytdl-org/youtube-dl):\nbash\n\n```\nvideo_url = f'https://www.youtube.com/watch?v=CftLBPI1Ga4'\n\n!pip install -U \"git+https://github.com/ytdl-org/youtube-dl.git\"\n!python -m youtube_dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' \"$video_url\"\n```\n\nWe have almost everything ready. We just need to set the output path for the segmented video and we're ready to pass our video through the YOLO model!\nini\n\n```\ninput_video_path = f\"/content/Cars, Busy Streets, City Traffic - No Copyright Royalty Free Stock Videos-CftLBPI1Ga4.mp4\"\noutput = \"traffic.mp4\"\n```\n\nAll set! Let's run our segmentation model:\nlua\n\n```\ndevice = 'cuda' if torch.cuda.is_available() else \"cpu\"\nyolo_nas_l.to(device).predict(input_video_path).save(output)\n```\n\n_Note: This code may take a bit to run, depending on the configurations of your local system and the availability of GPUs on Google Colab_\n.. and that's it! You can check out the segmented video on [my youtube channel \"The Data Journey\"](https://youtu.be/-7j4eJorJSY). Here's a cool preview:\n![Segmented Traffic Video - Image by Author](../images/010.png)\nSegmented Traffic Video - Image by Author\n* * *\nYOLO models are extremely powerful! You can use them to segment images or videos quite fast with just a couple lines of code. Using this code that I've shown here, it's super easy to play around with your own media and experiment with this great computer vision model.\nAs you may noticed, particularly in complex images or videos, YOLO base models still have some flaws that need to be corrected. As I've mentioned this can be improved quite well with model fine tuning. Check out this [post](https://medium.com/@yongsun.yoon/fine-tuning-yolov8-using-custom-dataset-generated-by-open-world-object-detector-5724e267645d) for more info.\nAnd, if you are curious on how the building blocks of Deep Learning work, feel free to check my _pytorch_ introduction series, that should give you a good overview on the basics of deep learning:\n  * [Tensor Basics](https://towardsdatascience.com/pytorch-introduction-tensors-and-tensor-calculations-412ff818bd5b?sk=2cf4d44549664fc647baa3455e9d78e8);\n  * [Create a simple linear model using Pytorch.](https://towardsdatascience.com/pytorch-introduction-building-your-first-linear-model-d868a8681a41)\n  * [Learn how to work with non-linear activation functions and how to solve non-linear problems.](https://towardsdatascience.com/pytorch-introduction-enter-nonlinear-functions-4dd893845592)\n  * [Using custom data.](<http://We've> seen how to use custom data in the context of the library.)\n  * [Training a computer vision algorithm.](https://medium.com/towards-data-science/pytorch-introduction-training-a-computer-vision-algorithm-c17ed96e64d5?sk=74bd56317df5a7910d5f0efa5578b7dc)\n\n\nThank you for reading this post! And again, thank you to Harpreet for the awesome [notebook](https://colab.research.google.com/drive/1q0RmeVRzLwRXW-h9dPFSOchwJkThUy6d?usp=sharing).\nIf you want to read / see more content related to AI and DS, subscribe my youtube Channel \"_The Data Journey_ \":\n![https://www.youtube.com/@TheDataJourney42](../images/011.png)\n<https://www.youtube.com/@TheDataJourney42>\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-6f351be10c9e83aa9f9d.jpeg)\nWritten By\n## [Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[See all from Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Computer Vision](https://towardsdatascience.com/tag/computer-vision/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Deep Learning](https://towardsdatascience.com/tag/deep-learning/)[Yolo](https://towardsdatascience.com/tag/yolo/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Feasy-object-detection-with-yolo-nas-51f9931be979%2F&title=Easy%20Object%20Detection%20with%20Yolo-NAS)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Feasy-object-detection-with-yolo-nas-51f9931be979%2F&title=Easy%20Object%20Detection%20with%20Yolo-NAS)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Feasy-object-detection-with-yolo-nas-51f9931be979%2F&text=Easy%20Object%20Detection%20with%20Yolo-NAS)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/012.png)](https://towardsdatascience.com/hadoop-vs-spark-overview-and-comparison-f62c99d0ee15/)\n## [Hadoop vs Spark: Overview and Comparison](https://towardsdatascience.com/hadoop-vs-spark-overview-and-comparison-f62c99d0ee15/)\n[Programming](https://towardsdatascience.com/category/programming/)\nA summary and comparison of Spark and Hadoop\n[Rian Dolphin](https://towardsdatascience.com/author/riandolphin/)\nMarch 1, 20227 min read\n  * [![](../images/013.jpeg)](https://towardsdatascience.com/lightgbm-the-fastest-option-of-gradient-boosting-1fb0c40948a3/)\n## [LightGBM: The Fastest Option of Gradient Boosting](https://towardsdatascience.com/lightgbm-the-fastest-option-of-gradient-boosting-1fb0c40948a3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nLearn how to implement a fast and effective Gradient Boosting model using Python\n[Gustavo Santos](https://towardsdatascience.com/author/gustavorsantos/)\nJanuary 12, 20257 min read\n  * [![](../images/014.png)](https://towardsdatascience.com/how-to-work-with-object-detection-datasets-in-coco-format-9bf4fb5848a4/)\n## [How to work with object detection datasets in COCO format](https://towardsdatascience.com/how-to-work-with-object-detection-datasets-in-coco-format-9bf4fb5848a4/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA comprehensive guide to defining, loading, exploring, and evaluating object detection datasets in COCO format using FiftyOne\n[Eric Hofesmann](https://towardsdatascience.com/author/eric.hofesmann/)\nFebruary 19, 202110 min read\n  * [![](../images/015.jpg)](https://towardsdatascience.com/bakeryscan-and-cyto-aiscan-52475b3cb779/)\n## [BakeryScan and Cyto-AiSCAN](https://towardsdatascience.com/bakeryscan-and-cyto-aiscan-52475b3cb779/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nand the unexpected impact of an AI that identifies bread.\n[Matthew Turner](https://towardsdatascience.com/author/matthewturner-irl/)\nSeptember 7, 20217 min read\n  * [![](../images/016.jpeg)](https://towardsdatascience.com/dont-do-laundry-today-it-will-be-cheaper-tomorrow-84a6baa4e626/)\n## [Don't Do Laundry Today, It Will Be Cheaper Tomorrow](https://towardsdatascience.com/dont-do-laundry-today-it-will-be-cheaper-tomorrow-84a6baa4e626/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAnalysing electricity price changes in London through causal inference\n[Alvaro Corrales Cano](https://towardsdatascience.com/author/acorralescano/)\nOctober 21, 202417 min read\n  * [![](../images/017.jpeg)](https://towardsdatascience.com/3-subtle-mistakes-that-can-undermine-your-sql-query-performance-47e897688977/)\n## [3 Subtle Mistakes That Can Undermine Your SQL Query Performance](https://towardsdatascience.com/3-subtle-mistakes-that-can-undermine-your-sql-query-performance-47e897688977/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nAnd how to mitigate them\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nMay 11, 20234 min read\n  * [![](../images/018.jpeg)](https://towardsdatascience.com/deploy-any-python-project-to-kubernetes-2c6ad4d41f14/)\n## [Deploy Any Python Project to Kubernetes](https://towardsdatascience.com/deploy-any-python-project-to-kubernetes-2c6ad4d41f14/)\n[Programming](https://towardsdatascience.com/category/programming/)\nIt's time to dive into Kubernetes and bring your Python project to Cloud with this fully-fledged project template!\n[Martin Heinz](https://towardsdatascience.com/author/martin.heinz/)\nApril 15, 20206 min read\n  * [![](../images/019.jpg)](https://towardsdatascience.com/get-uncertainty-estimates-in-neural-networks-for-free-48f2edb82c8f/)\n## [Get Uncertainty Estimates in Regression Neural Networks for Free](https://towardsdatascience.com/get-uncertainty-estimates-in-neural-networks-for-free-48f2edb82c8f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nGiven the right loss function, a standard neural network can output uncertainty as well\n[Robert Kübler](https://towardsdatascience.com/author/dr-robert-kuebler/)\nApril 22, 202210 min read\n  * [![](../images/020.jpg)](https://towardsdatascience.com/how-to-perform-bulk-insert-update-upsert-actions-with-sqlalchemy-orm-79deef24f457/)\n## [How to Perform Bulk Insert/Update/Upsert Actions with SQLAlchemy ORM](https://towardsdatascience.com/how-to-perform-bulk-insert-update-upsert-actions-with-sqlalchemy-orm-79deef24f457/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nLearn efficient ways to perform bulk actions with the latest version of SQLAlchemy\n[Lynn G. Kwong](https://towardsdatascience.com/author/lynn-kwong/)\nMay 14, 202411 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "Easy Object Detection with Yolo-NAS | Towards Data Science",
    "description": "Learn how to do object detection with Python using yolo-NAS",
    "keywords": null,
    "author": "Ivo Bernardo",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Easy Object Detection with Yolo-NAS",
    "og:description": "Learn how to do object detection with Python using yolo-NAS",
    "og:url": "https://towardsdatascience.com/easy-object-detection-with-yolo-nas-51f9931be979/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/0WPn4Jj9-jkqRQtd2-scaled.jpg",
    "og:image:width": "2560",
    "og:image:height": "1440",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Ivo Bernardo",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "6 min read",
    "article:published_time": "2024-08-03T21:00:29.000Z",
    "article:modified_time": "2024-08-03T21:00:29.000Z",
    "article:author": "https://towardsdatascience.com/author/ivopbernardo/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_000.txt",
      "chars": 52
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_001.txt",
      "chars": 87
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_002.txt",
      "chars": 88
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_003.txt",
      "chars": 199
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_004.txt",
      "chars": 237
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_005.txt",
      "chars": 237
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_006.txt",
      "chars": 236
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_007.txt",
      "chars": 93
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_008.txt",
      "chars": 207
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_009.txt",
      "chars": 144
    },
    {
      "language": "txt",
      "file": "attachments/8d350e675d67/code/block_010.txt",
      "chars": 117
    }
  ],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:52Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:52Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:52Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:59:52Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=CftLBPI1Ga4](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1WosgRL7B4UINUniO4AAgyA.png",
      "kind": "invalid_video_url",
      "status": "download_failed",
      "title": "",
      "error": "[youtube] Extracting URL: https://www.youtube.com/watch?v=CftLBPI1Ga4](https://assets.insightmediagroup.io/media/wp-content...7B4UINUniO4AAgyA.png\n[youtube] CftLBPI1Ga4: Downloading webpage\n[youtube] CftLBPI1Ga4: Downloading web embedded client config\n[youtube] CftLBPI1Ga4: Downloading player 67288f35-main\n[youtube] CftLBPI1Ga4: Downloading web embedded player API JSON\n[youtube] CftLBPI1Ga4: Downloading tv downgraded player API JSON\n[youtube] [jsc:deno] Solving JS challenges using deno\n[info] CftLBPI1Ga4: Downloading 1 format(s): 399+251\n[info] Video metadata is already present\n[download] /www/wwwroot/dataset/xinxing-zimeiti-corpus/attachments/8d350e675d67/videos/repair-CftLBPI1Ga4.mp4 has already been downloaded\n",
      "retried_at": "2026-10-20T22:24:32Z"
    },
    {
      "url": "https://www.youtube.com/watch?v=CftLBPI1Ga4>",
      "kind": "invalid_video_url",
      "status": "download_failed",
      "title": "",
      "error": "[youtube] Extracting URL: https://www.youtube.com/watch?v=CftLBPI1Ga4>\n[youtube] CftLBPI1Ga4: Downloading webpage\n[youtube] CftLBPI1Ga4: Downloading web embedded client config\n[youtube] CftLBPI1Ga4: Downloading player 67288f35-main\n[youtube] CftLBPI1Ga4: Downloading web embedded player API JSON\n[youtube] CftLBPI1Ga4: Downloading tv downgraded player API JSON\n[youtube] [jsc:deno] Solving JS challenges using deno\n[info] CftLBPI1Ga4: Downloading 1 format(s): 399+251\n[info] Video metadata is already present\n[download] /www/wwwroot/dataset/xinxing-zimeiti-corpus/attachments/8d350e675d67/videos/repair-CftLBPI1Ga4.mp4 has already been downloaded\n",
      "retried_at": "2026-10-20T22:24:35Z"
    },
    {
      "url": "https://www.youtube.com/watch?v=CftLBPI1Ga4",
      "status": "ok",
      "local_path": "attachments/8d350e675d67/videos/CftLBPI1Ga4.mp4",
      "bytes": 2239221,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "10.441000"
    },
    {
      "url": "https://www.youtube.com/watch?v=CftLBPI1Ga4'",
      "kind": "invalid_video_url",
      "status": "download_failed",
      "title": "",
      "error": "[youtube] Extracting URL: https://www.youtube.com/watch?v=CftLBPI1Ga4'\n[youtube] CftLBPI1Ga4: Downloading webpage\n[youtube] CftLBPI1Ga4: Downloading web embedded client config\n[youtube] CftLBPI1Ga4: Downloading player 67288f35-main\n[youtube] CftLBPI1Ga4: Downloading web embedded player API JSON\n[youtube] CftLBPI1Ga4: Downloading tv downgraded player API JSON\n[youtube] [jsc:deno] Solving JS challenges using deno\n[info] CftLBPI1Ga4: Downloading 1 format(s): 399+251\n[info] Video metadata is already present\n[download] /www/wwwroot/dataset/xinxing-zimeiti-corpus/attachments/8d350e675d67/videos/repair-CftLBPI1Ga4.mp4 has already been downloaded\n",
      "retried_at": "2026-10-20T22:24:36Z"
    },
    {
      "url": "https://www.youtube.com/watch?v=-7j4eJorJSY",
      "status": "ok",
      "local_path": "attachments/8d350e675d67/videos/repair--7j4eJorJSY.mp4",
      "bytes": 5809600,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "10.461000"
    },
    {
      "url": "https://www.youtube.com/@TheDataJourney42",
      "kind": "channel_reference",
      "status": "reference_only"
    },
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    },
    {
      "url": "https://www.youtube.com/watch?v=CftLBPI1Ga4](../images/009.png",
      "kind": "invalid_video_url",
      "status": "download_failed",
      "title": "",
      "error": "[youtube] Extracting URL: https://www.youtube.com/watch?v=CftLBPI1Ga4](../images/009.png\n[youtube] CftLBPI1Ga4: Downloading webpage\n[youtube] CftLBPI1Ga4: Downloading web embedded client config\n[youtube] CftLBPI1Ga4: Downloading player 67288f35-main\n[youtube] CftLBPI1Ga4: Downloading web embedded player API JSON\n[youtube] CftLBPI1Ga4: Downloading tv downgraded player API JSON\n[youtube] [jsc:deno] Solving JS challenges using deno\n[info] CftLBPI1Ga4: Downloading 1 format(s): 399+251\n[info] Video metadata is already present\n[download] /www/wwwroot/dataset/xinxing-zimeiti-corpus/attachments/8d350e675d67/videos/repair-CftLBPI1Ga4.mp4 has already been downloaded\n",
      "retried_at": "2026-10-20T22:24:38Z"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/ivopbernardo/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/pytorch-introduction-tensors-and-tensor-calculations-412ff818bd5b?sk=2cf4d44549664fc647baa3455e9d78e8"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/pytorch-introduction-building-your-first-linear-model-d868a8681a41"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/pytorch-introduction-enter-nonlinear-functions-4dd893845592"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/computer-vision/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/deep-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/yolo/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/hadoop-vs-spark-overview-and-comparison-f62c99d0ee15/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/programming/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/riandolphin/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/lightgbm-the-fastest-option-of-gradient-boosting-1fb0c40948a3/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/pt-br/@googledeepmind"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/abs/1506.02640"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/abs/2402.13616"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-engineer"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://blog.roboflow.com/yolov5-is-here/"
    },
    {
      "type": "external",
      "href": "https://colab.research.google.com/drive/1haLyNBz1i-bhh4GPizY-vsRABXs7srOQ?usp=sharing"
    },
    {
      "type": "external",
      "href": "https://colab.research.google.com/drive/1q0RmeVRzLwRXW-h9dPFSOchwJkThUy6d?usp=sharing"
    },
    {
      "type": "external",
      "href": "https://datascienceharp.medium.com/"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Neural_architecture_search"
    },
    {
      "type": "external",
      "href": "https://cocodataset.org/"
    },
    {
      "type": "external",
      "href": "https://www.researchgate.net/publication/329038564_Complexity_and_accuracy_analysis_of_common_artificial_neural_networks_on_pedestrian_detection"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/pt-br/@dawidliberadzki"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/pt-br/@madebyvadim"
    },
    {
      "type": "external",
      "href": "https://kikaben.com/yolov5-transfer-learning-dogs-cats/"
    },
    {
      "type": "external",
      "href": "https://medium.com/towards-data-science/pytorch-introduction-training-a-computer-vision-algorithm-c17ed96e64d5?sk=74bd56317df5a7910d5f0efa5578b7dc"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:30:12Z",
  "source_url": "https://towardsdatascience.com/easy-object-detection-with-yolo-nas-51f9931be979/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [
    {
      "local_path": "attachments/8d350e675d67/videos/CftLBPI1Ga4.mp4",
      "bytes": 2239221,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "10.441000",
      "status": "ok"
    },
    {
      "local_path": "attachments/8d350e675d67/videos/repair--7j4eJorJSY.mp4",
      "bytes": 5809600,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "10.461000",
      "status": "ok"
    },
    {
      "local_path": "attachments/8d350e675d67/videos/repair-CftLBPI1Ga4.f251.webm",
      "bytes": 5018,
      "valid": false,
      "height": 0,
      "width": null,
      "duration": "10.441000",
      "status": "invalid_or_wrong_resolution"
    },
    {
      "local_path": "attachments/8d350e675d67/videos/repair-CftLBPI1Ga4.mp4",
      "bytes": 2239221,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "10.441000",
      "status": "ok"
    }
  ],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n# Easy Object Detection with Yolo-NAS\nLearn how to do object detection with Python using yolo-NAS\n[Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\nAugust 3, 20246 min read\n![Photo by googledeepmind @ Unplash.com](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/0WPn4Jj9-jkqRQtd2-scaled.jpg)\nPhoto by [googledeepmind](https://unsplash.com/pt-br/@googledeepmind) @ Unplash.com\nYOLO (_You only look once_) revolutionized the computer vision arena. The first version of YOLO [was released in 201](https://arxiv.org/abs/1506.02640)6 by Joseph Redmon et. al and it smashed benchmarks both in terms of speed and accuracy. When it comes to object detection, YOLO has been a favorite of Data Scientists and Machine Learning engineers and the go-to model when it comes to segmenting entities in images.\nSince it was launched, YOLO had many new iterations that improved several setbacks of previous versions, namely:\n  * Improved architecture of the underlying deep learning models.\n  * Implemented alternatives to improve performance, such as data augmentation techniques.\n  * Migrated the original YOLO code to use _pytorch_ training and deployment frameworks.\n  * Improved detection mechanisms of small objects.\n\n\nThe last version of YOLO is YOLO v9 (<https://arxiv.org/abs/2402.13616>). one important thing to be aware is that every computer vision and object detection model is evaluated on two parameters: **Accuracy** (defined by metrics related to computer vision segmentation) __ and **Speed** (defined by latency in the inference). One example of how CV algorithms are evaluated is shown below:\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer), [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\n![Comparison of different YOLO models vs. EfficientDet - Image by https://blog.roboflow.com/yolov5-is-here/](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/0Cm7-_Xx68EE-Lre-.png)\nComparison of different YOLO models vs. EfficientDet - Image by <https://blog.roboflow.com/yolov5-is-here/>\nIn this example, I'm going to show you how to run your own YOLO models on images and videos, so that you can rform object detection and segmentation. The entire code I'm executing is linked here, on this [Google Colab Notebook](https://colab.research.google.com/drive/1haLyNBz1i-bhh4GPizY-vsRABXs7srOQ?usp=sharing).\nPart of the code and blog post was inspired by this [great notebook](https://colab.research.google.com/drive/1q0RmeVRzLwRXW-h9dPFSOchwJkThUy6d?usp=sharing) by [Harpreet Sahota](https://datascienceharp.medium.com/).\nLet's start!\n* * *\n## Loading the Model\nWe'll start by training our own computer vision model...\nOf course not, that would be a waste of time :-)\nWe'll start by loading the pre-trained version of a large YOLO model. In this case, we'll use an implementation of YOLO with NAS ([Neural Architecture Search](https://en.wikipedia.org/wiki/Neural_architecture_search)). Neural architecture search is a common implementation of neural network optimization techniques to improve the automatic choice of parameters in the deep learning model.\nThe model we'll use was trained on the COCO dataset ([common objects in context](https://cocodataset.org/#home)). These weights already contain a very good baseline to detect objects on images.\nFirst, let's add a couple of libraries we will need to our environment, namely:\n  * `torchinfo` , a helper to visualize our neural network architecture;\n  * `super_gradients` , the library we will use to load our models;\n\n\ndiff\n\n```\n!pip install torchinfo\n!pip install super_gradients\n```\n\nNext, we'll load the functions and libraries we will need:\njavascript\n\n```\nfrom super_gradients.training import models\nfrom torchinfo import summary\nimport torch\n```\n\n_Note: If you are using google colab and have a prompt to restart the kernel after installing `super_gradients` , do it. It's a known issue from using `super_learners` in that environment_\nThen, we start by loading our COCO pretrained model into memory using `super_gradients` :\nini\n\n```\n# Using Yolo NAS Large\nyolo_nas_l = models.get(\"yolo_nas_l\", pretrained_weights=\"coco\")\n```\n\nCool! We have our pretrained model stored in `yolo_nas_l` . Picking up these pretrained versions of YOLO is super easy with `models` .\n`torchinfo` gives us a very cool view of our model architecture:\npython\n\n```\nsummary(model=yolo_nas_l,\n        input_size=(16, 3, 640, 640),\n        col_names=[\"input_size\", \"output_size\", \"num_params\", \"trainable\"],\n        col_width=20,\n        row_settings=[\"var_names\"]\n)\n```\n\nOut of curiosity, if you would like to check the YOLO architecture (from the original paper) check out the image below:\n![Image Source: https://www.researchgate.net/publication/329038564_Complexity_and_accuracy_analysis_of_common_artificial_neural_networks_on_pedestrian_detection](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1-dSf6DJaPEaZOySkQ2Jclg.png)\nImage Source: <https://www.researchgate.net/publication/329038564_Complexity_and_accuracy_analysis_of_common_artificial_neural_networks_on_pedestrian_detection>\nHere's a preview of the architecture of our YOLO NAS model:\n![Preview of Yolo-NAS model - image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1VzypuzfWcU2R7WSoVlzo7Q.png)\nPreview of Yolo-NAS model - image by author.\nWith the YOLO weights loaded, it's time to play around with image segmentation!\n* * *\n## Segmenting Images\nLet's start with a simple image featuring a desk as the centerpiece, surrounded by various objects. In this image, we can see:\n  * Two chairs\n  * A desk\n  * Two Lamps\n  * One computer\n  * Headphones\n  * One plant\n\n\n![Image 1 - Image by dawidliberadzki at Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/0gQXXoV8VC5So92_2-scaled.jpg)\nImage 1 - Image by [dawidliberadzki](https://unsplash.com/pt-br/@dawidliberadzki) at Unsplash\nIn our code, we only request bounding boxes where our model has a confidence level exceeding 55%. Only labels for these items will show up in the segmented image.\nmakefile\n\n```\nurl = \"https://images.unsplash.com/photo-1476365518243-f738bf58443d?q=80&amp;w=2787&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\nyolo_nas_l.predict(url, conf=0.55).show()\n```\n\n![Labeled Image with YOLO - Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1wZkiUfF6AmE72ETcXO8gJg.png)\nLabeled Image with YOLO - Image by Author\nNice! Our model was able to confidently detect the chairs, laptop, desk and plant (although it missed the lamps, headphones and that hi-tech jug). Let's see what happens if we lower our confidence threshold:\nmakefile\n\n```\nurl = \"https://images.unsplash.com/photo-1476365518243-f738bf58443d?q=80&amp;w=2787&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\nyolo_nas_l.predict(url, conf=0.40).show()\n```\n\n![Labeled Image with YOLO \\(40% Confidence\\) - Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1v849zqgK1mJdClWZZfnmSg.png)\nLabeled Image with YOLO (40% Confidence) - Image by Author\nAh, interesting! Lowering our threshold has led to our first instance of misclassification. In this case, the headphones were incorrectly identified as a computer mouse. Reducing the threshold will inevitably result in more errors in object detection and segmentation.\nLet's try an image with a more crowded scenario:\n![Image by madebyvadim @unsplash.com](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/0efh3nZHY2VWakq6w-scaled.jpg)\nImage by [madebyvadim](https://unsplash.com/pt-br/@madebyvadim) @unsplash.com\nWhat objects will our YOLO model segment? As this image has more elements, I'll lower the confidence of the inference:\nmakefile\n\n```\nurl = \"https://images.unsplash.com/photo-1496664444929-8c75efb9546f?q=80&amp;w=2940&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\nyolo_nas_l.predict(url, conf=0.3).show()\n```\n\n![Labeled Image with YOLO \\(30% Confidence\\) - Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1wP2M_p7pMbZsvo1eEmR5QA.png)\nLabeled Image with YOLO (30% Confidence) - Image by Author\nAs we can see, YOLO fails to segment some of the objects - particularly smaller / thiner objects. Nevertheless, performance is quite good, particularly for such a crowded image. To improve some the performance, [transfer learning with images related](https://kikaben.com/yolov5-transfer-learning-dogs-cats/) to your use case is extremely important.\n**Now, with**`**super_gradients**`**, we're abstracting most of code that actually prepares and predicts the boundaries on our image.** If you would like to have a deeper insight on the foundations of these models, check out the article [_Training a Computer Vision Algorithm from my Pytorch Introduction Series_](https://medium.com/towards-data-science/pytorch-introduction-training-a-computer-vision-algorithm-c17ed96e64d5?sk=74bd56317df5a7910d5f0efa5578b7dc) _._\nIn the next section, we'll learn how to use YOLO-NAS, but in the context of segmenting videos.\n* * *\nFor this section, I'll be using a traffic short video on Youtube:\n![Traffic Video - https://www.youtube.com/watch?v=CftLBPI1Ga4](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1WosgRL7B4UINUniO4AAgyA.png)\nTraffic Video - <https://www.youtube.com/watch?v=CftLBPI1Ga4>\nWe'll start by downloading this video into our Google Colab environment. We can also display the video by using `IPython` 's handy `YoutubeVideo` function:\njava\n\n```\nfrom IPython.display import YouTubeVideo\n\nvideo = YouTubeVideo('CftLBPI1Ga4')\ndisplay(video)\n```\n\nTo download our video, I'll use [_youtube-dl_](https://github.com/ytdl-org/youtube-dl):\nbash\n\n```\nvideo_url = f'https://www.youtube.com/watch?v=CftLBPI1Ga4'\n\n!pip install -U \"git+https://github.com/ytdl-org/youtube-dl.git\"\n!python -m youtube_dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' \"$video_url\"\n```\n\nWe have almost everything ready. We just need to set the output path for the segmented video and we're ready to pass our video through the YOLO model!\nini\n\n```\ninput_video_path = f\"/content/Cars, Busy Streets, City Traffic - No Copyright Royalty Free Stock Videos-CftLBPI1Ga4.mp4\"\noutput = \"traffic.mp4\"\n```\n\nAll set! Let's run our segmentation model:\nlua\n\n```\ndevice = 'cuda' if torch.cuda.is_available() else \"cpu\"\nyolo_nas_l.to(device).predict(input_video_path).save(output)\n```\n\n_Note: This code may take a bit to run, depending on the configurations of your local system and the availability of GPUs on Google Colab_\n.. and that's it! You can check out the segmented video on [my youtube channel \"The Data Journey\"](https://youtu.be/-7j4eJorJSY). Here's a cool preview:\n![Segmented Traffic Video - Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1k2Pv7JAxxP1dvlrtHr80DA.png)\nSegmented Traffic Video - Image by Author\n* * *\nYOLO models are extremely powerful! You can use them to segment images or videos quite fast with just a couple lines of code. Using this code that I've shown here, it's super easy to play around with your own media and experiment with this great computer vision model.\nAs you may noticed, particularly in complex images or videos, YOLO base models still have some flaws that need to be corrected. As I've mentioned this can be improved quite well with model fine tuning. Check out this [post](https://medium.com/@yongsun.yoon/fine-tuning-yolov8-using-custom-dataset-generated-by-open-world-object-detector-5724e267645d) for more info.\nAnd, if you are curious on how the building blocks of Deep Learning work, feel free to check my _pytorch_ introduction series, that should give you a good overview on the basics of deep learning:\n  * [Tensor Basics](https://towardsdatascience.com/pytorch-introduction-tensors-and-tensor-calculations-412ff818bd5b?sk=2cf4d44549664fc647baa3455e9d78e8);\n  * [Create a simple linear model using Pytorch.](https://towardsdatascience.com/pytorch-introduction-building-your-first-linear-model-d868a8681a41)\n  * [Learn how to work with non-linear activation functions and how to solve non-linear problems.](https://towardsdatascience.com/pytorch-introduction-enter-nonlinear-functions-4dd893845592)\n  * [Using custom data.](<http://We've> seen how to use custom data in the context of the library.)\n  * [Training a computer vision algorithm.](https://medium.com/towards-data-science/pytorch-introduction-training-a-computer-vision-algorithm-c17ed96e64d5?sk=74bd56317df5a7910d5f0efa5578b7dc)\n\n\nThank you for reading this post! And again, thank you to Harpreet for the awesome [notebook](https://colab.research.google.com/drive/1q0RmeVRzLwRXW-h9dPFSOchwJkThUy6d?usp=sharing).\nIf you want to read / see more content related to AI and DS, subscribe my youtube Channel \"_The Data Journey_ \":\n![https://www.youtube.com/@TheDataJourney42](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1d3kWOamhkRhWNjF609t-4A.png)\n<https://www.youtube.com/@TheDataJourney42>\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657081760_wqdt7l.jpeg)\nWritten By\n## [Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[See all from Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Computer Vision](https://towardsdatascience.com/tag/computer-vision/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Deep Learning](https://towardsdatascience.com/tag/deep-learning/)[Yolo](https://towardsdatascience.com/tag/yolo/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Feasy-object-detection-with-yolo-nas-51f9931be979%2F&title=Easy%20Object%20Detection%20with%20Yolo-NAS)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Feasy-object-detection-with-yolo-nas-51f9931be979%2F&title=Easy%20Object%20Detection%20with%20Yolo-NAS)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Feasy-object-detection-with-yolo-nas-51f9931be979%2F&text=Easy%20Object%20Detection%20with%20Yolo-NAS)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/03/1xaFsHMPIyRTYVo6aeTIsyw.png)](https://towardsdatascience.com/hadoop-vs-spark-overview-and-comparison-f62c99d0ee15/)\n## [Hadoop vs Spark: Overview and Comparison](https://towardsdatascience.com/hadoop-vs-spark-overview-and-comparison-f62c99d0ee15/)\n[Programming](https://towardsdatascience.com/category/programming/)\nA summary and comparison of Spark and Hadoop\n[Rian Dolphin](https://towardsdatascience.com/author/riandolphin/)\nMarch 1, 20227 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1aSTGKT1LWq_paC-xhgdPDg.jpeg)](https://towardsdatascience.com/lightgbm-the-fastest-option-of-gradient-boosting-1fb0c40948a3/)\n## [LightGBM: The Fastest Option of Gradient Boosting](https://towardsdatascience.com/lightgbm-the-fastest-option-of-gradient-boosting-1fb0c40948a3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nLearn how to implement a fast and effective Gradient Boosting model using Python\n[Gustavo Santos](https://towardsdatascience.com/author/gustavorsantos/)\nJanuary 12, 20257 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/1NR0biFNv5O3ShW1U1NtxvQ.png)](https://towardsdatascience.com/how-to-work-with-object-detection-datasets-in-coco-format-9bf4fb5848a4/)\n## [How to work with object detection datasets in COCO format](https://towardsdatascience.com/how-to-work-with-object-detection-datasets-in-coco-format-9bf4fb5848a4/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA comprehensive guide to defining, loading, exploring, and evaluating object detection datasets in COCO format using FiftyOne\n[Eric Hofesmann](https://towardsdatascience.com/author/eric.hofesmann/)\nFebruary 19, 202110 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/09/0zZhPSpjcYUZPKZ-X-scaled.jpg)](https://towardsdatascience.com/bakeryscan-and-cyto-aiscan-52475b3cb779/)\n## [BakeryScan and Cyto-AiSCAN](https://towardsdatascience.com/bakeryscan-and-cyto-aiscan-52475b3cb779/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nand the unexpected impact of an AI that identifies bread.\n[Matthew Turner](https://towardsdatascience.com/author/matthewturner-irl/)\nSeptember 7, 20217 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/10/1_y27TLD_zk3Ds-dbdyX3sQ-scaled.jpeg)](https://towardsdatascience.com/dont-do-laundry-today-it-will-be-cheaper-tomorrow-84a6baa4e626/)\n## [Don't Do Laundry Today, It Will Be Cheaper Tomorrow](https://towardsdatascience.com/dont-do-laundry-today-it-will-be-cheaper-tomorrow-84a6baa4e626/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAnalysing electricity price changes in London through causal inference\n[Alvaro Corrales Cano](https://towardsdatascience.com/author/acorralescano/)\nOctober 21, 202417 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/05/191d5PgJNwfzdfAUZWJi2MA-scaled.jpeg)](https://towardsdatascience.com/3-subtle-mistakes-that-can-undermine-your-sql-query-performance-47e897688977/)\n## [3 Subtle Mistakes That Can Undermine Your SQL Query Performance](https://towardsdatascience.com/3-subtle-mistakes-that-can-undermine-your-sql-query-performance-47e897688977/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nAnd how to mitigate them\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nMay 11, 20234 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/04/1CV-VVMuRILKD0sf2Ctywxg-scaled.jpeg)](https://towardsdatascience.com/deploy-any-python-project-to-kubernetes-2c6ad4d41f14/)\n## [Deploy Any Python Project to Kubernetes](https://towardsdatascience.com/deploy-any-python-project-to-kubernetes-2c6ad4d41f14/)\n[Programming](https://towardsdatascience.com/category/programming/)\nIt's time to dive into Kubernetes and bring your Python project to Cloud with this fully-fledged project template!\n[Martin Heinz](https://towardsdatascience.com/author/martin.heinz/)\nApril 15, 20206 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/0v-iLerKzzVVArXz7-scaled.jpg)](https://towardsdatascience.com/get-uncertainty-estimates-in-neural-networks-for-free-48f2edb82c8f/)\n## [Get Uncertainty Estimates in Regression Neural Networks for Free](https://towardsdatascience.com/get-uncertainty-estimates-in-neural-networks-for-free-48f2edb82c8f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nGiven the right loss function, a standard neural network can output uncertainty as well\n[Robert Kübler](https://towardsdatascience.com/author/dr-robert-kuebler/)\nApril 22, 202210 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/0TmW27yujmenZPviU.jpg)](https://towardsdatascience.com/how-to-perform-bulk-insert-update-upsert-actions-with-sqlalchemy-orm-79deef24f457/)\n## [How to Perform Bulk Insert/Update/Upsert Actions with SQLAlchemy ORM](https://towardsdatascience.com/how-to-perform-bulk-insert-update-upsert-actions-with-sqlalchemy-orm-79deef24f457/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nLearn efficient ways to perform bulk actions with the latest version of SQLAlchemy\n[Lynn G. Kwong](https://towardsdatascience.com/author/lynn-kwong/)\nMay 14, 202411 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "body_base_path": "attachments/8d350e675d67/pages/",
  "body_markdown_path": "attachments/8d350e675d67/pages/archived-body.md",
  "local_html": "attachments/8d350e675d67/pages/archived-body.html",
  "body_source": "prior_capture"
}