<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Tushar Singh</title>
    <description>The latest articles on Forem by Tushar Singh (@_tusharrathore).</description>
    <link>https://forem.com/_tusharrathore</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3111488%2F7d744a7e-5d03-4ce6-929c-89ae7c61c189.jpg</url>
      <title>Forem: Tushar Singh</title>
      <link>https://forem.com/_tusharrathore</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/_tusharrathore"/>
    <language>en</language>
    <item>
      <title>Image Annotation Applications: A Complete</title>
      <dc:creator>Tushar Singh</dc:creator>
      <pubDate>Fri, 21 Nov 2025 11:08:27 +0000</pubDate>
      <link>https://forem.com/_tusharrathore/image-annotation-applications-a-complete-1m6c</link>
      <guid>https://forem.com/_tusharrathore/image-annotation-applications-a-complete-1m6c</guid>
      <description>&lt;p&gt;How does your phone recognize faces in photos? Or how self-driving cars know where the road is? The answer is image annotation. This technology is changing our world, and it's easier to understand than you might think.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Image Annotation?
&lt;/h2&gt;

&lt;p&gt;Image annotation is the process of adding labels or tags to images to help computers understand what they're seeing. People draw boxes around objects, highlight areas, or add descriptive tags to pictures. These labeled images then teach artificial intelligence (AI) systems to recognize similar objects in new, unlabeled images. It's like teaching a child to identify animals using flashcards with labels.&lt;/p&gt;

&lt;p&gt;Think of image annotation as creating training wheels for AI. Just as training wheels help you learn to ride a bike, annotated images help AI learn to "see." Without these labels, computers would just see random shapes and colors without understanding what they mean.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need Image Annotation Applications?
&lt;/h2&gt;

&lt;p&gt;We need image annotation applications because manually labeling thousands of images takes too much time and effort. These specialized tools make the process faster, more accurate, and consistent. They provide features like automatic labeling assistance, quality checks, and collaboration tools that allow teams to work together efficiently on large annotation projects.&lt;/p&gt;

&lt;p&gt;Modern image annotation applications have transformed how we prepare data for AI systems. Companies like Labellerr AI have developed platforms that combine human expertise with machine learning to create high-quality training data efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Image Annotation Techniques
&lt;/h2&gt;

&lt;p&gt;There are several ways to annotate images, each useful for different purposes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bounding Boxes:&lt;/strong&gt; Drawing rectangles around objects (like cars, people, or animals)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Polygon Annotation:&lt;/strong&gt; Creating precise shapes around irregular objects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic Segmentation:&lt;/strong&gt; Coloring each pixel to show what object it belongs to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Landmark Annotation:&lt;/strong&gt; Marking specific points on objects (like facial features)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text Annotation:&lt;/strong&gt; Adding labels or descriptions to parts of an image&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Do Image Annotation Tools Help Machine Learning?
&lt;/h2&gt;

&lt;p&gt;Image annotation tools provide the labeled data that machine learning algorithms need to learn pattern recognition. These tools create training datasets where each image has accurate labels identifying objects, boundaries, or features. The AI studies these examples to learn what different objects look like from various angles, lighting conditions, and contexts, eventually becoming able to identify them in new, unlabeled images.&lt;/p&gt;

&lt;p&gt;According to research from &lt;a href="https://arxiv.org/abs/1909.13335" rel="noopener noreferrer"&gt;Stanford University&lt;/a&gt;, the quality of annotation directly impacts how well AI models perform. Poor labeling leads to confused AI, while precise annotations create smarter systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Using Professional Annotation Tools
&lt;/h2&gt;

&lt;p&gt;Using specialized image annotation applications offers several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time Savings:&lt;/strong&gt; Automated features speed up the labeling process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better Accuracy:&lt;/strong&gt; Quality control tools reduce mistakes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team Collaboration:&lt;/strong&gt; Multiple people can work on the same project&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Standardized labeling across all images&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; Ability to handle large projects with thousands of images&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://www.nature.com/articles/s42256-020-00287-7" rel="noopener noreferrer"&gt;Nature Journal of Machine Intelligence&lt;/a&gt; highlights that as AI systems become more advanced, the demand for high-quality annotated data continues to grow exponentially.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Are Image Annotation Applications Used?
&lt;/h2&gt;

&lt;p&gt;You might be surprised how many areas use image annotation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Self-Driving Cars:&lt;/strong&gt; Identifying pedestrians, other vehicles, and traffic signs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Medical Imaging:&lt;/strong&gt; Spotting diseases in X-rays, MRIs, and CT scans&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retail:&lt;/strong&gt; Recognizing products for inventory management and visual search&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agriculture:&lt;/strong&gt; Monitoring crop health and detecting pests&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Identifying suspicious activities or objects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Media:&lt;/strong&gt; Automatically tagging people in photos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Companies developing these technologies rely on image annotation applications to create the training data their AI needs. For instance, Labellerr AI provides annotation services that help businesses across these industries build better computer vision models.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges in Image Annotation
&lt;/h2&gt;

&lt;p&gt;Despite technological advances, image annotation still faces some difficulties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Subjectivity:&lt;/strong&gt; Different people might label the same object differently&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex Objects:&lt;/strong&gt; Some items have unclear boundaries or change shape&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time-Consuming:&lt;/strong&gt; Detailed annotation requires significant human effort&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; High-quality annotation can be expensive for large datasets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Control:&lt;/strong&gt; Ensuring consistent quality across all annotations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A study by ACM found that inconsistent annotations are one of the biggest challenges in computer vision projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Makes a Good Image Annotation Tool?
&lt;/h2&gt;

&lt;p&gt;A good image annotation tool provides an intuitive interface, supports multiple annotation types (boxes, polygons, etc.), includes quality assurance features, enables team collaboration, offers automation capabilities to speed up labeling, and maintains data security. The best tools balance ease of use with powerful features suitable for both beginners and expert annotators working on complex projects.&lt;/p&gt;

&lt;p&gt;When evaluating image annotation applications, consider these key features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User-Friendly Interface:&lt;/strong&gt; Easy to learn and use&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple Annotation Types:&lt;/strong&gt; Supports different labeling methods&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration Features:&lt;/strong&gt; Allows team members to work together&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Control:&lt;/strong&gt; Tools to check and maintain annotation quality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automation:&lt;/strong&gt; AI-assisted labeling to speed up the process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Security:&lt;/strong&gt; Protects sensitive images and information&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Future of Image Annotation
&lt;/h2&gt;

&lt;p&gt;Image annotation is evolving quickly. Here are some exciting developments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AI-Assisted Annotation: Tools that learn from human input and suggest labels&lt;/li&gt;
&lt;li&gt;3D Annotation: Labeling objects in three-dimensional space&lt;/li&gt;
&lt;li&gt;Video Annotation: Tracking objects across multiple video frames&lt;/li&gt;
&lt;li&gt;Active Learning: Systems that identify which images would be most valuable to annotate&lt;/li&gt;
&lt;li&gt;Synthetic Data: Computer-generated images with automatic labels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As noted by Forbes, the future of AI depends heavily on improvements in data preparation, including image annotation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What's the difference between image annotation and image labeling?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Image labeling typically means adding a single tag to an entire image (like "cat"), while image annotation involves marking specific regions or objects within an image (like drawing a box around each cat in a picture with multiple animals).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long does it take to annotate an image?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It depends on the complexity. A simple bounding box around one object might take seconds, while detailed segmentation of multiple complex objects could take several minutes per image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can image annotation be completely automated?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Not yet. While AI can help with annotation, human review is still needed for accuracy, especially for complex or unusual cases. The best approach combines AI efficiency with human quality control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready to Learn More About Image Annotation?
&lt;/h2&gt;

&lt;p&gt;Understanding &lt;a href="https://www.labellerr.com/blog/how-image-annotation-is-leading-the-way-in-ai-and-ml/?utm_source=organic&amp;amp;utm_medium=referal&amp;amp;utm_campaign=organic-SLR" rel="noopener noreferrer"&gt;image annotation applications&lt;/a&gt; is the first step toward leveraging this powerful technology. Whether you're a student, developer, or business professional, mastering image annotation can open doors to exciting opportunities in AI and machine learning.&lt;/p&gt;

&lt;p&gt;Visit Labellerr AI to explore how professional image annotation tools can help with your computer vision projects and take your AI initiatives to the next level.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Image Annotation Applications: A Complete Guide</title>
      <dc:creator>Tushar Singh</dc:creator>
      <pubDate>Fri, 21 Nov 2025 10:59:18 +0000</pubDate>
      <link>https://forem.com/_tusharrathore/image-annotation-applications-a-complete-guide-3ao9</link>
      <guid>https://forem.com/_tusharrathore/image-annotation-applications-a-complete-guide-3ao9</guid>
      <description>&lt;p&gt;How does your phone recognize faces in photos? Or how self-driving cars know where the road is? The answer is image annotation. This technology is changing our world, and it's easier to understand than you might think.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Image Annotation?
&lt;/h2&gt;

&lt;p&gt;Image annotation is the process of adding labels or tags to images to help computers understand what they're seeing. People draw boxes around objects, highlight areas, or add descriptive tags to pictures. These labeled images then teach artificial intelligence (AI) systems to recognize similar objects in new, unlabeled images. It's like teaching a child to identify animals using flashcards with labels.&lt;/p&gt;

&lt;p&gt;Think of image annotation as creating training wheels for AI. Just as training wheels help you learn to ride a bike, annotated images help AI learn to "see." Without these labels, computers would just see random shapes and colors without understanding what they mean.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need Image Annotation Applications?
&lt;/h2&gt;

&lt;p&gt;We need image annotation applications because manually labeling thousands of images takes too much time and effort. These specialized tools make the process faster, more accurate, and consistent. They provide features like automatic labeling assistance, quality checks, and collaboration tools that allow teams to work together efficiently on large annotation projects.&lt;/p&gt;

