<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Untitled Publication]]></title><description><![CDATA[Untitled Publication]]></description><link>https://axylone.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 01 Sep 2026 22:27:14 GMT</lastBuildDate><atom:link href="https://axylone.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Guide to Object Detection with YOLO-NAS & FiftyOne Using E2E Cloud GPU Server]]></title><description><![CDATA[By Akshayraj

Object detection is a crucial aspect of computer vision, enabling machines to identify and locate multiple objects within an image or a video. It’s the foundational technology behind various applications like autonomous vehicles, survei...]]></description><link>https://axylone.hashnode.dev/guide-to-object-detection-with-yolo-nas-fiftyone-using-e2e-cloud-gpu-server</link><guid isPermaLink="true">https://axylone.hashnode.dev/guide-to-object-detection-with-yolo-nas-fiftyone-using-e2e-cloud-gpu-server</guid><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[YOLO]]></category><category><![CDATA[object detection ]]></category><category><![CDATA[Computer Vision]]></category><dc:creator><![CDATA[Akshayraj M]]></dc:creator><pubDate>Mon, 08 Jan 2024 12:29:16 GMT</pubDate><content:encoded><![CDATA[<blockquote>
<p><strong><em>By Akshayraj</em></strong></p>
</blockquote>
<p>Object detection is a crucial aspect of computer vision, enabling machines to identify and locate multiple objects within an image or a video. It’s the foundational technology behind various applications like autonomous vehicles, surveillance systems, augmented reality, and even assistive technologies for the visually impaired. Among the various object detection algorithms, YOLO (You Only Look Once) stands out for its speed and accuracy.</p>
<h1 id="heading-yolo-nas-overview"><strong>YOLO-NAS Overview</strong></h1>
<p>Now, <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">YOLO</a> (You Only Look Once) is a pioneering object detection algorithm known for its speed and accuracy. Instead of sliding windows or region-based approaches, YOLO divides the image into a grid and predicts bounding boxes and class probabilities directly from grid cells. This approach allows YOLO to make predictions in real-time, making it well-suited for applications requiring rapid object detection. To get an in-depth understanding of YOLO, refer to the paper: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://arxiv.org/pdf/1506.02640.pdf</a>.</p>
<p>Since its inception, the original YOLO paper has sparked a series of architectural advancements, each iteration refining and enhancing the model’s capabilities. One of the latest breakthroughs in this lineage is the YOLO-NAS (Neural Architecture Search) developed by <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">Deci.ai</a>, marking a significant leap in performance and precision in the realm of object detection.</p>
<p>Setting new benchmarks in the field, YOLO-NAS surpasses its predecessors by achieving superior mean average precision (mAP) while maintaining the same operational speed. This cutting-edge model stands as a testament to state-of-the-art (SOTA) technology, boasting unparalleled accuracy-speed equilibrium that outshines even renowned models like YOLOv5, YOLOv6, YOLOv7, and YOLOv8.</p>
<p>In raw statistical terms, YOLO-NAS demonstrates an approximate increase of 0.5 mAP points in accuracy compared to its counterparts, while exhibiting a striking speed advantage of 10–20% over equivalent versions of YOLOv8 and YOLOv7. The official comparative data is encapsulated in the figure below, illustrating the remarkable performance differentials among these models.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:875/0*i-UuJ7tz2x30wVMw" alt /></p>
<p>This evolution within the YOLO architecture, particularly with YOLO-NAS, underscores the relentless pursuit of precision and efficiency in object detection technologies. The tangible advancements witnessed in this latest iteration hold promise for diverse applications across industries, offering enhanced accuracy without compromising on speed, thereby revolutionizing the landscape of computer vision systems.</p>
<h1 id="heading-fiftyone-overview"><strong>FiftyOne: Overview</strong></h1>
<p><a target="_blank" href="https://docs.voxel51.com/index.html">FiftyOne</a> stands out as a robust tool used for streamlined and efficient inference in the realm of computer vision. This versatile platform is tailored to simplify the process of evaluating, analyzing, and visualizing models’ predictions on datasets, making it a go-to choice for professionals working in object detection, image segmentation, and beyond. With its intuitive interface and comprehensive functionalities, FiftyOne streamlines the inference process, enabling practitioners to assess model performance, iterate on improvements, and gain deeper insights into their computer vision solutions effortlessly. Learn more about the tool in the following link: <a target="_blank" href="https://docs.voxel51.com/index.html">https://docs.voxel51.com/index.html</a>.</p>
<h1 id="heading-e2e-gpu-cloud"><strong>E2E GPU Cloud</strong></h1>
<p>The most effective approach to grasp YOLO-NAS and FiftyOne involves hands-on experience, where the environment you choose for practice plays a pivotal role in mastering such complex architectures. Amidst numerous GPU cloud service providers available, selecting the right one can notably enhance both cost efficiency and productivity. Fortunately, after thorough research, I’ve identified <a target="_blank" href="https://www.e2enetworks.com/">E2E Cloud</a> as the optimal choice, offering a balance between cost-effectiveness and accessibility. Moreover, it provides readily available setups for all required environments, expediting enthusiast projects by saving valuable time. For this hands-on session, I utilized the TIR-AI Platform within the E2E cloud. To embark on a similar journey, you can initiate the process by following this link: <a target="_blank" href="https://docs.voxel51.com/index.html">https://www.e2enetworks.com/blog/how-to-use-jupyter-notebooks-on-e2e-networks</a>.</p>
<h1 id="heading-lets-play"><strong>Let’s Play</strong></h1>
<p>To employ YOLO-NAS (super-gradients) and FiftyOne, installation can be accomplished via the Python package installer, PIP. In a Jupyter notebook, utilize the magic command as illustrated below:</p>
<pre><code class="lang-python">!pip install fiftyone
!pip install super-gradients
</code></pre>
<p>Alternatively, when operating in the E2E cloud terminal:</p>
<pre><code class="lang-python">pip install fiftyone
pip install super-gradients
</code></pre>
<p>Next, import the necessary packages by executing:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> urllib.request


