<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rishi Kumar Soni on Medium]]></title>
        <description><![CDATA[Stories by Rishi Kumar Soni on Medium]]></description>
        <link>https://medium.com/@devtherishi?source=rss-dd92d7660b99------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3hAKbOp38_TaCkmL</url>
            <title>Stories by Rishi Kumar Soni on Medium</title>
            <link>https://medium.com/@devtherishi?source=rss-dd92d7660b99------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 16:12:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@devtherishi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Test a RF-DETR based Object Detection Model]]></title>
            <link>https://medium.com/@devtherishi/how-to-test-a-rf-detr-based-object-detection-model-4beb97073dd2?source=rss-dd92d7660b99------2</link>
            <guid isPermaLink="false">https://medium.com/p/4beb97073dd2</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[detection-transformer]]></category>
            <category><![CDATA[roboflow]]></category>
            <category><![CDATA[rf-detr]]></category>
            <category><![CDATA[object-detection]]></category>
            <dc:creator><![CDATA[Rishi Kumar Soni]]></dc:creator>
            <pubDate>Thu, 22 Jan 2026 05:47:16 GMT</pubDate>
            <atom:updated>2026-01-22T05:47:16.742Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is a continuation of my previous article on how to train a RF-DETR based object detection model, check <a href="https://medium.com/@devtherishi/how-to-train-a-rf-detr-based-object-detection-model-e6e812c08689"><strong><em>here</em></strong></a>.</p><p>This article will walk you through the testing part your custom trained RF-DETR model.</p><p>There are 4 main parts to this:</p><ol><li><strong>openCV</strong>: To read the images</li><li><strong>supervision: </strong>To draw annotations around the prediction/inference.</li><li><strong>rfdetr: </strong>To use the the weights of the trained model</li></ol><p>The code to perform inference/testing on images(present in a folder) is give below:</p><pre>from rfdetr import RFDETRBase<br>import supervision as sv<br>import os<br>import cv2<br> <br>model = RFDETRBase(pretrain_weights = &quot;/output/checkpoint_best_total.pth&quot;)<br><br># assign id and name in the same order as in training data (check _annotations.coco.json)<br>categories= [<br>        {&quot;id&quot;: 0,&quot;name&quot;: &quot;parrot&quot;,&quot;supercategory&quot;: &quot;bird&quot;},<br>        {&quot;id&quot;: 1,&quot;name&quot;: &quot;swan&quot;,&quot;supercategory&quot;: &quot;bird&quot;},<br>        {&quot;id&quot;: 2,&quot;name&quot;: &quot;sparrow&quot;,&quot;supercategory&quot;: &quot;bird&quot;},<br>]<br><br># use absolute path<br>SOURCE_IMAGE_DIR = &quot;input folder path containing images&quot;<br>TARGET_IMAGE_DIR = &quot;output folder path to saved inference result&quot;<br><br># supervision for annotations<br>box_annotator = sv.BoxAnnotator()<br>label_annotator = sv.LabelAnnotator()<br><br># get all image path<br>image_paths = sv.list_files_with_extensions(<br>    directory=SOURCE_IMAGE_DIR, <br>    extensions=[&quot;jpg&quot;, &quot;jpeg&quot;, &quot;png&quot;]<br>)<br><br># 3. Create a sink to save processed images<br>with sv.ImageSink(target_dir_path=TARGET_IMAGE_DIR, overwrite=True) as sink:<br>    for image_path in image_paths:<br><br>        frame = cv2.imread(image_path)<br>        if frame is None:<br>            continue<br>            <br>        annotated_frame = frame.copy()<br><br>        detections = model.predict(annotated_frame, threshold=0.5)<br><br>        labels = [<br>            f&quot;{categories[class_id][&#39;name&#39;]} {confidence:.2f}&quot;<br>            for class_id, confidence in zip(detections.class_id, detections.confidence)<br>        ]<br><br>        annotated_frame = box_annotator.annotate(scene=annotated_frame, detections=detections)<br>        annotated_frame = label_annotator.annotate(scene=annotated_frame, detections=detections, labels=labels)<br><br>        image_name = os.path.basename(image_path)<br>        sink.save_image(image=annotated_frame, image_name=image_name)<br><br>print(f&quot;Processed {len(image_paths)} images. Results saved to {TARGET_IMAGE_DIR}&quot;)</pre><p>This code will pick images from SOURCE_IMAGE_DIR, detect objects with more than 50% confidence, annotate and save them into TARGET_IMAGE_DIR folders.</p><p>I hope you find this article helpful. If you have any questions, you can ask through comments/email. Connect at <a href="https://www.linkedin.com/in/rishikumarsoni/"><strong><em>https://www.linkedin.com/in/rishikumarsoni/</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4beb97073dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to train a RF-DETR based Object Detection Model]]></title>
            <link>https://medium.com/@devtherishi/how-to-train-a-rf-detr-based-object-detection-model-e6e812c08689?source=rss-dd92d7660b99------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6e812c08689</guid>
            <category><![CDATA[roboflow]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[rf-detr]]></category>
            <category><![CDATA[detection-transformer]]></category>
            <category><![CDATA[real-time-detection]]></category>
            <dc:creator><![CDATA[Rishi Kumar Soni]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 11:20:04 GMT</pubDate>
            <atom:updated>2026-01-20T11:20:04.900Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous article the file structure of dataset is explained, check <a href="https://medium.com/@devtherishi/how-to-arrange-data-for-rf-detr-model-training-ddc0fe1653e8"><strong><em>here</em></strong></a>.</p><p>This article is about how to get started with RF-DETR. To start you first need to install some python libraries in your local computer. I suggest you to create a conda environment and install</p><pre>pip install roboflow rfdetr</pre><p>Roboflow and rdfetr are the two must have libraries to have. After installing them use the below code to <strong>train </strong>the RT-DETR detection model</p><pre>from rfdetr import RFDETRBase<br><br>model = RFDETRBase()<br><br>model.train(<br>    dataset_dir=&quot;PATH OF THE DATASET DIRECTORY&quot;,<br>    epochs=100,<br>    batch_size=4,<br>    grad_accum_steps=4,<br>    lr=1e-4,<br>    output_dir=&quot;PATH OF OUTPUT FOLDER&quot;,<br>    device=&quot;cuda&quot;,<br>)</pre><p>There are 22 different input parameters of RT-DETR that you can control and to save that hassle I suggest you to get started with the above code.</p><p>By changing only three parameters one can run the training code — just change the <em>datatset_dir </em>with the path of your dataset, <em>output_dir</em> where it will store the final model weights and also mention which <em>device </em>to use if you have an nvidia-gpu put device=”cuda” else use device=”cpu”.</p><p>Change other parameters as per your hardware and learn about other parameters from the official website <a href="https://rfdetr.roboflow.com/learn/train/"><strong><em>here</em></strong></a>.</p><p>After the training is complete the <em>output_dir </em>will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*piKNy4NbgcWrzx8WxR_fnw.png" /><figcaption>output_dir</figcaption></figure><p>The below is the short explanation of different files/folders created after training</p><ol><li><strong>checkpoint_best_ema.pth:</strong> best checkpoint based on validation score, using the EMA (Exponential Moving Average) weights. EMA weights are a smoothed version of the model’s parameters across training steps, often yielding better generalization.</li><li><strong>checkpoint_best_regular.pth: </strong>best checkpoint based on validation score, using the raw (non-EMA) model weights.</li><li><strong>checkpoint_best_total.pth:</strong> final checkpoint selected for inference and benchmarking. It contains only the model weights (no optimizer state or scheduler) and is chosen as the better of the EMA and non-EMA models based on validation performance.</li><li><strong>checkpoint.pth: </strong>the most recent checkpoint, saved at the end of the latest epoch.</li><li><strong>checkpoint_&lt;number&gt;.pth</strong> — periodic checkpoints saved every N epochs (default is every 10).</li><li><strong>log.txt: </strong>It contains the hyperparameter, network-layer, performance, gain/losses, and result information at every epoch.</li><li><strong>metrics_plot.png: </strong>It contains 4 plots of with respect to epochs. These are Training/Validation loss, mean Average Precision 50(mAP50), mean Average Precision 50–90(mAP50–90), mean Average Recall 50–90.</li><li><strong>results.json:</strong> It contains the overall precision, recall, mean average precision(mAP) and class wise<strong><em> </em>precision</strong>, <strong>recall</strong>, <strong>map@50</strong>, <strong>map@50:95</strong></li></ol><p>That is all for a short introduction on training an RF-DETR model. Have questions, comment below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6e812c08689" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to arrange Data for RF-DETR model training]]></title>
            <link>https://medium.com/@devtherishi/how-to-arrange-data-for-rf-detr-model-training-ddc0fe1653e8?source=rss-dd92d7660b99------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddc0fe1653e8</guid>
            <category><![CDATA[detr]]></category>
            <category><![CDATA[rf-detr]]></category>
            <category><![CDATA[detection]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[roboflow]]></category>
            <dc:creator><![CDATA[Rishi Kumar Soni]]></dc:creator>
            <pubDate>Fri, 16 Jan 2026 11:58:49 GMT</pubDate>
            <atom:updated>2026-01-16T11:58:49.162Z</atom:updated>
            <content:encoded><![CDATA[<p>To make a detection transformer using roboflow’s RF-DETR, the data should be arranged in the below format</p><pre>project_name/<br>├── dataset/<br>│   ├── train/<br>│   │   ├── image1.jpg<br>│   │   ├── image2.jpg<br>│   │   ├── image3.jpg<br>│   │   ├── ...         <br>│   │   └── _annotations.coco.json<br>│   ├── valid/<br>│   │   ├── image4.jpg<br>│   │   ├── image5.jpg<br>│   │   ├── image6.jpg             <br>│   │   ├── ...                        <br>│   │   └── _annotations.coco.json     <br>│   ├── test/<br>│   │   ├── image4.jpg<br>│   │   ├── image5.jpg<br>│   │   ├── image6.jpg             <br>│   │   ├── ...                        <br>│   │   └── _annotations.coco.json</pre><p>Keep the below points in mind:</p><ol><li>name folders as train, valid and test. Any other name might cause error.</li><li>train, test and valid all three folders are compulsory</li><li>the annotations should be in coco format(as described below) and the name of each annotation file must be <em>_annotations.coco.json</em></li><li>The <em>supercategory </em>must be present in the annotation file(open your annotation in <em>vscode </em>and search <em>supercategory </em>using ctrl+F)</li></ol><p>The below is the desired format of the annotation which is also known as coco format</p><pre>{<br>    &quot;info&quot;: {<br>        &quot;description&quot;: &quot;My Small Dataset&quot;,<br>        &quot;url&quot;: &quot;http://example.com&quot;,<br>        &quot;version&quot;: &quot;1.0&quot;,<br>        &quot;year&quot;: 2024,<br>        &quot;contributor&quot;: &quot;AI Explorer&quot;,<br>        &quot;date_created&quot;: &quot;2024-05-20&quot;<br>    },<br>    &quot;licenses&quot;: [<br>        {<br>            &quot;id&quot;: 1,<br>            &quot;name&quot;: &quot;CC BY-NC 4.0&quot;,<br>            &quot;url&quot;: &quot;https://creativecommons.org/licenses/by-nc/4.0/&quot;<br>        }<br>    ],<br>    &quot;categories&quot;: [<br>        {<br>            &quot;id&quot;: 1,<br>            &quot;name&quot;: &quot;dog&quot;,<br>            &quot;supercategory&quot;: &quot;animal&quot;<br>        },<br>        {<br>            &quot;id&quot;: 2,<br>            &quot;name&quot;: &quot;ball&quot;,<br>            &quot;supercategory&quot;: &quot;sports&quot;<br>        }<br>    ],<br>    &quot;images&quot;: [<br>        {<br>            &quot;id&quot;: 1,<br>            &quot;file_name&quot;: &quot;image1.jpg&quot;,<br>            &quot;width&quot;: 640,<br>            &quot;height&quot;: 480,<br>            &quot;date_captured&quot;: &quot;2024-05-20&quot;<br>        }<br>    ],<br>    &quot;annotations&quot;: [<br>        {<br>            &quot;id&quot;: 1,<br>            &quot;image_id&quot;: 1,<br>            &quot;category_id&quot;: 1,<br>            &quot;segmentation&quot;: [[100, 150, 200, 150, 200, 250, 100, 250]],<br>            &quot;area&quot;: 10000.0,<br>            &quot;bbox&quot;: [100, 150, 100, 100],<br>            &quot;iscrowd&quot;: 0<br>        }<br>    ]<br>}</pre><p>If you find this helpful then helpful then comment something. For more clarification you can email me</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddc0fe1653e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>