&lt;p&gt;Modern image annotation applications have transformed how we prepare data for AI systems. Companies like Labellerr AI have developed platforms that combine human expertise with machine learning to create high-quality training data efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Image Annotation Techniques
&lt;/h2&gt;

&lt;p&gt;There are several ways to annotate images, each useful for different purposes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bounding Boxes:&lt;/strong&gt; Drawing rectangles around objects (like cars, people, or animals)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Polygon Annotation:&lt;/strong&gt; Creating precise shapes around irregular objects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic Segmentation:&lt;/strong&gt; Coloring each pixel to show what object it belongs to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Landmark Annotation:&lt;/strong&gt; Marking specific points on objects (like facial features)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text Annotation:&lt;/strong&gt; Adding labels or descriptions to parts of an image&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Do Image Annotation Tools Help Machine Learning?
&lt;/h2&gt;

&lt;p&gt;Image annotation tools provide the labeled data that machine learning algorithms need to learn pattern recognition. These tools create training datasets where each image has accurate labels identifying objects, boundaries, or features. The AI studies these examples to learn what different objects look like from various angles, lighting conditions, and contexts, eventually becoming able to identify them in new, unlabeled images.&lt;/p&gt;

&lt;p&gt;According to research from &lt;a href="https://arxiv.org/abs/1909.13335" rel="noopener noreferrer"&gt;Stanford University&lt;/a&gt;, the quality of annotation directly impacts how well AI models perform. Poor labeling leads to confused AI, while precise annotations create smarter systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Using Professional Annotation Tools
&lt;/h2&gt;

&lt;p&gt;Using specialized image annotation applications offers several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time Savings:&lt;/strong&gt; Automated features speed up the labeling process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better Accuracy:&lt;/strong&gt; Quality control tools reduce mistakes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team Collaboration:&lt;/strong&gt; Multiple people can work on the same project&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Standardized labeling across all images&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; Ability to handle large projects with thousands of images&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://www.nature.com/articles/s42256-020-00287-7" rel="noopener noreferrer"&gt;Nature Journal of Machine Intelligence&lt;/a&gt; highlights that as AI systems become more advanced, the demand for high-quality annotated data continues to grow exponentially.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Are Image Annotation Applications Used?
&lt;/h2&gt;

&lt;p&gt;You might be surprised how many areas use image annotation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Self-Driving Cars:&lt;/strong&gt; Identifying pedestrians, other vehicles, and traffic signs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Medical Imaging:&lt;/strong&gt; Spotting diseases in X-rays, MRIs, and CT scans&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retail:&lt;/strong&gt; Recognizing products for inventory management and visual search&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agriculture:&lt;/strong&gt; Monitoring crop health and detecting pests&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Identifying suspicious activities or objects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Media:&lt;/strong&gt; Automatically tagging people in photos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Companies developing these technologies rely on image annotation applications to create the training data their AI needs. For instance, Labellerr AI provides annotation services that help businesses across these industries build better computer vision models.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges in Image Annotation
&lt;/h2&gt;

&lt;p&gt;Despite technological advances, image annotation still faces some difficulties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Subjectivity:&lt;/strong&gt; Different people might label the same object differently&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex Objects:&lt;/strong&gt; Some items have unclear boundaries or change shape&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time-Consuming:&lt;/strong&gt; Detailed annotation requires significant human effort&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; High-quality annotation can be expensive for large datasets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Control:&lt;/strong&gt; Ensuring consistent quality across all annotations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A study by ACM found that inconsistent annotations are one of the biggest challenges in computer vision projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Makes a Good Image Annotation Tool?
&lt;/h2&gt;

&lt;p&gt;A good image annotation tool provides an intuitive interface, supports multiple annotation types (boxes, polygons, etc.), includes quality assurance features, enables team collaboration, offers automation capabilities to speed up labeling, and maintains data security. The best tools balance ease of use with powerful features suitable for both beginners and expert annotators working on complex projects.&lt;/p&gt;

&lt;p&gt;When evaluating image annotation applications, consider these key features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User-Friendly Interface:&lt;/strong&gt; Easy to learn and use&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple Annotation Types:&lt;/strong&gt; Supports different labeling methods&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration Features:&lt;/strong&gt; Allows team members to work together&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Control:&lt;/strong&gt; Tools to check and maintain annotation quality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automation:&lt;/strong&gt; AI-assisted labeling to speed up the process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Security:&lt;/strong&gt; Protects sensitive images and information&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Future of Image Annotation
&lt;/h2&gt;

&lt;p&gt;Image annotation is evolving quickly. Here are some exciting developments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AI-Assisted Annotation: Tools that learn from human input and suggest labels&lt;/li&gt;
&lt;li&gt;3D Annotation: Labeling objects in three-dimensional space&lt;/li&gt;
&lt;li&gt;Video Annotation: Tracking objects across multiple video frames&lt;/li&gt;
&lt;li&gt;Active Learning: Systems that identify which images would be most valuable to annotate&lt;/li&gt;
&lt;li&gt;Synthetic Data: Computer-generated images with automatic labels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As noted by Forbes, the future of AI depends heavily on improvements in data preparation, including image annotation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What's the difference between image annotation and image labeling?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Image labeling typically means adding a single tag to an entire image (like "cat"), while image annotation involves marking specific regions or objects within an image (like drawing a box around each cat in a picture with multiple animals).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long does it take to annotate an image?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It depends on the complexity. A simple bounding box around one object might take seconds, while detailed segmentation of multiple complex objects could take several minutes per image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can image annotation be completely automated?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Not yet. While AI can help with annotation, human review is still needed for accuracy, especially for complex or unusual cases. The best approach combines AI efficiency with human quality control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready to Learn More About Image Annotation?
&lt;/h2&gt;

&lt;p&gt;Understanding &lt;a href="https://www.labellerr.com/blog/how-image-annotation-is-leading-the-way-in-ai-and-ml/?utm_source=organic&amp;amp;utm_medium=referal&amp;amp;utm_campaign=organic-SLR" rel="noopener noreferrer"&gt;image annotation applications&lt;/a&gt; is the first step toward leveraging this powerful technology. Whether you're a student, developer, or business professional, mastering image annotation can open doors to exciting opportunities in AI and machine learning.&lt;/p&gt;

&lt;p&gt;Visit Labellerr AI to explore how professional image annotation tools can help with your computer vision projects and take your AI initiatives to the next level.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Labellerr SDK &amp; YOLOv8: Cars and Number Plate Detection Practical, Step-by-Step</title>
      <dc:creator>Tushar Singh</dc:creator>
      <pubDate>Thu, 06 Nov 2025 04:03:17 +0000</pubDate>
      <link>https://forem.com/_tusharrathore/labellerr-x-yolov8-cars-and-number-plate-detection-practical-step-by-step-3dd3</link>
      <guid>https://forem.com/_tusharrathore/labellerr-x-yolov8-cars-and-number-plate-detection-practical-step-by-step-3dd3</guid>
      <description>&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;In this project, we will build a complete end-to-end pipeline for detecting cars and their number plates using a custom-trained object detection model. The workflow is structured and beginner-friendly: we will first label images in Labellerr, then export those annotations, convert them into the YOLOv8 compatible format, and finally train and evaluate the model to see real detection results.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Labellerr?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.labellerr.com/" rel="noopener noreferrer"&gt;Labellerr&lt;/a&gt; is a smart data annotation platform designed specifically for computer vision workflows.&lt;br&gt;
It helps teams create high-quality labeled datasets efficiently, without the usual hassle of managing annotation tasks manually.&lt;/p&gt;

&lt;p&gt;Key advantages of using Labellerr:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intuitive bounding box annotation UI  ideal for object detection tasks&lt;/li&gt;
&lt;li&gt;Built-in quality review workflows  ensures consistency across annotations&lt;/li&gt;
&lt;li&gt;Direct export support for YOLO formats  no manual formatting or conversion required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, Labellerr saves both time and effort while maintaining annotation quality, which is crucial for achieving good model performance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For more details and examples, refer to the official documentation:&lt;br&gt;
&lt;a href="https://docs.labellerr.com/" rel="noopener noreferrer"&gt;https://docs.labellerr.com/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  What is YOLOv8?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.ultralytics.com/" rel="noopener noreferrer"&gt;YOLOv8&lt;/a&gt;(by Ultralytics) is one of the most widely used state-of-the-art object detection models.&lt;br&gt;
It is known for delivering high accuracy, while still being fast enough for real-time detection.&lt;/p&gt;

&lt;p&gt;Why YOLOv8 works well here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast inference speed even on modest hardware&lt;/li&gt;
&lt;li&gt;Straightforward training workflow&lt;/li&gt;
&lt;li&gt;Excellent accuracy for object localization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it a strong choice for real-world applications such as vehicle surveillance, traffic monitoring, and automated license plate recognition systems.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Use Labellerr and YOLOv8 Together?
&lt;/h2&gt;

&lt;p&gt;Both tools complement each other perfectly:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Role in the Pipeline&lt;/th&gt;
&lt;th&gt;Benefit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Labellerr&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Label images clearly and consistently&lt;/td&gt;
&lt;td&gt;High-quality dataset preparation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;YOLOv8&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Train and evaluate the detection model&lt;/td&gt;
&lt;td&gt;Strong real-world performance with minimal setup&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The workflow becomes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Label → Export → Train → Detect,&lt;/strong&gt;&lt;br&gt;
without any messy intermediate steps or custom conversion scripts.&lt;/p&gt;

&lt;p&gt;This results in a clean, reliable, and efficient pipeline from annotation to model deployment.&lt;/p&gt;


&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1:
&lt;/h3&gt;

&lt;p&gt;In this step, we will install all the required libraries including Labellerr SDK and YOLOv8.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install all dependencies in one go.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!python -m pip install --upgrade pip
!python -m pip install --quiet https://github.com/tensormatics/SDKPython/releases/download/prod/labellerr_sdk-1.0.0.tar.gz kaggle Pillow requests python-dotenv opencv-python numpy scikit-learn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Setting Up Kaggle Credentials
&lt;/h3&gt;