<span class="hljs-keyword">import</span> fiftyone <span class="hljs-keyword">as</span> fo
<span class="hljs-keyword">import</span> fiftyone.utils.annotations <span class="hljs-keyword">as</span> foua
<span class="hljs-keyword">import</span> super_gradients
</code></pre>
<p>For our inference process, let’s procure several images from the internet and store them in a designated folder. However, if you already possess a folder containing images for use, you can bypass this step and directly upload the folder to the E2E cloud. Simply provide the path to this folder in the ‘base_dir’ variable.</p>
<pre><code class="lang-python"><span class="hljs-comment"># Alternatively if a folder full of images has to be predicted use os.listdir("folder_path")</span>


test_images_urls =[<span class="hljs-string">"http://farm4.staticflickr.com/3454/3208929391_b9fa771095_z.jpg"</span>,
       <span class="hljs-string">"http://farm9.staticflickr.com/8457/7981004366_626686aa75_z.jpg"</span>,
       <span class="hljs-string">"https://farm3.staticflickr.com/2183/2435864370_901e470541_z.jpg"</span>,
       <span class="hljs-string">"https://farm2.staticflickr.com/1091/527450857_dfdcbcb3e7_z.jpg"</span>,
       <span class="hljs-string">"https://farm9.staticflickr.com/8507/8476712489_a24567bf64_z.jpg"</span>
                   ]


<span class="hljs-comment"># download the images</span>
base_dir = <span class="hljs-string">"test_imgs"</span>
<span class="hljs-keyword">try</span>:
    os.mkdir(base_dir)
<span class="hljs-keyword">except</span> OSError <span class="hljs-keyword">as</span> error:
    print(<span class="hljs-string">"Directory Exists!"</span>)


<span class="hljs-keyword">for</span> index, img_url <span class="hljs-keyword">in</span> enumerate(test_images_urls):
  urllib.request.urlretrieve(img_url, <span class="hljs-string">f"<span class="hljs-subst">{base_dir}</span>/<span class="hljs-subst">{str(index)}</span>.jpg"</span>)