&lt;p&gt;Since we are downloading the dataset from Kaggle, we first need to configure our Kaggle API credentials inside Google Colab.&lt;br&gt;
This allows us to download datasets directly using commands like kaggle datasets download.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to your Kaggle account settings&lt;/li&gt;
&lt;li&gt;Scroll to API section&lt;/li&gt;
&lt;li&gt;Click on Create New API Token&lt;/li&gt;
&lt;li&gt;A file named kaggle.json will be downloaded&lt;/li&gt;
&lt;li&gt;We will programmatically place this file in the correct location
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os, json, shutil
from pathlib import Path
from getpass import getpass
from IPython.display import display, Markdown

# Get Kaggle credentials from user input
KAGGLE_USERNAME = input("Enter your Kaggle username: ")
KAGGLE_KEY = getpass("Enter your Kaggle API key: ")

# Create .kaggle directory in user's home folder
kaggle_dir = Path.home() / ".kaggle"
kaggle_dir.mkdir(exist_ok=True)

# Write credentials to kaggle.json file
with open(kaggle_dir / "kaggle.json", "w") as f:
    json.dump({"username": KAGGLE_USERNAME, "key": KAGGLE_KEY}, f)

# Set proper permissions (600 = read/write for owner only)
os.chmod(kaggle_dir / "kaggle.json", 0o600)