</code></pre>
<p>Visualizing the images using the FiftyOne session allows us to confirm if the data has been loaded correctly. Don’t hesitate to explore the tool to gain a deeper understanding!</p>
<pre><code class="lang-python"><span class="hljs-comment"># View the downloaded dataset</span>
test_dataset = fo.Dataset.from_images_dir(base_dir)
test_session = fo.launch_app(test_dataset)
</code></pre>
<p><img src="https://miro.medium.com/v2/resize:fit:875/0*DBWWTgvbYoA2uiXD" alt /></p>
<p>Next, we’ll initialize the YOLO-NAS model for predictions. In this code snippet, we’re employing the YOLO-NAS Large model. However, if you prefer a different variant like medium or small, adjust the ‘model_size’ variable accordingly. To assess the functionality of the code, a sample image is utilized, initializing the model with pre-trained weights from the coco dataset.</p>
<pre><code class="lang-python"><span class="hljs-comment"># Loading model, for medium/low use 'yolo_nas_m' / 'yolo_nas_s'</span>
model_size = <span class="hljs-string">"yolo_nas_l"</span>


<span class="hljs-comment"># If you don't have GPU instance remove .cuda()</span>
yolo_nas = super_gradients.training.models.get(model_size, pretrained_weights=<span class="hljs-string">"coco"</span>).cuda()


img_url = <span class="hljs-string">"https://deci-pretrained-models.s3.amazonaws.com/sample_images/beatles-abbeyroad.jpg"</span>
<span class="hljs-comment"># test and view prediction on single image</span>
model_predictions  = yolo_nas.predict(img_url).show()
</code></pre>
<p><img src="https://miro.medium.com/v2/resize:fit:875/0*hKIa61MJGsuyHAmU" alt /></p>
<p>Let’s leverage the capabilities of YOLO-NAS to make predictions on the loaded data using FiftyOne. The ‘conf’ variable serves as a hyperparameter, dictating the minimum confidence necessary to draw bounding boxes after object detection. For this experiment, we set ‘conf=0.6’.</p>
<pre><code class="lang-python">file_paths, widths, heights = test_dataset.values([<span class="hljs-string">"filepath"</span>, <span class="hljs-string">"metadata.width"</span>, <span class="hljs-string">"metadata.height"</span>])
preds = yolo_nas.predict(file_paths, conf = <span class="hljs-number">0.6</span>)._images_prediction_lst
</code></pre>
<p>The ‘_images_prediction_lst’ parameter produces a Python iterable where each element contains all predictions for each image. To better comprehend this, let’s take a peek into the predictions of the first image.</p>
<pre><code class="lang-python"><span class="hljs-comment"># Peeking into predictions</span>
print(preds[<span class="hljs-number">0</span>])
</code></pre>
<p>Now, it’s time to merge the predictions with the image and plot the bounding boxes. This involves 3 steps:</p>
<ol>
<li><p>Acquiring a label dictionary, mapping each label to its respective object.</p>
</li>
<li><p>Converting YOLO’s ‘xyxy’ bounding box format to COCO format.</p>
</li>
<li><p>Transforming YOLO predictions into FiftyOne Detection objects.</p>
</li>
</ol>
<p>The following code blocks cover all these 3 steps seamlessly.</p>
<p>1.</p>
<pre><code class="lang-python"><span class="hljs-comment"># create label to lable_name mapping</span>
label_dict = {i:j <span class="hljs-keyword">for</span> i,j <span class="hljs-keyword">in</span> enumerate(preds[<span class="hljs-number">0</span>].class_names)}
print(label_dict)
</code></pre>
<p>2.</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">convert_bboxes</span>(<span class="hljs-params">bboxes, w, h</span>):</span>
  <span class="hljs-string">"""
  Input:
  bboxes: YOLO boundary boxes of type xyxy
  w : width of image
  h : height of image


  Output:
  COCO format converted boundary boxes
  """</span>
  tmp = np.copy(bboxes[:, <span class="hljs-number">1</span>])
  bboxes[:, <span class="hljs-number">1</span>] = h - bboxes[:, <span class="hljs-number">3</span>]
  bboxes[:, <span class="hljs-number">3</span>] = h - tmp
  bboxes[:, <span class="hljs-number">0</span>]/= w
  bboxes[:, <span class="hljs-number">2</span>]/= w
  bboxes[:, <span class="hljs-number">1</span>]/= h
  bboxes[:, <span class="hljs-number">3</span>]/= h
  bboxes[:, <span class="hljs-number">2</span>] -= bboxes[:, <span class="hljs-number">0</span>]
  bboxes[:, <span class="hljs-number">3</span>] -= bboxes[:, <span class="hljs-number">1</span>]
  bboxes[:, <span class="hljs-number">1</span>] = <span class="hljs-number">1</span> - (bboxes[:, <span class="hljs-number">1</span>] + bboxes[:, <span class="hljs-number">3</span>])
  <span class="hljs-keyword">return</span> bboxes