display(Markdown("Kaggle credentials configured at `~/.kaggle/kaggle.json`"))
display(Markdown("Credentials securely stored with proper file permissions"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;What This Code Does:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part / Line&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;input()&lt;/code&gt; / &lt;code&gt;getpass()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Securely capture username &amp;amp; API key (key not echoed)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;~/.kaggle/&lt;/code&gt; directory&lt;/td&gt;
&lt;td&gt;Required location for Kaggle CLI credentials&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;kaggle.json&lt;/code&gt; write&lt;/td&gt;
&lt;td&gt;Stores &lt;code&gt;{username, key}&lt;/code&gt; for authentication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;os.chmod(..., 0o600)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Restricts file permissions to owner only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;display(Markdown(...))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows friendly confirmation messages&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;h3&gt;
  
  
  Step 3: Downloading the Dataset from Kaggle
&lt;/h3&gt;

&lt;p&gt;Now that our Kaggle credentials are configured, we can download the dataset directly into Google Colab using the Kaggle CLI.&lt;br&gt;
This avoids manual upload and ensures fast + clean workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset Used:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;andrewmvd/car-plate-detection&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pathlib import Path
from IPython.display import display, Markdown

# Download dataset via Kaggle CLI
DATASET = "andrewmvd/car-plate-detection"
DATA_DIR = Path("datasets/car")
DATA_DIR.mkdir(parents=True, exist_ok=True)

!kaggle datasets download -d {DATASET} -p {str(DATA_DIR)} --unzip

display(Markdown(f" Downloaded dataset `{DATASET}` to `{DATA_DIR}`"))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What This Code Does&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Line / Component&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DATASET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies the dataset to download from Kaggle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Path("datasets/car")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sets the directory where dataset will be stored&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mkdir(parents=True, exist_ok=True)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates folder if it doesn’t already exist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kaggle datasets download&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fetches dataset using Kaggle CLI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--unzip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Automatically extracts the files after download&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;display(Markdown(...))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Outputs a friendly completion message&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 4: Preparing Sample Images for Inspection
&lt;/h3&gt;

&lt;p&gt;Before labeling and training, it's always a good idea to preview a few images from the dataset.&lt;br&gt;
This helps us verify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The dataset downloaded correctly&lt;/li&gt;
&lt;li&gt;The images are relevant&lt;/li&gt;
&lt;li&gt;Their quality is suitable for training&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here, we will randomly pick 10 sample images and store them in a separate folder for quick review.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pathlib import Path
from IPython.display import display, Markdown
import random
import shutil

# Prepare 10 sample images (ripe/unripe bananas subset if present; otherwise any images)
SEARCH_DIRS = [
    DATA_DIR,
]
IMAGE_EXTS = {".jpg", ".jpeg", ".png", ".bmp", ".tiff"}

all_images = []
for base in SEARCH_DIRS:
    for p in base.rglob("*"):
        if p.is_file() and p.suffix.lower() in IMAGE_EXTS:
            all_images.append(p)

random.shuffle(all_images)

SAMPLE_DIR = Path("sample_images")
SAMPLE_DIR.mkdir(exist_ok=True)

selected = all_images[:10]
for i, src in enumerate(selected, start=1):
    dst = SAMPLE_DIR / f"car_{i:02d}{src.suffix.lower()}"
    shutil.copy2(src, dst)

display(Markdown(f" Prepared {len(selected)} images in `{SAMPLE_DIR}`"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What This Code Does&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part / Line&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DATA_DIR&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Directory containing the downloaded dataset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;IMAGE_EXTS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Defines valid image file extensions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rglob("*")&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Recursively searches all folders for images&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;random.shuffle()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Randomizes image selection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SAMPLE_DIR.mkdir()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates a folder named &lt;code&gt;sample_images&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;copy2()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Copies selected sample images to that folder&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;display(Markdown(...))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Prints a neat confirmation message&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 5: Connecting to Labellerr (Authentication)
&lt;/h3&gt;

&lt;p&gt;Now we'll connect to the Labellerr platform. This cell will prompt you for your Labellerr credentials to initialize the API client.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client ID&lt;/strong&gt;: Your workspace-specific ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email&lt;/strong&gt;: The email associated with your Labellerr account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Key &amp;amp; Secret&lt;/strong&gt;: Found in your Labellerr account settings. These will be entered securely with hidden input.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** How to Get Your Client ID**&lt;br&gt;
The method depends on your Labellerr plan:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you're using a Pro or Enterprise plan, you can simply contact Labellerr Support and they will share your Client ID.&lt;/li&gt;
&lt;li&gt;If you're on the Free plan, you can request your Client ID by sending a short message to:
&lt;a href="mailto:support@tensormatics.com"&gt;support@tensormatics.com&lt;/a&gt;
(mention the email you used to sign up on Labellerr that’s it.)
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from getpass import getpass
from labellerr.client import LabellerrClient
from labellerr.exceptions import LabellerrError
from IPython.display import display, Markdown

# --- Interactive Input for Labellerr Credentials ---
print("Please enter your Labellerr API credentials.")
LABELLERR_CLIENT_ID = input("Labellerr Client ID: ")
LABELLERR_EMAIL = input("Labellerr Email: ")
LABELLERR_API_KEY = getpass("Labellerr API Key (input will be hidden): ")
LABELLERR_API_SECRET = getpass("Labellerr API Secret (input will be hidden): ")

# --- Initialize Labellerr Client ---
try:
    if not all([LABELLERR_API_KEY, LABELLERR_API_SECRET, LABELLERR_CLIENT_ID, LABELLERR_EMAIL]):
        raise ValueError("One or more required fields were left empty.")

    client = LabellerrClient(LABELLERR_API_KEY, LABELLERR_API_SECRET)

    display(Markdown(" Labellerr client initialized successfully!"))

except (LabellerrError, ValueError) as e:
    display(Markdown(f" **Client Initialization Failed:** {e}"))
    client = None

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;What This Code Does&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Line / Component&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;getpass()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Safely hides API key input while typing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LabellerrClient()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates authenticated Labellerr session&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;ValueError&lt;/code&gt; check&lt;/td&gt;
&lt;td&gt;Ensures no fields were left empty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;try / except&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Catches invalid credentials and prevents crashes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;display(Markdown(...))&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Prints clean success/failure messages&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;h3&gt;
  
  
  Step 6: Creating Annotation Schema in Labellerr
&lt;/h3&gt;

&lt;p&gt;Before labeling, we need to define what objects we want to annotate (Car &amp;amp; License Plate).&lt;br&gt;
This step tells Labellerr which classes to display in the labeling UI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ANNOTATION_QUESTIONS = [
    {
        "question_number": 1,
        "question": "Car",
        "question_id": "car-bbox-001",
        "option_type": "BoundingBox",
        "required": False,
        "options": [
            {"option_id": "opt-001", "option_name": "#FF0000"}
        ],
        "question_metadata": []
    },
    {
        "question_number": 2,
        "question": "License Plate",
        "question_id": "plate-bbox-002",
        "option_type": "BoundingBox",
        "required": False,
        "options": [
            {"option_id": "opt-002", "option_name": "#00FF00"}
        ],
        "question_metadata": []
    }
]




PROJECT_NAME = "Vehicle Object Detection new"
DATASET_NAME = "vehicle_dataset_sample_new"
DATASET_DESCRIPTION = "10 vehicle images including cars, plates"
DATA_TYPE = "image"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What This Code Defines&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field / Section&lt;/th&gt;
&lt;th&gt;Meaning / Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANNOTATION_QUESTIONS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List of labeling tasks the annotator will perform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;question&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Name shown in labeling UI (Car, License Plate)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;option_type = "BoundingBox"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Means user will draw bounding boxes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;option_name = "#FF0000"&lt;/code&gt; / &lt;code&gt;"#00FF00"&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Box color to visually differentiate classes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PROJECT_NAME&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Name of the project inside Labellerr&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DATASET_NAME&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Dataset title where labeled images will be stored&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DATASET_DESCRIPTION&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Short description for dataset organization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DATA_TYPE = "image"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies dataset type  important for correct processing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 7:  Create Annotation Template in Labellerr
&lt;/h3&gt;

&lt;p&gt;We’ll create an annotation guideline template (schema) in Labellerr using our questions (Car, License Plate).&lt;br&gt;
Different SDK versions may return either a UUID string or a JSON dict, so we’ll handle both safely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
from IPython.display import display, Markdown
from labellerr.exceptions import LabellerrError

template_id = None
try:
    res_str = client.create_annotation_guideline(
        client_id=LABELLERR_CLIENT_ID,
        questions=ANNOTATION_QUESTIONS,  
        template_name=f"{PROJECT_NAME} Template",
        data_type=DATA_TYPE,
    )

    #  Handle UUID-only or dict response
    if isinstance(res_str, str) and len(res_str) == 36 and res_str.count('-') == 4:
        template_id = res_str
        display(Markdown(f"Template created: `{template_id}`"))
    else:
        try:
            res = json.loads(res_str) if isinstance(res_str, str) else res_str
            template_id = res.get("response", {}).get("template_id")
            if template_id:
                display(Markdown(f"Template created: `{template_id}`"))
            else:
                display(Markdown(" Could not find template_id in response"))
                display(Markdown(f"Raw response: `{res_str}`"))
        except json.JSONDecodeError as e:
            display(Markdown(f" Response parsing issue: `{e}`"))
            display(Markdown(f"Raw response: `{res_str}`"))
            if isinstance(res_str, str) and len(res_str) &amp;gt; 20:
                template_id = res_str
                display(Markdown(f"Using response as template_id: `{template_id}`"))


except LabellerrError as e:
    display(Markdown(f"Template creation failed: `{e}`"))


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What This Code Does
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Line / Component&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;create_annotation_guideline(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates a labeling template in Labellerr&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;questions=ANNOTATION_QUESTIONS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Passes your schema (Car, License Plate)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;template_name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Human-readable name for the template&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data_type=DATA_TYPE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ensures correct modality (e.g., &lt;code&gt;"image"&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UUID check (&lt;code&gt;len==36&lt;/code&gt; &amp;amp; 4 dashes)&lt;/td&gt;
&lt;td&gt;Detects raw UUID responses from older SDKs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;json.loads(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Parses JSON response from newer SDKs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;res["response"]["template_id"]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Extracts template ID when returned inside a dict&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;except LabellerrError&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Catches SDK errors and prints a clean message&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fallback to &lt;code&gt;template_id = res_str&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Uses response as template ID if no JSON found&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Expected Success Output&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Template created: &lt;code&gt;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Step 8: Creating the Project in Labellerr &amp;amp; Uploading Images
&lt;/h3&gt;

&lt;p&gt;Once our annotation template is ready, the next step is to create a project in Labellerr and link our dataset.&lt;br&gt;
We will also upload the sample images folder so annotators can begin labeling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
from IPython.display import display, Markdown

project_id = None
if template_id:
    try:
        print("Creating project and linking dataset...")

        payload = {
            "client_id": LABELLERR_CLIENT_ID,
            "dataset_name": DATASET_NAME,
            "dataset_description": DATASET_DESCRIPTION,
            "data_type": DATA_TYPE,
            "created_by": LABELLERR_EMAIL,
            "project_name": PROJECT_NAME,
            "annotation_template_id": template_id,
            "rotation_config": {
                "annotation_rotation_count": 1,
                "review_rotation_count": 1,
                "client_review_rotation_count": 1
            },
            "autolabel": False,
            "folder_to_upload": "/content/sample_images"
        }

        # Pass as a single payload dictionary
        res = client.initiate_create_project(payload)

        # Handle response
        if isinstance(res, str) and len(res) == 36 and res.count('-') == 4:
            project_id = res
            display(Markdown(f"Project created: `{project_id}`"))
        else:
            try:
                res_obj = json.loads(res) if isinstance(res, str) else res
                project_id = res_obj.get("response", {}).get("project_id")
                if project_id:
                    display(Markdown(f" Project created: `{project_id}`"))
                else:
                    display(Markdown(" Could not find project_id in response"))
                    display(Markdown(f"Raw response: `{res}`"))
            except Exception as e:
                display(Markdown(f" Response parsing issue: `{e}`"))
                display(Markdown(f"Raw response: `{res}`"))

    except LabellerrError as e:
        display(Markdown(f" Project creation failed: `{e}`"))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What This Code Does&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Line / Component&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;payload = {...}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Contains all project settings and metadata&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;dataset_name&lt;/code&gt; / &lt;code&gt;project_name&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Organized names in Labellerr dashboard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;annotation_template_id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Attaches the schema we made earlier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;folder_to_upload&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Directory containing images to upload to Labellerr&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;initiate_create_project(payload)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates project + uploads dataset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UUID response check&lt;/td&gt;
&lt;td&gt;Handles cases where API returns raw UUID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSON parse fallback&lt;/td&gt;
&lt;td&gt;Handles cases where API returns JSON object&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;except LabellerrError&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Catches SDK errors cleanly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 9: Linking an Existing Dataset to the Project in Labellerr
&lt;/h3&gt;

&lt;p&gt;If your dataset is already uploaded to Labellerr, you do not need to upload images again.&lt;br&gt;
Instead, you simply need to copy its Dataset ID from the Labellerr dashboard and pass it into the project creation function.&lt;/p&gt;

&lt;p&gt;How to Get Dataset ID:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Labellerr Dashboard&lt;/li&gt;
&lt;li&gt;Go to Datasets section&lt;/li&gt;
&lt;li&gt;Select your dataset&lt;/li&gt;
&lt;li&gt;Copy the Dataset ID shown in the details panel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This Dataset ID is what we will use in the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code to Link Dataset With Project&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rotation_config = {
    "annotation_rotation_count": 1,
    "review_rotation_count": 1,
    "client_review_rotation_count": 1
}

print("Creating project and linking existing dataset...")

res = client.create_project(
    project_name=PROJECT_NAME,
    data_type=DATA_TYPE,
    client_id=LABELLERR_CLIENT_ID,
    dataset_id="b7954c7f-a071-4eb7-b4e0-1980b3505e2b",   # ✅ Paste your Dataset ID here
    annotation_template_id=template_id,
    rotation_config=rotation_config
)

print("Project created successfully:")
print(res)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field / Parameter&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dataset_id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The dataset you selected from Labellerr → copied from dashboard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;annotation_template_id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The annotation schema we created earlier (Car + License Plate)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rotation_config&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How many people annotate → review → client verify&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;create_project()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates a new project and links your dataset + labeling workflow&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 10:Labeling Workflow in Labellerr (Step-by-Step)
&lt;/h3&gt;

&lt;p&gt;Once your dataset is linked to the project, you can start labeling right inside Labellerr.&lt;br&gt;
Follow these clear steps to go from Label → Review → Accept.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Go to Projects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Open Labellerr Dashboard → Projects tab.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Open Your Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Select the project you created/linked (e.g., Vehicle Object Detection).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Go to the Label Section&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;_ Inside the project, click Label to open the annotation interface._&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Start Labeling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;-  Choose the right tool (e.g., Bounding Box).&lt;/em&gt;&lt;br&gt;
&lt;em&gt;-        Draw boxes around each Car and License Plate as per your schema.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;-        Assign the correct class from the sidebar.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Save / Submit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Save the annotation for each image (as per UI button in your workspace).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Move to Review&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Go to &lt;strong&gt;Review tab&lt;/strong&gt;. The images you labeled will show up for verification.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Accept or Send Back&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;- If the annotation looks good → Accept&lt;/em&gt;&lt;br&gt;
&lt;em&gt;- If changes needed → Send back to labeling.&lt;/em&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Step 11: Exporting Labeled Dataset from Labellerr
&lt;/h3&gt;

&lt;p&gt;After labeling + review, we export annotations from Labellerr.&lt;br&gt;
This script automates 3 steps: Create export → Poll status → Download &amp;amp; Validate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# --- Car Dataset Export Script ---
from IPython.display import display, Markdown
import requests
import json
import time
from pathlib import Path
import logging
import traceback
import uuid
from labellerr.exceptions import LabellerrError

project_id = "magdaia_joyous_peafowl_21008"

# CONFIGURE LOGGER
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S',
    force=True
)
logger = logging.getLogger(__name__)

# --- GLOBAL VARS ---
downloaded_annotations = None

# Step 1: Create Export
def create_export(client, project_id, client_id, export_config):
    """Initiates an export job on the Labellerr platform."""
    logger.info("Step 1: Creating export for car dataset...")
    try:
        res = client.create_local_export(project_id, client_id, export_config)
        export_id = res["response"]["report_id"]
        logger.info(f"Export created successfully. Export ID: {export_id}")
        return export_id
    except LabellerrError as e:
        logger.error(f"Export creation failed: `{e}`")
        return None

# Step 2: Poll Export Status
def poll_export_status(client, api_key, api_secret, project_id, export_id, client_id, max_wait_time=300, wait_interval=10):
    """Polls Labellerr API for export completion status."""
    logger.info(f"Step 2: Polling for export completion (max {max_wait_time}s)...")
    elapsed_time = 0
    while elapsed_time &amp;lt; max_wait_time:
        raw_status = client.check_export_status(
            api_key=api_key,
            api_secret=api_secret,
            project_id=project_id,
            report_ids=[export_id],
            client_id=client_id
        )

        status_obj = None
        if isinstance(raw_status, dict):
            status_obj = raw_status
        elif isinstance(raw_status, str):
            try:
                status_obj = json.loads(raw_status)
            except json.JSONDecodeError:
                logger.warning(f"Could not parse status string: '{raw_status}'")

        if status_obj and status_obj.get('status') and len(status_obj['status']) &amp;gt; 0:
            export_status = status_obj['status'][0]
            is_completed = export_status.get('is_completed', False)
            export_status_text = export_status.get('export_status', 'Unknown')
            logger.info(f"Current status: '{export_status_text}' (Completed: {is_completed})")
            if is_completed:
                logger.info("Export completed! Proceeding to download.")
                return True
            elif export_status_text.lower() == "failed":
                logger.error("Export failed!")
                return False

        time.sleep(wait_interval)
        elapsed_time += wait_interval

    logger.warning(f"Export timeout after {max_wait_time}s.")
    return False

# Step 3: Download &amp;amp; Validate Export
def download_and_validate_export(client, api_key, api_secret, project_id, export_id, client_id):
    """Fetches download URL, downloads, and validates the exported data."""
    logger.info("Step 3: Fetching download URL and validating data...")
    try:
        download_uuid = str(uuid.uuid4())
        raw_download_result = client.fetch_download_url(
            api_key=api_key,
            api_secret=api_secret,
            project_id=project_id,
            uuid=download_uuid,
            export_id=export_id,
            client_id=client_id
        )

        download_obj = None
        if isinstance(raw_download_result, dict):
            download_obj = raw_download_result
        elif isinstance(raw_download_result, str):
            try:
                download_obj = json.loads(raw_download_result)
            except json.JSONDecodeError:
                logger.warning(f"Could not parse download URL string: '{raw_download_result}'")

        download_url = (
            download_obj.get('url')
            or download_obj.get('response', {}).get('download_url')
        )

        if download_url:
            logger.info("Download URL fetched successfully.")
            logger.info(f"DOWNLOAD LINK (expires in ~1 hour): {download_url}")

            exports_dir = Path("exports")
            exports_dir.mkdir(exist_ok=True)
            export_file = exports_dir / f"car_dataset_export_{export_id}.json"

            response = requests.get(download_url)
            if response.status_code == 200:
                with open(export_file, 'wb') as f:
                    f.write(response.content)
                logger.info(f"Export downloaded to {export_file}")

                # Validate JSON structure
                try:
                    json_data = json.loads(response.content)
                    annotated_count = sum(
                        1 for ann in json_data
                        if ann.get("latest_answer") and len(ann["latest_answer"]) &amp;gt; 0
                    )

                    logger.info(f"VALIDATION: {annotated_count}/{len(json_data)} images have annotations.")
                    if annotated_count == 0:
                        logger.error(" No annotations found! Please ensure images are labeled.")
                        return False
                    else:
                        logger.info("Annotation data validated successfully!")
                        return True

                except json.JSONDecodeError:
                    logger.error(" Invalid JSON format in downloaded export.")
                    return False
            else:
                logger.error(f"Failed to download export file. HTTP {response.status_code}")
                return False

        else:
            logger.error(f"No download URL found. Raw response: {raw_download_result}")
            return False

    except Exception as e:
        logger.error(f" Error during download: {e}\n{traceback.format_exc()}")
        return False


#  MAIN EXECUTION
if project_id:
    try:
        export_config = {
            "export_name": "CarDatasetExport",
            "export_description": "Export of all annotated car images",
            "export_format": "json",
            "statuses": ['review', 'r_assigned', 'client_review', 'cr_assigned', 'accepted'],
            "export_destination": "local",
            "question_ids": ["all"]
        }

        export_id = create_export(client, project_id, LABELLERR_CLIENT_ID, export_config)

        if export_id:
            if poll_export_status(client, LABELLERR_API_KEY, LABELLERR_API_SECRET, project_id, export_id, LABELLERR_CLIENT_ID):
                download_and_validate_export(client, LABELLERR_API_KEY, LABELLERR_API_SECRET, project_id, export_id, LABELLERR_CLIENT_ID)

    except Exception as e:
        logger.error(f" Unexpected error in main block: {e}\n{traceback.format_exc()}")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What Each Part Does:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Block / Line&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;logging.basicConfig(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows clean, timestamped logs in console&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;create_local_export(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Starts export job on Labellerr (returns &lt;code&gt;report_id&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;poll_export_status(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Re-checks export status until completed/failed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fetch_download_url(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retrieves temporary download link for export file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;requests.get(download_url)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Downloads export into &lt;code&gt;exports/*.json&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Annotation Validation&lt;/td&gt;
&lt;td&gt;Confirms labeled data actually exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;statuses=[...]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Controls which workflow stages to include in export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;question_ids=["all"]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ensures all annotation question categories are exported&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 12: Installing YOLOv8 (Ultralytics)
&lt;/h3&gt;

&lt;p&gt;Before we start training our object detection model, we need to install Ultralytics, which contains YOLOv8.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;!&lt;/span&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; pip &lt;span class="nb"&gt;install &lt;/span&gt;ultralytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 13: Convert Labellerr Export (JSON) → YOLOv8 Dataset + Train/Val Split
&lt;/h3&gt;

&lt;p&gt;Labellerr exports annotations in JSON format, but YOLOv8 requires images and labels in a specific directory structure along with .txt annotation files in normalized YOLO format (class x_center y_center width height).&lt;/p&gt;

&lt;p&gt;In this step, we will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load the exported JSON file&lt;/li&gt;
&lt;li&gt;Split the dataset into train and val sets&lt;/li&gt;
&lt;li&gt;Convert bounding boxes into YOLO normalized coordinates&lt;/li&gt;
&lt;li&gt;Copy images to the correct folders&lt;/li&gt;
&lt;li&gt;Create annotation .txt files
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json, shutil, random
from pathlib import Path
from sklearn.model_selection import train_test_split

# --- Paths ---
EXPORT_FILE = Path("/content/exports/car_dataset_export_NfKqUBdOqPEz2HPfnSw4.json")
IMAGE_SOURCE_DIR = Path("/content/sample_images")  # your 10 images here
YOLO_DATA_DIR = Path("/content/yolo_Car_dataset")

# --- Classes ---
CLASS_NAMES = ["Car", "License Plate"]
CLASS_MAP = {name: i for i, name in enumerate(CLASS_NAMES)}

# --- Reset dataset folder ---
if YOLO_DATA_DIR.exists():
    shutil.rmtree(YOLO_DATA_DIR)

for split in ["train", "val"]:
    (YOLO_DATA_DIR / "images" / split).mkdir(parents=True, exist_ok=True)
    (YOLO_DATA_DIR / "labels" / split).mkdir(parents=True, exist_ok=True)

# --- Load JSON ---
with open(EXPORT_FILE, "r") as f:
    data = json.load(f)

print(f"Loaded {len(data)} items")

# --- Split Train/Val ---
train_data, val_data = train_test_split(data, test_size=0.2, random_state=42)

def convert_and_save(items, split):
    for item in items:
        file_name = item["file_name"]
        width = item["file_metadata"]["image_width"]
        height = item["file_metadata"]["image_height"]

        # Copy image
        src = IMAGE_SOURCE_DIR / file_name
        dst = YOLO_DATA_DIR / "images" / split / file_name
        if src.exists():
            shutil.copy(src, dst)
        else:
            print(f" Missing image: {src}")
            continue

        # Prepare label file
        label_path = YOLO_DATA_DIR / "labels" / split / f"{Path(file_name).stem}.txt"
        lines = []

        for ans_group in item.get("latest_answer", []):
            for ann in ans_group.get("answer", []):
                label = ann.get("label")
                if label not in CLASS_MAP:
                    continue
                cls_id = CLASS_MAP[label]
                bbox = ann["answer"]

                # YOLO normalized format
                x_center = ((bbox["xmin"] + bbox["xmax"]) / 2) / width
                y_center = ((bbox["ymin"] + bbox["ymax"]) / 2) / height
                w = (bbox["xmax"] - bbox["xmin"]) / width
                h = (bbox["ymax"] - bbox["ymin"]) / height

                lines.append(f"{cls_id} {x_center:.6f} {y_center:.6f} {w:.6f} {h:.6f}")

        with open(label_path, "w") as f:
            f.write("\n".join(lines))

# --- Run conversion ---
convert_and_save(train_data, "train")
convert_and_save(val_data, "val")

print("\n YOLO dataset structure created successfully at:", YOLO_DATA_DIR)
print("Classes:", CLASS_MAP)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  What This Script Does
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Explanation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Load JSON export&lt;/td&gt;
&lt;td&gt;Reads annotation and metadata from Labellerr&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Define class mapping&lt;/td&gt;
&lt;td&gt;Assigns each object category a numerical class ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Create &lt;code&gt;/images/&lt;/code&gt; and &lt;code&gt;/labels/&lt;/code&gt; folders&lt;/td&gt;
&lt;td&gt;Matches the expected YOLO dataset layout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Split data into train &amp;amp; val&lt;/td&gt;
&lt;td&gt;Ensures proper supervised learning workflow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Copy images to destination folders&lt;/td&gt;
&lt;td&gt;Prepares dataset structure for YOLO&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Convert bounding boxes → YOLO format&lt;/td&gt;
&lt;td&gt;Normalizes coordinates between 0–1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Write &lt;code&gt;.txt&lt;/code&gt; annotation files&lt;/td&gt;
&lt;td&gt;YOLO uses one annotation text file per image&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Resulting Dataset Structure&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yolo_Car_dataset/
 ├─ images/
 │   ├─ train/
 │   └─ val/
 └─ labels/
     ├─ train/
     └─ val/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 14: Convert Labellerr Annotations → YOLOv8 Labels (Function)
&lt;/h3&gt;

&lt;p&gt;This helper converts Labellerr’s JSON annotations into YOLO normalized TXT labels and copies images into the correct split folders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def convert_labellerr_to_yolo(data, split):
    """Converts Labellerr bounding box annotations to YOLO format."""
    for ann in data:
        image_name = ann.get("file_name")
        image_width = ann.get("file_metadata", {}).get("image_width", 1)
        image_height = ann.get("file_metadata", {}).get("image_height", 1)

        # Copy image
        source_image_path = IMAGE_SOURCE_DIR / image_name
        dest_image_path = YOLO_DATA_DIR / "images" / split / image_name
        if source_image_path.exists():
            shutil.copy2(source_image_path, dest_image_path)
        else:
            print(f"Warning: Source image not found: {source_image_path}")
            continue

        # Label file path
        label_path = YOLO_DATA_DIR / "labels" / split / f"{Path(image_name).stem}.txt"

        with open(label_path, "w") as f:
            for qa in ann.get("latest_answer", []):  # iterate over each question (Car, License Plate, etc.)
                for ans in qa.get("answer", []):     # iterate over each bounding box inside that question
                    class_name = ans.get("label")
                    if class_name not in CLASS_MAP:
                        continue

                    class_id = CLASS_MAP[class_name]
                    box = ans.get("answer", {})

                    if not all(k in box for k in ["xmin", "ymin", "xmax", "ymax"]):
                        continue

                    xmin, ymin, xmax, ymax = (
                        float(box["xmin"]),
                        float(box["ymin"]),
                        float(box["xmax"]),
                        float(box["ymax"]),
                    )

                    # Convert to YOLO normalized format
                    x_center = ((xmin + xmax) / 2) / image_width
                    y_center = ((ymin + ymax) / 2) / image_height
                    width = (xmax - xmin) / image_width
                    height = (ymax - ymin) / image_height

                    f.write(f"{class_id} {x_center:.6f} {y_center:.6f} {width:.6f} {height:.6f}\n")

        # Check for empty file
        if label_path.stat().st_size == 0:
            print(f"Warning: Empty label file -&amp;gt; {label_path.name}")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  What This Function Does
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List of Labellerr JSON items (one per image)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;split&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Either &lt;code&gt;"train"&lt;/code&gt; or &lt;code&gt;"val"&lt;/code&gt;; controls which folder images &amp;amp; labels go into&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy image → &lt;code&gt;images/split/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Places each image inside YOLO dataset structure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create TXT → &lt;code&gt;labels/split/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Creates YOLO annotation files matching each image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;CLASS_MAP&lt;/code&gt; mapping&lt;/td&gt;
&lt;td&gt;Converts class names like &lt;code&gt;"Car"&lt;/code&gt; into numeric YOLO class IDs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Normalize bbox&lt;/td&gt;
&lt;td&gt;Converts bounding box to YOLO normalized format (&lt;code&gt;x_center y_center width height&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Empty label warning&lt;/td&gt;
&lt;td&gt;Alerts when an image has no valid annotations (good for debugging)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Step 15: Creating dataset.yaml for YOLOv8
&lt;/h3&gt;

&lt;p&gt;YOLOv8 needs a dataset.yaml file that tells it where the images &amp;amp; labels are located and which classes the model will learn.&lt;br&gt;
The script below automatically generates it based on your dataset folder and class mapping.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import yaml
from pathlib import Path # Added import
from IPython.display import display, Markdown # Added import

# Define the dataset configuration
yaml_content = {
    'path': str(YOLO_DATA_DIR.resolve()), # The absolute path to the dataset directory
    'train': 'images/train',             # Path to training images (relative to 'path')
    'val': 'images/val',                 # Path to validation images (relative to 'path')
    'names': {v: k for k, v in CLASS_MAP.items()} # Class names map (e.g., {0: 'Ripe Banana', 1: 'Unripe Banana'})
}

# Write the configuration to a file
yaml_file = YOLO_DATA_DIR / "dataset.yaml"
with open(yaml_file, 'w') as f:
    yaml.dump(yaml_content, f, default_flow_style=False, sort_keys=False)

print(f"Created dataset configuration at '{yaml_file}'")
print("\n--- dataset.yaml content ---")
print(yaml.dump(yaml_content, sort_keys=False))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Understanding the &lt;code&gt;dataset.yaml&lt;/code&gt; Fields
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;path&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Root directory of the YOLO dataset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;train&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Folder containing training images (relative to &lt;code&gt;path&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;val&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Folder containing validation images (relative to &lt;code&gt;path&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;names&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Class index → Class name dictionary used by YOLO during training&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example dataset.yaml (Generated Output)&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Created dataset configuration at '/content/yolo_Car_dataset/dataset.yaml'&lt;br&gt;
--- dataset.yaml content ---&lt;br&gt;
path: /content/yolo_Car_dataset&lt;br&gt;
train: images/train&lt;br&gt;
val: images/val&lt;br&gt;
names:&lt;br&gt;
  0: Car&lt;br&gt;
  1: License Plate&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Step 16: Training YOLOv8 on Our Dataset
&lt;/h3&gt;

&lt;p&gt;Now that our dataset is structured and the dataset.yaml file is ready, we can train a YOLOv8 model.&lt;br&gt;
Here, we use YOLOv8m (medium variant) for better accuracy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ultralytics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;YOLO&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;

&lt;span class="c1"&gt;# Load medium model for better accuracy
&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;YOLO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yolov8m.pt&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;train&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yaml_file&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;   &lt;span class="c1"&gt;# Path to your dataset YAML
&lt;/span&gt;    &lt;span class="n"&gt;epochs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;            &lt;span class="c1"&gt;# Increase training epochs for better learning
&lt;/span&gt;    &lt;span class="n"&gt;imgsz&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;640&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;freeze&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;car_license_training&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;yolov8m_finetuned&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt; YOLOv8m Object Detection Training Complete!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What This Code Does&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;YOLO('yolov8m.pt')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Loads the YOLOv8 Medium model (balanced accuracy &amp;amp; speed)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data=str(yaml_file)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses the dataset YAML we generated earlier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;epochs=100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Number of training cycles (higher = better accuracy)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;imgsz=640&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Input image resolution (default recommended for YOLOv8)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;batch=4&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Number of images processed per training step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;freeze=0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows full fine-tuning of entire model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;project=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Folder where training logs &amp;amp; weights are stored&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;name=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Name of the trained model checkpoint subfolder&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;** Tip**&lt;/p&gt;

&lt;p&gt;To get higher accuracy, you may later increase:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;epochs = 150 or 200&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Step 17: Inference: Test the Trained YOLOv8 Model on Validation Images
&lt;/h3&gt;

&lt;p&gt;Now that training is complete, let’s load the best weights and run inference on a few validation images.&lt;br&gt;
We’ll draw colored boxes: green for license plates, yellow for cars.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ultralytics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;YOLO&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;IPython.display&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Markdown&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;PIL&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="c1"&gt;# Load best weights
&lt;/span&gt;&lt;span class="n"&gt;best_weights&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/content/car_license_training/yolov8m_finetuned/weights/best.pt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;best_weights&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;infer_model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;YOLO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;best_weights&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Using best weights: `&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;best_weights&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;`&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;FileNotFoundError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; best.pt not found!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Load validation images
&lt;/span&gt;&lt;span class="n"&gt;val_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/content/yolo_Car_dataset/images/val&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;test_images&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;val_dir&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suffix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.jpg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.jpeg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}][:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;test_images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;FileNotFoundError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No validation images found.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Inference
&lt;/span&gt;&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;###  Running inference with lower confidence (0.10)...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;img_path&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;test_images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;preds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;infer_model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_path&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;imgsz&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;640&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;preds&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_path&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; Could not read image: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;img_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;box&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;boxes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xyxy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;cls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;conf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;class_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;infer_model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;class_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

        &lt;span class="c1"&gt;#  Color code
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;class_name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;license plate&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;plate&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
            &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# Green for license plate
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Yellow for car
&lt;/span&gt;
        &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;putText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FONT_HERSHEY_SIMPLEX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;img_rgb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cvtColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;COLOR_BGR2RGB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img_rgb&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Inference complete  check if license plates appear now!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  What This Inference Code Does
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Load &lt;code&gt;best.pt&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Uses the best checkpoint from training for inference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Collect validation images&lt;/td&gt;
&lt;td&gt;Selects sample images to test predictions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;infer_model.predict(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs YOLOv8 inference on each image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Draw bounding boxes + confidence scores&lt;/td&gt;
&lt;td&gt;Visualizes detection results clearly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Color coding&lt;/td&gt;
&lt;td&gt;Green = License Plate, Yellow = Car&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Display results inline&lt;/td&gt;
&lt;td&gt;Shows final annotated images directly in notebook/output&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Expected Output&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using&lt;br&gt;
 best weights: /content/car_license_training/yolov8m_finetuned/weights/best.pt&lt;br&gt;
Running inference with lower confidence (0.10)...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9lkx9f2ynhj5uluy13i9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9lkx9f2ynhj5uluy13i9.png" alt=" " width="400" height="253"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Google Colab Notebook
&lt;/h3&gt;

&lt;p&gt;Run the full workflow, experiment with the dataset, or retrain the model:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://colab.research.google.com/drive/1KmontQoTchCJ9oqqGeBaZ0mxCD4eVZTU#scrollTo=2SdNLRuRVLDt" rel="noopener noreferrer"&gt;https://colab.research.google.com/drive/1KmontQoTchCJ9oqqGeBaZ0mxCD4eVZTU#scrollTo=2SdNLRuRVLDt&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Thanks for reading! If you found this helpful, feel free to connect or leave feedback&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>deeplearning</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🧠 Behind the Scenes of ClarityCare.AI: CAMEL-AI Toolkits That Power Your AI Wellness Companion</title>
      <dc:creator>Tushar Singh</dc:creator>
      <pubDate>Fri, 20 Jun 2025 08:05:06 +0000</pubDate>
      <link>https://forem.com/_tusharrathore/behind-the-scenes-of-claritycareai-camel-ai-toolkits-that-power-your-ai-wellness-companion-4330</link>
      <guid>https://forem.com/_tusharrathore/behind-the-scenes-of-claritycareai-camel-ai-toolkits-that-power-your-ai-wellness-companion-4330</guid>
      <description>&lt;p&gt;&lt;strong&gt;ClarityCare.AI&lt;/strong&gt; &lt;em&gt;is more than just a chatbot. It's a thoughtfully crafted AI mental wellness assistant designed to promote mindfulness, manage stress, and track emotional well-being. Let’s take a deep dive into the powerful toolkits, technologies, and design patterns used in this project.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎬 Project Demo
&lt;/h2&gt;

&lt;p&gt;Here’s a quick demo of my project in action. Watch it below:&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/WIPl5YgBO-o"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧹 Core Technology Stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftql2x57c9sy4nz7kkc53.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftql2x57c9sy4nz7kkc53.jpg" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. 🤖 &lt;a href="https://www.camel-ai.org/" rel="noopener noreferrer"&gt;CAMEL-AI Agents&lt;/a&gt; + &lt;a href="https://mistral.ai/" rel="noopener noreferrer"&gt;Mistral API&lt;/a&gt; — Role-Based AI Reasoning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The centerpiece of ClarityCare.AI is its AI therapist agent. This agent is created using CAMEL-AI, a framework that specializes in role-based reasoning.&lt;br&gt;
With CAMEL-AI’s ChatAgent, we define a personal for our agent using a system_message. In this case, the agent acts like a compassionate therapist—calm, empathetic, and emotionally intelligent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔧 Agent Creation Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from camel.agents import ChatAgent
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
from camel.configs import MistralConfig

mistral_model = ModelFactory.create(
    model_platform=ModelPlatformType.MISTRAL,
    model_type=ModelType.MISTRAL_LARGE,
    model_config_dict=MistralConfig(temperature=0.7).as_dict(),
)

agent = ChatAgent(
    system_message="You are a compassionate AI therapist. Provide empathetic and helpful guidance.",
    model=mistral_model,
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This allows ClarityCare to simulate announced, context-aware, and emotionally appropriate dialogue using Mistral's LLM API.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of using CAMEL + Mistral:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Clear role definition (Therapist, Coach, Mentor, etc.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Flexible model switching (OpenAI, Mistral, Claude, etc.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Reusable agents for other domains (career coach, fitness advisor, etc.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. 🔍 SearchToolkit – Real-Time Mental Health Info&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Understanding mental health often requires current, up-to-date information. To support this, we integrate CAMEL’s SearchToolkit, which performs real-time web search using DuckDuckGo.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from camel.toolkits import SearchToolkit

def search_outside_agent(query: str) -&amp;gt; str:
    search_tool = SearchToolkit().search_duckduckgo
    return search_tool(query)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The query result is appended to the user’s message before it's sent to the LLM, improving response depth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. 🔢 Arxiv Toolkit Wrapper – Evidence-Based Mental Health Papers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The app also taps into scientific knowledge using a custom arxiv_toolkit_wrapper. This connects to Arxiv.org and fetches latest research in:&lt;/p&gt;

&lt;p&gt;Mindfulness therapy&lt;/p&gt;

&lt;p&gt;CBT (Cognitive Behavioral Therapy)&lt;/p&gt;

&lt;p&gt;Mental health tech&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from toolkits.arxiv_toolkit_wrapper import get_mental_health_papers
papers = get_mental_health_papers()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps the user informed through a science-first lens and ensures the app promotes evidence-based advice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. 📊 Mood Score Toolkit – Track Emotional Well-Being Over Time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tracking how you feel daily is crucial for emotional growth. That’s where our math_toolkit_wrapper comes in. This simple but effective tool computes a mood score from the user’s mood rating.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from toolkits.math_toolkit_wrapper import calculate_mood_score
score = calculate_mood_score([mood])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paired with a Matplotlib + Pandas graph, users can visualize trends in their emotional state, identifying:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. High-stress weeks&lt;/li&gt;
&lt;li&gt;2. Positive growth periods &lt;/li&gt;
&lt;li&gt;3. Patterns related to sleep, anxiety, or focus&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ru9aoyscqtcbdbqvayo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ru9aoyscqtcbdbqvayo.jpg" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;** Architecture Overview**&lt;/p&gt;

&lt;p&gt;app.py: Core Streamlit logic with sidebar, chat interface, and insight panels.&lt;/p&gt;

&lt;p&gt;therapist_agent.py: Handles agent creation and real-time search logic.&lt;/p&gt;

&lt;p&gt;toolkits/: Each AI utility like search, math, and arXiv research is modularized.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;claritycare-ai
├── app.py
├── therapist_agent.py
├── toolkits
│   ├── arxiv_toolkit_wrapper.py
│   ├── math_toolkit_wrapper.py
│   ├── news_toolkit_wrapper.py
│
|___ api.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This design makes it easy to scale, modify, or replace any component (e.g. swap Mistral with OpenAI).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ClarityCare.AI is a fusion of research, compassion, and AI. By integrating toolkits like CAMEL Agents, Mistral LLMs, and live search capabilities, it offers not just answers—but support, clarity, and presence.&lt;/p&gt;

&lt;p&gt;It proves that AI can be not only intelligent—but also emotionally supportive.&lt;/p&gt;

&lt;p&gt;💬 "Therapists may not be replaced—but they can be assisted by tools that help millions begin their journey to well-being."&lt;/p&gt;

</description>
    </item>
    <item>
      <title>🐪 CAMEL-AI: Architecting the Future of Autonomous Multi-Agent Collaboration with LLMs</title>
      <dc:creator>Tushar Singh</dc:creator>
      <pubDate>Tue, 27 May 2025 12:27:30 +0000</pubDate>
      <link>https://forem.com/_tusharrathore/camel-ai-architecting-the-future-of-autonomous-multi-agent-collaboration-with-llms-4cog</link>
      <guid>https://forem.com/_tusharrathore/camel-ai-architecting-the-future-of-autonomous-multi-agent-collaboration-with-llms-4cog</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;em&gt;“The next big leap in AI isn’t just about larger models—it’s about how they think, talk, and collaborate.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✨ Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the explosion of powerful large language models (LLMs) like GPT-4, Claude, and LLaMA-4, we're witnessing machines that can translate languages, write code, generate poetry, and even pass professional exams.&lt;/p&gt;

&lt;p&gt;But here’s a question:&lt;/p&gt;

&lt;p&gt;Can we build systems of agents that simulate human-like discussion, disagreement, and collaboration to solve complex tasks?&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="https://www.camel-ai.org/" rel="noopener noreferrer"&gt;CAMEL-AI&lt;/a&gt; revolutionary open-source framework that enables developers to build multi-agent AI systems where each agent plays a unique role, has its own perspective, and works together to solve a shared goal.&lt;/p&gt;

&lt;p&gt;In this deep-dive blog post, we’ll explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔍 What is CAMEL-AI?&lt;/li&gt;
&lt;li&gt;🧠 Why multi-agent reasoning matters&lt;/li&gt;
&lt;li&gt;🧱 Core architecture and components&lt;/li&gt;
&lt;li&gt;⚙️ Step-by-step implementation with code&lt;/li&gt;
&lt;li&gt;🚀 Use case: AI Legal Advisor with dual-agent deliberation&lt;/li&gt;
&lt;li&gt;📌 Best practices&lt;/li&gt;
&lt;li&gt;🔮 Real-world applications and future roadmap&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🔍 What is CAMEL-AI?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CAMEL-AI (Communicative Agents for Mindful Engagement and Learning) is a framework that brings the multi-agent paradigm to life using LLMs.&lt;/p&gt;

&lt;p&gt;It allows you to simulate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧑‍⚖️ Agent-level personalities (roles)&lt;/li&gt;
&lt;li&gt;🧠 Goal-oriented discussions&lt;/li&gt;
&lt;li&gt;🗣️ Multi-turn conversations between agents&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ Task execution with alignment and negotiation&lt;br&gt;
In CAMEL-AI:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every agent is a ChatAgent&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each message carries a role context&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conversations are orchestrated using the AgentChatManager&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The shared objective is defined through a TaskPromptTemplate&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure mirrors how real-world teams solve problems: through debate, alignment, and collaboration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wp27gv6rg16xqx6z3f8.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wp27gv6rg16xqx6z3f8.webp" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Why Multi-Agent AI Systems?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Single-agent LLMs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can hallucinate facts&lt;/li&gt;
&lt;li&gt;Lack self-reflection&lt;/li&gt;
&lt;li&gt;Often follow instructions blindly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Multi-agent systems:&lt;br&gt;
✅ Encourage disagreement and evaluation&lt;br&gt;
✅ Improve planning and reasoning&lt;br&gt;
✅ Simulate real-world role dynamics&lt;br&gt;
✅ Allow for decentralized decision-making&lt;/p&gt;

&lt;p&gt;In essence, multi-agent setups like CAMEL-AI allow LLMs to "think with others", just like humans.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvy4h3nj4j691calou734.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvy4h3nj4j691calou734.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧱 CAMEL-AI Architecture&lt;/strong&gt;&lt;br&gt;
Here’s a high-level diagram of CAMEL-AI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; ┌────────────────────┐
 │  TaskPromptTemplate│
 └────────┬───────────┘
          ↓
 ┌──────────────┐      ┌──────────────┐
 │  ChatAgent A │ ◄──► │  ChatAgent B │
 └────┬─────────┘      └────┬─────────┘
      ↓                        ↓
  Role Message A          Role Message B
     (BaseMessage)           (BaseMessage)
          ↓                        ↓
       LLM Call                LLM Call

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;📦 Installing CAMEL-AI&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install camel-ai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set your LLM provider keys (OpenAI, Groq, TogetherAI, etc.):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# .env
GROQ_API_KEY="your_api_key"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use python-dotenv to load them safely in your script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from dotenv import load_dotenv
load_dotenv()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;⚙️ Project: AI Legal Advisor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s build a CAMEL-AI system that simulates a legal assistant and a client advocate discussing a legal case and producing a summary opinion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎭 Roles&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Legal Assistant: Interprets the legal facts and provides advice&lt;/li&gt;
&lt;li&gt;Client Advocate: Represents the client’s perspective and challenges the assistant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1️⃣ Define Role Messages&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from camel.messages import BaseMessage
from camel.types import RoleType

legal_assistant_msg = BaseMessage(
    role_name="Legal Assistant",
    role_type=RoleType.ASSISTANT,
    content="You are an experienced legal advisor. Analyze the given case with reference to applicable laws and provide a professional opinion."
)

client_advocate_msg = BaseMessage(
    role_name="Client Advocate",
    role_type=RoleType.USER,
    content="You are defending the client's perspective. Your role is to challenge, clarify, and ensure the best interest of the client is protected."
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2️⃣ Define the Shared Objective&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from camel.prompts import TaskPromptTemplate

task_prompt = TaskPromptTemplate().format(
    assistant_role="Legal Assistant",
    user_role="Client Advocate",
    task="Evaluate a case where an employee was terminated for social media activity. Discuss if the firing was legal and what remedies are available."
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3️⃣ Initialize Agents&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from camel.agents import ChatAgent

assistant = ChatAgent(legal_assistant_msg)
advocate = ChatAgent(client_advocate_msg)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4️⃣ Set Up Chat Manager&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from camel.agents import AgentChatManager

chat_manager = AgentChatManager(
    agent1=assistant,
    agent2=advocate,
    task_prompt=task_prompt
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5️⃣ Simulate the Conversation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chat_messages = chat_manager.init_chat()

for step in range(8):
    result = chat_manager.step()
    chat_messages.append(result.msgs)

    print(f"\n--- Round {step + 1} ---")
    for msg in result.msgs:
        print(f"{msg.role_name}: {msg.content}")

    if result.terminated:
        print("\n✅ Final Opinion Reached.")
        break
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sample Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Round 1
Legal Assistant: Based on U.S. labor law, employers can act on public social media content...
Client Advocate: However, was the post protected under First Amendment or NLRA Section 7?
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now have a live simulation of a legal team reasoning together using LLM agents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Key Learnings&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear Role Definitions lead to more purposeful interactions.&lt;/li&gt;
&lt;li&gt;Agents that disagree and debate surface better decisions.&lt;/li&gt;
&lt;li&gt;CAMEL-AI allows fine-grained control over multi-agent dialog.&lt;/li&gt;
&lt;li&gt;Easily extendable to more agents with specialized knowledge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;💡 Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CAMEL-AI is more than just a framework—it’s a paradigm shift. We’re moving from instruction-following AIs to reasoning, negotiating, and collaborative agents that can truly scale with complexity.&lt;/p&gt;

&lt;p&gt;If you’re building AI agents for real-world use—legal, educational, healthcare, or product—you owe it to yourself to explore CAMEL-AI.&lt;/p&gt;

&lt;p&gt;“Don’t just think bigger. Think together.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧑‍💻 About the Author&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m a developer and researcher passionate about building agentic AI systems with real-world impact. I work with CAMEL-AI, RAG, Groq, Streamlit, and open-source LLMs to prototype tools that think collaboratively.&lt;/p&gt;

&lt;p&gt;📬 Reach out on &lt;a href="https://www.linkedin.com/in/tushar-singh-1ba975296/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; | 🧵 Follow on &lt;a href="https://x.com/_tusharrathore?t=TxC9YOee4HDOt3Xz1Fi0YA&amp;amp;s=08" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | ⭐ Star on &lt;a href="https://github.com/tushar80rt" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>MedAI Pro: Building an AI-Powered Medical Report Assistant Using GROQ,CAMEL-AI, and LLaMA 4</title>
      <dc:creator>Tushar Singh</dc:creator>
      <pubDate>Sun, 04 May 2025 20:53:35 +0000</pubDate>
      <link>https://forem.com/_tusharrathore/medai-pro-ai-powered-medical-report-analyzer-using-camel-ai-llama-4-groq-api-and-streamlit-p6a</link>
      <guid>https://forem.com/_tusharrathore/medai-pro-ai-powered-medical-report-analyzer-using-camel-ai-llama-4-groq-api-and-streamlit-p6a</guid>
      <description>&lt;p&gt;In today's digital health era, there's a growing need for tools that help users make sense of complex medical documents. This is where MedAI Pro comes into play — a streamlined, AI-powered assistant built with Streamlit, &lt;a href="https://www.camel-ai.org/" rel="noopener noreferrer"&gt;CAMEL-AI Agent&lt;/a&gt;, and LLaMA 4 via the &lt;a href="https://console.groq.com/home" rel="noopener noreferrer"&gt;GROQ-API&lt;/a&gt;, designed to interpret and explain PDF-based medical reports in a conversational manner.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll break down how the project works, explore the key technologies used, and guide you through how you can run or extend the app yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✨ What is MedAI Pro?&lt;/strong&gt;&lt;br&gt;
MedAI Pro is a web application where users can upload their medical reports in PDF format, ask natural language questions about the content, and receive both a written and spoken response powered by a Large Language Model.&lt;/p&gt;

&lt;p&gt;Key Features:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Upload and parse medical reports in PDF format&lt;/li&gt;
&lt;li&gt;Chat interface for asking questions&lt;/li&gt;
&lt;li&gt;Text and audio-based responses&lt;/li&gt;
&lt;li&gt;Role-based CAMEL-AI agents for contextual answers &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;🩺 Imagine this...&lt;/strong&gt; You're a doctor, student, or just someone trying to understand a lab report. You open a 50-page PDF filled with blood work, medical terms, and charts.&lt;/p&gt;

&lt;p&gt;You have one question:&lt;/p&gt;

&lt;p&gt;“Is the patient’s WBC count normal?”&lt;/p&gt;

&lt;p&gt;But you're stuck scanning through paragraphs.&lt;/p&gt;

&lt;p&gt;"Imagine asking a question and receiving the answer in just seconds—delivered seamlessly in both text and audio formats. Instant, accurate, and fully interactive!"&lt;/p&gt;

&lt;p&gt;🔥 Meet Med-AI Med-AI is a blazing-fast PDF Q&amp;amp;A assistant for medical documents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bbd1e2eju1bvyxbraq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bbd1e2eju1bvyxbraq1.png" alt="Image description" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8b1egh8afox1w2mlhmta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8b1egh8afox1w2mlhmta.png" alt="Image description" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzonihqbyl153isbh0zek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzonihqbyl153isbh0zek.png" alt="Image description" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🗂 Project Structure&lt;/strong&gt;&lt;br&gt;
Here’s what the repository contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MedAi/
├── app.py                # Streamlit frontend and orchestrator
├── camel_agents.py       # CAMEL-style agent logic with LLaMA 4 and Groq API
├── parse_report.py       # PDF parsing logic using PyMuPDF
├── requirements.txt      # All required Python packages
├── .env                  # For storing API keys securely

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🔍 Under the Hood: Code Breakdown&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;app.py:&lt;/strong&gt; The Streamlit Web Interface&lt;br&gt;
     The main UI and logic control center. It lets users upload a &lt;br&gt;
     medical PDF, input a question, and then displays (and plays) &lt;br&gt;
     the AI’s response.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Streamlit is used to create an intuitive UI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PDF Uploading: st.file_uploader() allows users to upload a PDF&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parsing: Calls parse_report.py to extract readable text&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query Handling: User question and extracted report are sent to &lt;br&gt;
camel_agents.py&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Response: Displays the model's answer and converts it to audio &lt;br&gt;
using gTTS&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;parse_report.py&lt;/strong&gt;: Extracting Text from PDF&lt;br&gt;
  This module uses PyMuPDF (fitz) to read and extract text from &lt;br&gt;
   every page of the uploaded PDF.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import fitz  # PyMuPDF

   def extract_text_from_pdf(file):
       pdf = fitz.open(stream=file.read(), filetype="pdf")
       text = "\n".join(page.get_text() for page in pdf)
       return text

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures that medical data is accurately captured for AI processing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;camel_agents.py:&lt;/strong&gt; Role-Based Prompting with CAMEL + LLaMA 4&lt;/p&gt;

&lt;p&gt;This module goes beyond traditional prompt engineering and implements a true CAMEL-style role-based agent architecture, using the official CAMEL AI structure — including:&lt;/p&gt;

&lt;p&gt;ChatAgent&lt;/p&gt;

&lt;p&gt;BaseMessage&lt;/p&gt;

&lt;p&gt;RoleTypeonse.&lt;/p&gt;

&lt;p&gt;👨‍⚕️ Role: Doctor Agent&lt;br&gt;
Instead of just using raw strings to define prompts, MedAI uses a Doctor agent object with predefined role behavior. Here's how it looks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
   doctor = ChatAgent(
    system_message=BaseMessage(
        role_name="Doctor",
        role_type=RoleType.ASSISTANT,
        content="""You are a medical expert. Analyze reports and 
                 provide concise, medically accurate answers. 
                 Focus on lab values, terminology, and 
                conditions. Be factual, not speculative."""
    )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;⚙️ Model Initialization:&lt;/strong&gt; LLaMA 4 via Groq with CAMEL’s ModelFactory&lt;/p&gt;

&lt;p&gt;The MedAI project leverages CAMEL AI’s modular model factory to connect with the latest LLaMA 4 model hosted on Groq. This is done through the ModelFactory API provided in the CAMEL agent framework.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;self.model = ModelFactory.create(
    model_platform=ModelPlatformType.GROQ,
    model_type="meta-llama/llama-4-maverick-17b-128e-instruct"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.env&lt;/strong&gt;: API Security&lt;/p&gt;

&lt;p&gt;The .env file stores your Groq API key safely. It’s loaded using python-dotenv&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   GROQ_API_KEY=your_actual_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🚀 Running the Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Clone the Repo&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/tushar80rt/MedAi
cd MedAi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2:📦 Installation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;camel-ai[all]

PyMuPDF==1.23.9

python-dotenv==1.0.1

streamlit

gTTS==2.5.1

groq

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Install Dependencies&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Add Your API Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a .env file with your Groq key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GROQ_API_KEY=your_api_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4: Run the App&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;a href="http://localhost:8501" rel="noopener noreferrer"&gt;http://localhost:8501&lt;/a&gt;, upload a report, and start asking questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌐 Tech Stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Frontend: Streamlit&lt;/p&gt;

&lt;p&gt;PDF Parsing: PyMuPDF&lt;/p&gt;

&lt;p&gt;LLM: LLaMA 4 via Groq API&lt;/p&gt;

&lt;p&gt;Prompting Strategy: CAMEL AI-style agents&lt;/p&gt;

&lt;p&gt;Audio Output: gTTS&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🙌 Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MedAI Pro is a powerful yet minimalistic prototype that combines the power of modern LLMs, voice output, and agent-style prompting to deliver valuable insights from medical reports. By leveraging the CAMEL AI architecture and Groq-hosted LLaMA 4, it sets a strong foundation for future intelligent healthcare tools.&lt;/p&gt;

&lt;p&gt;Fork it, run it, and build something impactful.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/tushar80rt/MedAi" rel="noopener noreferrer"&gt;https://github.com/tushar80rt/MedAi&lt;/a&gt;&lt;br&gt;
Author: Tushar Singh&lt;/p&gt;

&lt;p&gt;Have questions or suggestions? Drop a comment or open an issue!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