</code></pre>
<p>3.</p>
<pre><code class="lang-python"><span class="hljs-comment"># extract bbox, confidence and labels from predictions</span>
<span class="hljs-comment"># create FiftyOne's detections object for each image</span>
all_detections = []
<span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds:
  img = pred.image
  pred = pred.prediction
  height, width, _ = img.shape


  bboxes, probs, labels = np.array(pred.bboxes_xyxy), pred.confidence, pred.labels.astype(int)
  bboxes = convert_bboxes(bboxes, width, height)


  labels = [label_dict[i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> labels]


  detections = []
  <span class="hljs-keyword">for</span> (label, prob, bbox) <span class="hljs-keyword">in</span> zip(labels, probs, bboxes):
    detections.append(fo.Detection(label = label,confidence = prob,bounding_box = bbox))


  all_detections.append(fo.Detections(detections=detections))


print(all_detections[<span class="hljs-number">0</span>]) <span class="hljs-comment"># converted to COCO format</span>
</code></pre>
<p>Everything’s set! Now, let’s bring on the visualizations using FiftyOne, where the real fun begins. Time to explore and enjoy the predictions in action!</p>
<pre><code class="lang-python"><span class="hljs-comment"># Visualize the predictions with FiftyOne</span>


dataset = fo.Dataset() <span class="hljs-comment"># empty dataset</span>
samples = []
<span class="hljs-keyword">for</span> fpath, pred <span class="hljs-keyword">in</span> zip(file_paths, all_detections): <span class="hljs-comment">#iterate all images and draw detections</span>
  samples.append(fo.Sample(filepath=fpath, pred_objects=pred))

dataset.add_samples(samples)


session = fo.launch_app(dataset)
</code></pre>
<p><img src="https://miro.medium.com/v2/resize:fit:875/0*54-FMUZK5B-LLB-O" alt /></p>
<h1 id="heading-conclusion"><strong>Conclusion</strong></h1>
<p>In conclusion, diving into YOLO-NAS and FiftyOne has been an exciting journey. We’ve explored powerful tools and techniques, unlocking the potential of computer vision in a hands-on, dynamic way. And guess what? It’s all been made smoother and more exhilarating with the support of E2E Cloud! Cheers to the thrill of innovation and learning in this vibrant tech landscape!</p>
<p>The code used can be found at GitHub: <a target="_blank" href="https://github.com/Lord-Axy/Article-YoloNAS">https://github.com/Lord-Axy/Article-YoloNAS</a></p>
<p>Let’s stay connected:</p>
<p>LinkedIn: <a target="_blank" href="https://github.com/Lord-Axy/Article-YoloNAS">https://www.linkedin.com/in/akshayraj-axy-210733132/</a></p>
<h1 id="heading-references"><strong>References</strong></h1>
<p>YOLO Original Paper: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://arxiv.org/pdf/1506.02640.pdf</a></p>
<p><a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">Deci.ai</a> : <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://deci.ai/</a></p>
<p>YOLO-NAS: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://deci.ai/blog/yolo-nas-object-detection-foundation-model/</a></p>
<p>FiftyOne: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://docs.voxel51.com/index.html</a></p>
<p>E2E network home: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://www.e2enetworks.com/</a></p>
<p>E2E environment setup: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://www.e2enetworks.com/blog/how-to-use-jupyter-notebooks-on-e2e-networks</a></p>
<p>COCO Prediction tutorial: <a target="_blank" href="https://arxiv.org/pdf/1506.02640.pdf">https://voxel51.com/blog/state-of-the-art-object-detection-with-yolo-nas-fiftyone/</a></p>
]]></content:encoded></item></channel></rss>