<?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 Gerald Anthony Cabansag on Medium]]></title>
        <description><![CDATA[Stories by Gerald Anthony Cabansag on Medium]]></description>
        <link>https://medium.com/@xanthophile10?source=rss-390772f43c2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2ymzNX5KBVbcG_Ok</url>
            <title>Stories by Gerald Anthony Cabansag on Medium</title>
            <link>https://medium.com/@xanthophile10?source=rss-390772f43c2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 23:46:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xanthophile10/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[Revolutionizing Tumor Detection with AI: A New Era for Medical Imaging]]></title>
            <link>https://medium.com/@xanthophile10/revolutionizing-tumor-detection-with-ai-a-new-era-for-medical-imaging-e46d9fbbd30e?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e46d9fbbd30e</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[medical]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Fri, 14 Feb 2025 01:11:43 GMT</pubDate>
            <atom:updated>2025-02-14T01:11:43.158Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpT-A6iS1rIz81LWy7rcfA.jpeg" /></figure><p>Imagine a world where diagnosing brain tumors is not only faster and more precise but also accessible to everyone — regardless of where they live. This isn’t just a vision for the future; it’s happening now.</p><p>With cutting-edge computer vision technology, MRI scans can be analyzed in seconds by deep learning models capable of identifying meningiomas with extraordinary accuracy. What once took hours of meticulous review by radiologists can now be accelerated using AI — helping doctors make life-saving decisions faster than ever before.</p><h3>The Power Behind the Innovation</h3><p>At the heart of this breakthrough is <strong>YOLOv11 Instant Segmentation</strong>, one of the most advanced AI models in medical imaging. Running on a <strong>Tesla T4 Tensor Core GPU</strong>, this model was trained in just three hours using a dataset of <strong>10,000 expertly annotated MRI images</strong>. The result? A system that can detect tumors with remarkable speed and precision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gzcGpU0-CYtoloTXh3WOwg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TI1sARAI_wOZoqGCRAMvLw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0wAaVdq7LOsKj5ffQSZIA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJ1GIESElFVfa9w2y6MS1g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ePmHYW7ZZjw8Vg9KRiF69Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ka4CPvyMBER0slFazvX7UA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgd8MWLy3GsDP_5PKBfxiw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMhG7EDh5RRv_Xy39B5oLA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFIOEIxU_APyC7MH35CcXg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8ibgeZ7HVdtFYG90TKT3Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D-SKR-2Z0SDZ9z9Uvby6mw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpT-A6iS1rIz81LWy7rcfA.jpeg" /></figure><h3>What Makes This Technology a Game-Changer?</h3><p>🔍 <strong>Pinpointing Tumors with Precision</strong><br>The AI highlights suspected tumors using blue bounding boxes, giving radiologists an exact location to focus on. No more second-guessing — just clear, actionable insights.</p><p>📊 <strong>Confidence Scores for Smarter Decisions</strong><br>Each detection comes with a confidence score like <strong>“tumor 0.9”</strong>, showing how certain the AI is about its findings. This extra layer of support helps doctors make informed choices, especially in complex cases.</p><p>👀 <strong>A 360° Perspective on Every Scan</strong><br>By analyzing MRI images from multiple angles — top-down, side, and front — the system ensures no potential tumor goes unnoticed. This comprehensive view makes diagnoses more <strong>reliable and thorough</strong>.</p><h3>Why This Matters</h3><p>⏳ <strong>Early Detection Saves Lives</strong><br>Catching tumors at their earliest stages can mean the difference between successful treatment and missed opportunities. AI-powered detection helps doctors intervene sooner — when it matters most.</p><p>🩺 <strong>Easing the Burden on Radiologists</strong><br>Radiologists work tirelessly to diagnose and treat patients, but human fatigue can lead to oversight. AI doesn’t replace doctors — it assists them, reducing workload and improving accuracy.</p><p>🌍 <strong>Bringing Expert Care to Underserved Areas</strong><br>Not every hospital has a team of specialized radiologists. AI-powered tools can <strong>bridge the healthcare gap</strong>, ensuring people in remote and underserved communities have access to high-quality diagnostics.</p><h3>The Future of AI in Medicine</h3><p>This is just the beginning. To refine this technology, AI developers and medical professionals must continue working together — reducing false positives, expanding detection to more tumor types, and improving adaptability to different scan qualities.</p><p>More than just making healthcare <strong>faster</strong>, this innovation makes it <strong>fairer</strong>. It ensures <strong>no one is left behind</strong> in the fight against diseases like brain tumors. By integrating AI into medical workflows, we’re not just building smarter systems — we’re building a <strong>more compassionate</strong> and <strong>inclusive</strong> future for healthcare.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e46d9fbbd30e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revolutionizing Agriculture with AI: From Apples to Tomatoes and Beyond]]></title>
            <link>https://medium.com/@xanthophile10/revolutionizing-agriculture-with-ai-from-apples-to-tomatoes-and-beyond-df3e37e64797?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/df3e37e64797</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Sun, 05 Jan 2025 19:34:59 GMT</pubDate>
            <atom:updated>2025-01-05T19:34:59.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uD8CgxIXNtUJcrT3" /><figcaption>The image before being processed by AI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A9SiQ2_1gTgtDOyD" /><figcaption>The image after being processed by AI.</figcaption></figure><p>Agriculture has always been essential to human progress, providing the food that sustains us. Yet, as the world faces growing challenges — from climate change to a rising global population — the need for smarter, more efficient farming practices has never been more urgent. This is where <strong>AI</strong> and <strong>computer vision</strong> come in, transforming the way we approach farming and revolutionizing the industry. Whether it’s predicting yields, detecting diseases, or optimizing resources, AI is at the forefront of a new agricultural revolution.</p><h3>How AI and Computer Vision Are Changing the Landscape of Farming</h3><p>In the past, farming was a labor-intensive process, often relying on manual work and intuition. But now, thanks to <strong>AI-powered computer vision</strong>, farming has entered a new era. AI technologies are helping farmers make smarter decisions, reduce waste, increase productivity, and build a more sustainable future for agriculture.</p><p>Here’s a look at some of the key ways AI is making an impact across various crops:</p><h3>1. Smarter Crop Monitoring and Yield Prediction</h3><p>AI is transforming how farmers monitor the health of their crops. Using drones, sensors, and cameras, AI can continuously scan fields to detect problems like diseases, pests, or nutrient deficiencies. This real-time data helps farmers make informed decisions about how to care for their crops and when to harvest them.</p><p>For instance, AI models can analyze images from an apple orchard to determine exactly how many apples are growing and estimate the yield with remarkable accuracy. Similarly, <strong>tomato farmers</strong> can use AI to detect <strong>Early Blight</strong>, a fungal disease that shows up as dark spots on leaves. Early detection is critical, as it prevents the disease from spreading and affecting the entire crop.</p><ul><li><strong>Better Yield Predictions</strong>: AI systems process visual data and historical trends to provide accurate yield predictions, helping farmers prepare for harvest and plan their resources more effectively.</li><li><strong>Resource Efficiency</strong>: AI helps optimize the use of water, fertilizers, and pesticides, reducing waste and ensuring that only the areas that need attention are treated. For example, AI can detect which sections of a field need irrigation, preventing overuse and ensuring crops receive the right amount of water.</li></ul><h3>2. Automated Disease and Pest Detection</h3><p>Crop diseases and pests are some of the most destructive challenges faced by farmers. Traditionally, detecting and diagnosing these issues involved hours of manual inspection. AI changes all of this. Through <strong>image recognition</strong> and <strong>machine learning algorithms</strong>, AI models can identify diseases, pests, and stress signs in crops faster and more accurately than the human eye.</p><p>For example, in <strong>tomato farming</strong>, AI models like <strong>YOLO (You Only Look Once)</strong> analyze images of plants, pinpointing areas affected by diseases like Early Blight or <strong>Septoria Leaf Spot</strong>. The system highlights infected spots with red or blue boxes and provides confidence scores about the diagnosis. This helps farmers take immediate action, whether it’s pruning affected plants or applying the correct fungicides.</p><ul><li><strong>Early Detection</strong>: AI models can detect diseases at the earliest stage, when they are most treatable, reducing the risk of a crop-wide outbreak.</li><li><strong>Faster Decisions</strong>: Instead of manually inspecting each plant, AI scans large areas quickly, saving valuable time while providing actionable insights.</li></ul><h3>3. Precision Harvesting and Quality Control</h3><p>Once crops are ready for harvest, AI continues to make a difference by optimizing the harvest process. For apples, <strong>AI models</strong> can detect which fruits are ripe and ready for picking, ensuring that only the best apples are harvested, reducing waste, and improving quality.</p><p>For many crops, including <strong>grapes, berries, and tomatoes</strong>, <strong>robotic harvesters</strong> guided by computer vision can pick fruits without damaging them. These robots use AI to assess the ripeness of each fruit, select it, and gently collect it, making harvesting more efficient and precise.</p><ul><li><strong>Top-Notch Quality</strong>: By identifying the exact ripeness of fruit, AI ensures that only the highest-quality produce reaches consumers, reducing the chance of over- or under-ripe crops.</li><li><strong>Reduced Labor Costs</strong>: Automation in harvesting reduces the reliance on manual labor, which can be both expensive and scarce, especially in many parts of the world.</li></ul><h3>4. Smart Irrigation and Resource Management</h3><p>Water is one of agriculture’s most precious resources, and AI helps farmers use it more wisely. Through precision irrigation, AI models analyze real-time data on soil moisture, weather conditions, and crop health to determine exactly how much water each section of a field needs.</p><p>By monitoring the soil and weather conditions, AI can predict when crops need watering and how much is required, cutting down on water waste and improving crop yields. This is especially important in areas where water is scarce or during dry seasons.</p><ul><li><strong>Water Conservation</strong>: By optimizing irrigation schedules and adjusting water levels for each section of the field, AI helps farmers conserve water while maintaining healthy crops.</li><li><strong>Cost Savings</strong>: Efficient water management reduces the need for over-irrigation, saving farmers money on water and energy costs.</li></ul><h3>5. Autonomous Machinery: The Future of Farming</h3><p>One of the most exciting advancements in AI for agriculture is the development of <strong>autonomous machinery</strong>. These AI-powered machines can perform tasks like planting, weeding, and harvesting without human intervention.</p><p>For example, <strong>autonomous tractors</strong> equipped with computer vision can plow fields, sow seeds, and monitor crop health while avoiding obstacles and minimizing soil compaction. Similarly, <strong>robotic weeders</strong> powered by AI can identify and remove weeds without damaging crops, reducing the need for herbicides.</p><ul><li><strong>Efficiency</strong>: Autonomous machines can work around the clock, reducing the need for human labor and increasing productivity.</li><li><strong>Precision</strong>: These machines are highly precise, minimizing crop damage and reducing the overuse of chemicals.</li></ul><h3>6. Environmental Sustainability</h3><p>AI is also playing a significant role in making farming more sustainable. By using <strong>data-driven decisions</strong>, AI helps farmers reduce their environmental footprint while increasing productivity.</p><p>For example, by monitoring crop health in real time, AI can help farmers reduce the use of fertilizers and pesticides. By applying chemicals only when needed, farmers can reduce runoff and minimize the impact on the surrounding ecosystem. AI can also help optimize land use by identifying areas that need more attention and guiding farmers on how to distribute their resources more efficiently.</p><ul><li><strong>Eco-Friendly Farming</strong>: By reducing the need for chemical treatments and minimizing waste, AI helps farmers practice more sustainable agriculture.</li><li><strong>Biodiversity</strong>: AI technologies are enabling farmers to monitor biodiversity in their fields, ensuring that they maintain healthy ecosystems while growing food.</li></ul><h3>Challenges and Future Potential</h3><p>Despite all the incredible progress AI has brought to agriculture, there are still challenges to overcome. For one, AI systems require a significant amount of high-quality data to function optimally, and not all farms have the resources to gather or manage this data. Moreover, AI technologies can be expensive, and many farmers may face a steep learning curve when adopting new technologies.</p><p>However, as AI tools become more accessible and affordable, and as agricultural data collection methods improve, the potential for AI to transform farming continues to grow. In the future, AI could even be paired with <strong>IoT devices</strong> for <strong>real-time data</strong> on crop growth and <strong>predictive analytics</strong>, helping farmers make even smarter, data-driven decisions.</p><h3>Wrapping It Up: A Smarter, More Sustainable Future for Agriculture</h3><p>From <strong>apple farming</strong> to <strong>tomato disease detection</strong>, AI and computer vision are helping farmers meet the challenges of modern agriculture head-on. By improving crop monitoring, optimizing resources, detecting diseases early, and reducing manual labor, AI is making farming more efficient, productive, and sustainable.</p><p>There is a link of the video provided for apple detection below.</p><p><a href="https://www.facebook.com/share/p/1Qkm6wkoJ6/">Facebook</a></p><p>The AI is not perfect but it can be improve through changing the confidence threshold and some calibrations in AI training.</p><p>The future of agriculture is <strong>smart</strong>, <strong>data-driven</strong>, and <strong>sustainable</strong>. AI is not just a tool; it’s a partner in shaping the future of food production — one that can help feed a growing global population while protecting the environment. As technology continues to advance, the potential for AI to revolutionize farming is limitless. And with each new breakthrough, we move closer to a more efficient, resilient, and sustainable agricultural system for the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df3e37e64797" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing LLaVA: Revolutionizing Multimodal Interaction in AI]]></title>
            <link>https://medium.com/@xanthophile10/embracing-llava-revolutionizing-multimodal-interaction-in-ai-d2908d2f2f6f?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2908d2f2f6f</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Sun, 17 Nov 2024 06:55:03 GMT</pubDate>
            <atom:updated>2024-11-17T06:55:03.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*j7S7lWUZpN_c-gdH.png" /><figcaption><a href="https://huggingface.co/llava-hf/llava-1.5-7b-hf">https://huggingface.co/llava-hf/llava-1.5-7b-hf</a></figcaption></figure><p>The landscape of computer vision and natural language processing has been fundamentally transformed by the advent of multimodal models like <strong>LLaVA</strong> (Large Language and Vision Assistant). Designed as an open-source powerhouse, LLaVA uniquely blends vision and language, opening new frontiers for research and application.</p><h4>What is LLaVA?</h4><p>LLaVA is an auto-regressive language model rooted in the <strong>transformer architecture</strong>, fine-tuned on a vast and diverse set of <strong>multimodal instruction-following data</strong>. By combining <strong>LLaMA/Vicuna</strong> foundations with state-of-the-art training techniques, it delivers advanced conversational and visual reasoning capabilities.</p><p><strong>Model Highlights:</strong></p><ul><li><strong>Release:</strong> LLaVA-v1.5–13B (September 2023)</li><li><strong>Purpose:</strong> Bridging the gap between vision and text for more interactive, insightful AI.</li><li><strong>Applications:</strong> From research in <strong>computer vision</strong> and <strong>NLP</strong> to advancing multimodal AI development.</li></ul><h4>Why is LLaVA a Game-Changer?</h4><p>The model is tailored for researchers and enthusiasts in AI, leveraging a vast corpus of <strong>image-text pairs</strong>, <strong>multimodal datasets</strong>, and benchmarks. Its ability to process and generate content across visual and textual dimensions ensures unparalleled insight into real-world challenges, particularly in fields like <strong>visual question answering (VQA)</strong>, academic AI tasks, and beyond.</p><h4>A Training Legacy Built for Innovation</h4><p>LLaVA’s training process reflects a deep commitment to advancing AI capabilities:</p><ol><li><strong>Multimodal Instruction Data:</strong> Includes <strong>158K GPT-generated multimodal instructions</strong> for sophisticated visual and linguistic reasoning.</li><li><strong>VQA Excellence:</strong> A blend of <strong>450K academic VQA data</strong> ensures superior performance on visual question-answering tasks.</li><li><strong>Diverse Foundations:</strong> Datasets like LAION, CC, and ShareGPT reinforce its versatility.</li></ol><h4>Powering Research Through Rigorous Evaluation</h4><p>With <strong>12 benchmarks</strong> covering academic and recent advancements in instruction-following, LLaVA is a benchmark in itself. It ensures researchers have the tools to assess the real-world application and robustness of their multimodal AI efforts.</p><h4>License and Open-Source Collaboration</h4><p>Under the <strong>Llama 2 Community License</strong>, LLaVA invites contributions and collaborative development, fostering a thriving open-source community dedicated to pushing the boundaries of AI.</p><h4>Who Should Explore LLaVA?</h4><p>If you are a researcher, hobbyist, or enthusiast in:</p><ul><li><strong>Computer Vision:</strong> Dive into visual reasoning and multimodal analysis.</li><li><strong>Natural Language Processing:</strong> Harness the potential of text-visual interactions.</li><li><strong>Artificial Intelligence:</strong> Push the envelope in integrating vision and language.</li></ul><h4>Join the Revolution</h4><p>LLaVA isn’t just a model — it’s an invitation to reimagine AI’s potential. For detailed insights and collaborative opportunities, visit the <a href="https://llava-vl.github.io/">official site</a> or engage with the community on <a href="https://github.com/haotian-liu/LLaVA/issues">GitHub</a>.</p><p>Let LLaVA guide your journey in advancing <strong>multimodal AI</strong>! 🚀</p><p><strong>Example Code</strong></p><pre>!pip install -q -U transformers==4.37.2<br>!pip install -q bitsandbytes==0.41.3 accelerate==0.25.0<br><br>#Load Image<br><br>import requests<br>from PIL import Image<br><br>image_url = &quot;https://llava-vl.github.io/static/images/view.jpg&quot;<br>image = Image.open(requests.get(image_url, stream=True).raw)<br>image</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*u5imuuYwsHhhOoEQY6kH5A.jpeg" /></figure><pre><br>#In order to load the model in 4-bit precision, we need to pass a quantization_config to our model. Let&#39;s do that in the cells below<br>import torch<br>from transformers import BitsAndBytesConfig<br><br>quantization_config = BitsAndBytesConfig(<br>    load_in_4bit=True,<br>    bnb_4bit_compute_dtype=torch.float16<br>)<br><br>#We will leverage the image-to-text pipeline from transformers !<br>from transformers import pipeline<br><br>model_id = &quot;llava-hf/llava-1.5-7b-hf&quot;<br><br>pipe = pipeline(&quot;image-to-text&quot;, model=model_id, model_kwargs={&quot;quantization_config&quot;: quantization_config})<br><br><br>max_new_tokens = 200<br>prompt = &quot;USER: &lt;image&gt;\nWhat are the things I should be cautious about when I visit this place?\nASSISTANT:&quot;<br><br>outputs = pipe(image, prompt=prompt, generate_kwargs={&quot;max_new_tokens&quot;: 200})<br><br><br>print(outputs[0][&quot;generated_text&quot;])<br><br><br>#Output<br>USER:  <br>What are the things I should be cautious about when I visit this place?<br>ASSISTANT: When visiting this place, which is a pier or dock extending over a body of water, there are a few things to be cautious about. First, be aware of the weather conditions, as sudden changes in weather can make the pier unsafe to walk on. Second, be mindful of the water depth and any potential hazards, such as submerged rocks or debris, that could cause accidents or injuries. Additionally, be cautious of the presence of wildlife, such as birds or fish, and avoid disturbing their natural habitats. Lastly, be aware of any local regulations or guidelines for the use of the pier, as some areas may be restricted or prohibited for certain activities.</pre><p>Reference: <a href="https://huggingface.co/llava-hf/llava-1.5-7b-hf">https://huggingface.co/llava-hf/llava-1.5-7b-hf</a></p><ul><li><strong>Classification</strong>: Pretrained checkpoints excel on ImageNet-1k, providing robust feature extraction capabilities for classification tasks.</li><li><strong>Segmentation</strong>: Leverage the DeepLabV3 head for semantic segmentation tasks, with checkpoints trained on PASCAL VOC.</li></ul><ol><li><strong>Model Outputs</strong>:<br>Unlike traditional transformers, MobileViTV2 operates on feature maps, akin to CNNs. This makes it intuitive for developers transitioning from CNN-based workflows.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2908d2f2f6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Llama 3.2: Transforming Edge AI and Vision with Open, Customizable Model]]></title>
            <link>https://medium.com/@xanthophile10/llama-3-2-transforming-edge-ai-and-vision-with-open-customizable-model-a94826b565dd?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a94826b565dd</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 14:26:15 GMT</pubDate>
            <atom:updated>2024-10-06T14:26:15.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zLuNq4w3vf7iIwlv" /><figcaption><a href="https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/">https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/</a></figcaption></figure><h3>Introduction</h3><p>As a Computer Vision Advocate, I’m thrilled to share some exciting updates on the latest advancements in AI that are shaping the future of edge computing and vision technologies.</p><p>Today marks the release of <strong>Llama 3.2</strong>, an impressive addition to the AI landscape. This release introduces small and medium-sized vision large language models (LLMs), including <strong>11B</strong> and <strong>90B</strong> parameter models, as well as lightweight, text-only models (1B and 3B), perfect for edge and mobile device deployment. These models, available in both pre-trained and instruction-tuned variants, bring cutting-edge performance right to the device level.</p><p>The <strong>1B</strong> and <strong>3B Llama 3.2 models</strong> are particularly noteworthy for their ability to support a <strong>128K token context length</strong>, making them ideal for tasks like <strong>summarization, instruction following</strong>, and <strong>rewriting</strong> — all running locally. Optimized for <strong>Qualcomm</strong> and <strong>MediaTek hardware</strong> with support for <strong>Arm processors</strong>, these models are immediately accessible for on-device applications.</p><p>On the vision front, the <strong>11B</strong> and <strong>90B vision models</strong> are designed to excel in image understanding, surpassing closed models like <strong>Claude 3 Haiku</strong>. Both pre-trained and aligned versions can be fine-tuned for custom use cases via <strong>torchtune</strong> and deployed locally using <strong>torchchat</strong>. This flexibility empowers developers to tailor the models for specific applications, whether it’s document-level visual comprehension, image captioning, or natural language-guided object detection.</p><p>To make working with these models even more seamless, the first <strong>Llama Stack distributions</strong> are now available, simplifying deployment across a range of environments — whether on-prem, in the cloud, or on-device. This opens the door to integrating <strong>retrieval-augmented generation (RAG)</strong> and other AI-powered tools with greater ease and security.</p><p>Moreover, Llama 3.2 is backed by a broad ecosystem of partners, including <strong>AWS, Databricks, Dell, Intel,</strong> and many others, allowing developers to take full advantage of its capabilities from day one. This is a major leap forward in making high-performance AI accessible and customizable for a wide array of edge and enterprise applications.</p><p>As an advocate for open innovation, I am particularly excited by Llama’s continued leadership in <strong>openness, modifiability</strong>, and <strong>cost-efficiency</strong>, driving real-world breakthroughs and ensuring that AI development remains a collaborative and inclusive effort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RPCCoUDaaLH7-1YX" /><figcaption><a href="https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/">https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O0R_OqS52LB_Frls" /><figcaption><a href="https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/">https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/</a></figcaption></figure><pre>import requests<br>import torch<br>from PIL import Image<br>from transformers import MllamaForConditionalGeneration, AutoProcessor<br><br># Model ID for the Llama model<br>model_id = &quot;meta-llama/Llama-3.2-11B-Vision&quot;<br><br># Check if CUDA is available and set the device<br>device = &quot;cuda&quot; if torch.cuda.is_available() else &quot;cpu&quot;<br><br># Load the model with evaluation mode and reduce memory usage<br>model = MllamaForConditionalGeneration.from_pretrained(<br>    model_id,<br>    torch_dtype=torch.float16,<br>).to(device).eval()  # Set model to evaluation mode<br><br># Load the processor<br>processor = AutoProcessor.from_pretrained(model_id)<br><br># Load the image from the URL<br>url = &quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg&quot;<br>image = Image.open(requests.get(url, stream=True).raw)<br><br># Prepare the prompt and inputs<br>prompt = &quot;&lt;|image|&gt;&lt;|begin_of_text|&gt;If I had to write a haiku for this one&quot;<br>inputs = processor(image, prompt, return_tensors=&quot;pt&quot;).to(device)<br><br># Clear any unused cache<br>torch.cuda.empty_cache()<br><br># Generate output with gradient calculation disabled<br>with torch.no_grad():<br>    output = model.generate(**inputs, max_new_tokens=30)<br><br># Decode and print the generated text<br>print(processor.decode(output[0]))<br><br># Optional: Clear cache again after processing<br>torch.cuda.empty_cache()</pre><p>This Python script demonstrates how to leverage the <strong>Llama 3.2 Vision model (11B)</strong> for image-to-text generation using <strong>PyTorch</strong> and <strong>Hugging Face Transformers</strong>. By combining the <strong>MllamaForConditionalGeneration</strong> model and an image processor, the script downloads an image, generates a natural language description or creative response (in this case, a haiku), and then decodes the model’s output.</p><p>The workflow includes loading the model and processor, setting the device to either GPU (if available) or CPU, preparing image inputs, and generating text without calculating gradients (to save memory and improve efficiency). This code exemplifies how vision and language models can be applied in <strong>image reasoning</strong> tasks such as captioning, enabling powerful AI-driven interactions between images and text.</p><h3>Vision Models</h3><p>The <strong>11B</strong> and <strong>90B Llama models</strong> are the first in the series to handle vision tasks, requiring a completely new architecture to enable image reasoning capabilities.</p><p>To incorporate image input, we developed a set of <strong>adapter weights</strong> that seamlessly integrate the pre-trained image encoder with the pre-trained language model. This adapter is made up of cross-attention layers, allowing the image encoder’s outputs to feed into the language model. The adapter was trained on <strong>text-image pairs</strong> to align the image representations with language. During training, the image encoder’s parameters were updated, while the language model remained untouched. This approach preserved the original text-only capabilities, ensuring the new models could serve as a <strong>drop-in replacement</strong> for Llama 3.1 models.</p><p>The training process followed several stages. Starting with the <strong>Llama 3.1 text models</strong>, we added image adapters and encoders, followed by pretraining on large-scale noisy datasets of image-text pairs. This was followed by training on medium-scale, high-quality, and knowledge-enhanced data.</p><p>Post-training, similar techniques used in text models were applied, such as <strong>alignment through supervised fine-tuning</strong>, <strong>rejection sampling</strong>, and <strong>direct preference optimization</strong>. We also used synthetic data generation, employing the Llama 3.1 model to enhance and filter question-and-answer pairs based on in-domain images, while a reward model ranked these answers to create high-quality fine-tuning data. Additionally, safety mitigation data was included to ensure the model maintained a balance of safety and helpfulness.</p><p>The final outcome is a set of models capable of processing both <strong>image and text prompts</strong> with deep reasoning, advancing Llama’s ability to handle more complex, multimodal tasks and enhancing its potential for more <strong>agentic capabilities</strong>.</p><h3>Experience Llama 3.2 Today</h3><p>Llama 3.2 is set to reach a broader audience and unlock a variety of exciting new applications. We believe that simply providing these models to the open-source community isn’t enough. To ensure developers can build with Llama responsibly, we’re also offering new tools and resources. Additionally, we will continue updating our <strong>Responsible Use Guide</strong> with best practices to support ethical development.</p><p>Our commitment to openness stems from our belief that it drives innovation, benefiting developers, Meta, and the world at large. We’re eager to continue collaborating with our partners and the open-source community, and we look forward to seeing the incredible projects that will be built with <strong>Llama 3.2</strong> and <strong>Llama Stack</strong>.</p><p>Reference:</p><p><a href="https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/">https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a94826b565dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Grounding DINO with Segment Anything (SAM) for generating masks based on text inputs]]></title>
            <link>https://medium.com/@xanthophile10/integrating-grounding-dino-with-segment-anything-sam-for-generating-masks-based-on-text-inputs-0adb59603366?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0adb59603366</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Sat, 14 Sep 2024 13:13:17 GMT</pubDate>
            <atom:updated>2024-09-14T13:13:17.522Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>In recent advancements in computer vision, combining different models has led to significant improvements in tasks like object detection and segmentation. One such innovative approach is the integration of Grounding DINO, a model designed for text-guided object detection, with Segment Anything (SAM), a model specializing in generating high-quality segmentation masks. By merging these two powerful models, it becomes possible to perform text-based mask generation, where users can specify objects in an image using natural language and obtain precise segmentation masks. This fusion opens up new possibilities in applications ranging from image editing to automated visual understanding systems, significantly enhancing the flexibility and accuracy of object segmentation based on textual descriptions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MA0YXD4BsK9AY6Jx.png" /><figcaption><a href="https://github.com/IDEA-Research/Grounded-Segment-Anything">https://github.com/IDEA-Research/Grounded-Segment-Anything</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RMBACpEI4UeJdNbH.png" /><figcaption><a href="https://github.com/IDEA-Research/Grounded-Segment-Anything">https://github.com/IDEA-Research/Grounded-Segment-Anything</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*PUTJ74PkMIpeDKmUs701lw.png" /></figure><p>How It Works</p><p>The integration of Grounding DINO with Segment Anything (SAM) enables text-based mask generation by leveraging the strengths of both models: Grounding DINO for detecting objects based on text prompts and SAM for producing highly accurate segmentation masks. Here’s a breakdown of how the combined system works:</p><p>1. Text-Based Object Detection with Grounding DINO:<br> Grounding DINO is a transformer-based model designed to detect objects in an image using natural language descriptions. The model processes both the image and a text query (e.g., “a red car” or “a window”). It identifies the location of the described object within the image by generating bounding boxes around the detected areas. Grounding DINO acts as the first step in identifying regions of interest (ROIs) based on the input text.</p><p>2. Region Refinement and Mask Generation with SAM:<br> Once Grounding DINO identifies the bounding boxes or regions of interest based on the text input, these ROIs are passed to SAM (Segment Anything Model). SAM specializes in generating precise segmentation masks, taking the initial bounding box and refining it to accurately outline the object at a pixel level. SAM uses the detected region and computes the detailed mask that fits the object’s exact boundaries.</p><p>3. Integration Process:<br> The integration involves two key steps: Grounding DINO performs a coarse detection, while SAM refines this detection into a high-quality mask. By combining these two models, the system allows users to generate segmentation masks for objects described in plain text without needing any manual input, such as points or clicks on the image.</p><p>4. Application Pipeline:<br> — Input: The user provides an image and a natural language description of the object they want to segment.<br> — Object Detection: Grounding DINO processes the image and text to identify the object’s location.<br> — Mask Generation: SAM receives the detected object’s bounding box and generates an accurate segmentation mask that outlines the object.<br> — Output: The final output is the original image with a segmentation mask overlaid on the specified object.</p><p>This powerful combination of models enables a user-friendly approach to image segmentation, allowing for a fully automated process from text input to pixel-perfect segmentation. It has broad applications in various fields, such as image editing, augmented reality, and content generation, where precise object segmentation is critical.</p><p><strong>How it works</strong></p><h3>Set-up environment</h3><pre>!pip install --upgrade -q git+https://github.com/huggingface/transformers</pre><h3>Imports</h3><pre>import random<br>from dataclasses import dataclass<br>from typing import Any, List, Dict, Optional, Union, Tuple<br><br>import cv2<br>import torch<br>import requests<br>import numpy as np<br>from PIL import Image<br>import plotly.express as px<br>import matplotlib.pyplot as plt<br>import plotly.graph_objects as go<br>from transformers import AutoModelForMaskGeneration, AutoProcessor, pipeline</pre><h3>Result Utils</h3><pre>@dataclass<br>class BoundingBox:<br>    xmin: int<br>    ymin: int<br>    xmax: int<br>    ymax: int<br><br>    @property<br>    def xyxy(self) -&gt; List[float]:<br>        return [self.xmin, self.ymin, self.xmax, self.ymax]<br><br>@dataclass<br>class DetectionResult:<br>    score: float<br>    label: str<br>    box: BoundingBox<br>    mask: Optional[np.array] = None<br><br>    @classmethod<br>    def from_dict(cls, detection_dict: Dict) -&gt; &#39;DetectionResult&#39;:<br>        return cls(score=detection_dict[&#39;score&#39;],<br>                   label=detection_dict[&#39;label&#39;],<br>                   box=BoundingBox(xmin=detection_dict[&#39;box&#39;][&#39;xmin&#39;],<br>                                   ymin=detection_dict[&#39;box&#39;][&#39;ymin&#39;],<br>                                   xmax=detection_dict[&#39;box&#39;][&#39;xmax&#39;],<br>                                   ymax=detection_dict[&#39;box&#39;][&#39;ymax&#39;]))</pre><h3>Plot Utils</h3><pre>def annotate(image: Union[Image.Image, np.ndarray], detection_results: List[DetectionResult]) -&gt; np.ndarray:<br>    # Convert PIL Image to OpenCV format<br>    image_cv2 = np.array(image) if isinstance(image, Image.Image) else image<br>    image_cv2 = cv2.cvtColor(image_cv2, cv2.COLOR_RGB2BGR)<br><br>    # Iterate over detections and add bounding boxes and masks<br>    for detection in detection_results:<br>        label = detection.label<br>        score = detection.score<br>        box = detection.box<br>        mask = detection.mask<br><br>        # Sample a random color for each detection<br>        color = np.random.randint(0, 256, size=3)<br><br>        # Draw bounding box<br>        cv2.rectangle(image_cv2, (box.xmin, box.ymin), (box.xmax, box.ymax), color.tolist(), 2)<br>        cv2.putText(image_cv2, f&#39;{label}: {score:.2f}&#39;, (box.xmin, box.ymin - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color.tolist(), 2)<br><br>        # If mask is available, apply it<br>        if mask is not None:<br>            # Convert mask to uint8<br>            mask_uint8 = (mask * 255).astype(np.uint8)<br>            contours, _ = cv2.findContours(mask_uint8, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)<br>            cv2.drawContours(image_cv2, contours, -1, color.tolist(), 2)<br><br>    return cv2.cvtColor(image_cv2, cv2.COLOR_BGR2RGB)<br><br>def plot_detections(<br>    image: Union[Image.Image, np.ndarray],<br>    detections: List[DetectionResult],<br>    save_name: Optional[str] = None<br>) -&gt; None:<br>    annotated_image = annotate(image, detections)<br>    plt.imshow(annotated_image)<br>    plt.axis(&#39;off&#39;)<br>    if save_name:<br>        plt.savefig(save_name, bbox_inches=&#39;tight&#39;)<br>    plt.show()</pre><pre>def random_named_css_colors(num_colors: int) -&gt; List[str]:<br>    &quot;&quot;&quot;<br>    Returns a list of randomly selected named CSS colors.<br><br>    Args:<br>    - num_colors (int): Number of random colors to generate.<br><br>    Returns:<br>    - list: List of randomly selected named CSS colors.<br>    &quot;&quot;&quot;<br>    # List of named CSS colors<br>    named_css_colors = [<br>        &#39;aliceblue&#39;, &#39;antiquewhite&#39;, &#39;aqua&#39;, &#39;aquamarine&#39;, &#39;azure&#39;, &#39;beige&#39;, &#39;bisque&#39;, &#39;black&#39;, &#39;blanchedalmond&#39;,<br>        &#39;blue&#39;, &#39;blueviolet&#39;, &#39;brown&#39;, &#39;burlywood&#39;, &#39;cadetblue&#39;, &#39;chartreuse&#39;, &#39;chocolate&#39;, &#39;coral&#39;, &#39;cornflowerblue&#39;,<br>        &#39;cornsilk&#39;, &#39;crimson&#39;, &#39;cyan&#39;, &#39;darkblue&#39;, &#39;darkcyan&#39;, &#39;darkgoldenrod&#39;, &#39;darkgray&#39;, &#39;darkgreen&#39;, &#39;darkgrey&#39;,<br>        &#39;darkkhaki&#39;, &#39;darkmagenta&#39;, &#39;darkolivegreen&#39;, &#39;darkorange&#39;, &#39;darkorchid&#39;, &#39;darkred&#39;, &#39;darksalmon&#39;, &#39;darkseagreen&#39;,<br>        &#39;darkslateblue&#39;, &#39;darkslategray&#39;, &#39;darkslategrey&#39;, &#39;darkturquoise&#39;, &#39;darkviolet&#39;, &#39;deeppink&#39;, &#39;deepskyblue&#39;,<br>        &#39;dimgray&#39;, &#39;dimgrey&#39;, &#39;dodgerblue&#39;, &#39;firebrick&#39;, &#39;floralwhite&#39;, &#39;forestgreen&#39;, &#39;fuchsia&#39;, &#39;gainsboro&#39;, &#39;ghostwhite&#39;,<br>        &#39;gold&#39;, &#39;goldenrod&#39;, &#39;gray&#39;, &#39;green&#39;, &#39;greenyellow&#39;, &#39;grey&#39;, &#39;honeydew&#39;, &#39;hotpink&#39;, &#39;indianred&#39;, &#39;indigo&#39;, &#39;ivory&#39;,<br>        &#39;khaki&#39;, &#39;lavender&#39;, &#39;lavenderblush&#39;, &#39;lawngreen&#39;, &#39;lemonchiffon&#39;, &#39;lightblue&#39;, &#39;lightcoral&#39;, &#39;lightcyan&#39;, &#39;lightgoldenrodyellow&#39;,<br>        &#39;lightgray&#39;, &#39;lightgreen&#39;, &#39;lightgrey&#39;, &#39;lightpink&#39;, &#39;lightsalmon&#39;, &#39;lightseagreen&#39;, &#39;lightskyblue&#39;, &#39;lightslategray&#39;,<br>        &#39;lightslategrey&#39;, &#39;lightsteelblue&#39;, &#39;lightyellow&#39;, &#39;lime&#39;, &#39;limegreen&#39;, &#39;linen&#39;, &#39;magenta&#39;, &#39;maroon&#39;, &#39;mediumaquamarine&#39;,<br>        &#39;mediumblue&#39;, &#39;mediumorchid&#39;, &#39;mediumpurple&#39;, &#39;mediumseagreen&#39;, &#39;mediumslateblue&#39;, &#39;mediumspringgreen&#39;, &#39;mediumturquoise&#39;,<br>        &#39;mediumvioletred&#39;, &#39;midnightblue&#39;, &#39;mintcream&#39;, &#39;mistyrose&#39;, &#39;moccasin&#39;, &#39;navajowhite&#39;, &#39;navy&#39;, &#39;oldlace&#39;, &#39;olive&#39;,<br>        &#39;olivedrab&#39;, &#39;orange&#39;, &#39;orangered&#39;, &#39;orchid&#39;, &#39;palegoldenrod&#39;, &#39;palegreen&#39;, &#39;paleturquoise&#39;, &#39;palevioletred&#39;, &#39;papayawhip&#39;,<br>        &#39;peachpuff&#39;, &#39;peru&#39;, &#39;pink&#39;, &#39;plum&#39;, &#39;powderblue&#39;, &#39;purple&#39;, &#39;rebeccapurple&#39;, &#39;red&#39;, &#39;rosybrown&#39;, &#39;royalblue&#39;, &#39;saddlebrown&#39;,<br>        &#39;salmon&#39;, &#39;sandybrown&#39;, &#39;seagreen&#39;, &#39;seashell&#39;, &#39;sienna&#39;, &#39;silver&#39;, &#39;skyblue&#39;, &#39;slateblue&#39;, &#39;slategray&#39;, &#39;slategrey&#39;,<br>        &#39;snow&#39;, &#39;springgreen&#39;, &#39;steelblue&#39;, &#39;tan&#39;, &#39;teal&#39;, &#39;thistle&#39;, &#39;tomato&#39;, &#39;turquoise&#39;, &#39;violet&#39;, &#39;wheat&#39;, &#39;white&#39;,<br>        &#39;whitesmoke&#39;, &#39;yellow&#39;, &#39;yellowgreen&#39;<br>    ]<br><br>    # Sample random named CSS colors<br>    return random.sample(named_css_colors, min(num_colors, len(named_css_colors)))<br><br>def plot_detections_plotly(<br>    image: np.ndarray,<br>    detections: List[DetectionResult],<br>    class_colors: Optional[Dict[str, str]] = None<br>) -&gt; None:<br>    # If class_colors is not provided, generate random colors for each class<br>    if class_colors is None:<br>        num_detections = len(detections)<br>        colors = random_named_css_colors(num_detections)<br>        class_colors = {}<br>        for i in range(num_detections):<br>            class_colors[i] = colors[i]<br><br><br>    fig = px.imshow(image)<br><br>    # Add bounding boxes<br>    shapes = []<br>    annotations = []<br>    for idx, detection in enumerate(detections):<br>        label = detection.label<br>        box = detection.box<br>        score = detection.score<br>        mask = detection.mask<br><br>        polygon = mask_to_polygon(mask)<br><br>        fig.add_trace(go.Scatter(<br>            x=[point[0] for point in polygon] + [polygon[0][0]],<br>            y=[point[1] for point in polygon] + [polygon[0][1]],<br>            mode=&#39;lines&#39;,<br>            line=dict(color=class_colors[idx], width=2),<br>            fill=&#39;toself&#39;,<br>            name=f&quot;{label}: {score:.2f}&quot;<br>        ))<br><br>        xmin, ymin, xmax, ymax = box.xyxy<br>        shape = [<br>            dict(<br>                type=&quot;rect&quot;,<br>                xref=&quot;x&quot;, yref=&quot;y&quot;,<br>                x0=xmin, y0=ymin,<br>                x1=xmax, y1=ymax,<br>                line=dict(color=class_colors[idx])<br>            )<br>        ]<br>        annotation = [<br>            dict(<br>                x=(xmin+xmax) // 2, y=(ymin+ymax) // 2,<br>                xref=&quot;x&quot;, yref=&quot;y&quot;,<br>                text=f&quot;{label}: {score:.2f}&quot;,<br>            )<br>        ]<br><br>        shapes.append(shape)<br>        annotations.append(annotation)<br><br>    # Update layout<br>    button_shapes = [dict(label=&quot;None&quot;,method=&quot;relayout&quot;,args=[&quot;shapes&quot;, []])]<br>    button_shapes = button_shapes + [<br>        dict(label=f&quot;Detection {idx+1}&quot;,method=&quot;relayout&quot;,args=[&quot;shapes&quot;, shape]) for idx, shape in enumerate(shapes)<br>    ]<br>    button_shapes = button_shapes + [dict(label=&quot;All&quot;, method=&quot;relayout&quot;, args=[&quot;shapes&quot;, sum(shapes, [])])]<br><br>    fig.update_layout(<br>        xaxis=dict(visible=False),<br>        yaxis=dict(visible=False),<br>        # margin=dict(l=0, r=0, t=0, b=0),<br>        showlegend=True,<br>        updatemenus=[<br>            dict(<br>                type=&quot;buttons&quot;,<br>                direction=&quot;up&quot;,<br>                buttons=button_shapes<br>            )<br>        ],<br>        legend=dict(<br>            orientation=&quot;h&quot;,<br>            yanchor=&quot;bottom&quot;,<br>            y=1.02,<br>            xanchor=&quot;right&quot;,<br>            x=1<br>        )<br>    )<br><br>    # Show plot<br>    fig.show()</pre><h3>Utils</h3><pre>def mask_to_polygon(mask: np.ndarray) -&gt; List[List[int]]:<br>    # Find contours in the binary mask<br>    contours, _ = cv2.findContours(mask.astype(np.uint8), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)<br><br>    # Find the contour with the largest area<br>    largest_contour = max(contours, key=cv2.contourArea)<br><br>    # Extract the vertices of the contour<br>    polygon = largest_contour.reshape(-1, 2).tolist()<br><br>    return polygon<br><br>def polygon_to_mask(polygon: List[Tuple[int, int]], image_shape: Tuple[int, int]) -&gt; np.ndarray:<br>    &quot;&quot;&quot;<br>    Convert a polygon to a segmentation mask.<br><br>    Args:<br>    - polygon (list): List of (x, y) coordinates representing the vertices of the polygon.<br>    - image_shape (tuple): Shape of the image (height, width) for the mask.<br><br>    Returns:<br>    - np.ndarray: Segmentation mask with the polygon filled.<br>    &quot;&quot;&quot;<br>    # Create an empty mask<br>    mask = np.zeros(image_shape, dtype=np.uint8)<br><br>    # Convert polygon to an array of points<br>    pts = np.array(polygon, dtype=np.int32)<br><br>    # Fill the polygon with white color (255)<br>    cv2.fillPoly(mask, [pts], color=(255,))<br><br>    return mask<br><br>def load_image(image_str: str) -&gt; Image.Image:<br>    if image_str.startswith(&quot;http&quot;):<br>        image = Image.open(requests.get(image_str, stream=True).raw).convert(&quot;RGB&quot;)<br>    else:<br>        image = Image.open(image_str).convert(&quot;RGB&quot;)<br><br>    return image<br><br>def get_boxes(results: DetectionResult) -&gt; List[List[List[float]]]:<br>    boxes = []<br>    for result in results:<br>        xyxy = result.box.xyxy<br>        boxes.append(xyxy)<br><br>    return [boxes]<br><br>def refine_masks(masks: torch.BoolTensor, polygon_refinement: bool = False) -&gt; List[np.ndarray]:<br>    masks = masks.cpu().float()<br>    masks = masks.permute(0, 2, 3, 1)<br>    masks = masks.mean(axis=-1)<br>    masks = (masks &gt; 0).int()<br>    masks = masks.numpy().astype(np.uint8)<br>    masks = list(masks)<br><br>    if polygon_refinement:<br>        for idx, mask in enumerate(masks):<br>            shape = mask.shape<br>            polygon = mask_to_polygon(mask)<br>            mask = polygon_to_mask(polygon, shape)<br>            masks[idx] = mask<br><br>    return masks</pre><h3>Grounded Segment Anything (SAM)</h3><p>Now it’s time to define the Grounded SAM approach!</p><p>The approach is very simple:</p><ol><li>use Grounding DINO to detect a given set of texts in the image. The output is a set of bounding boxes.</li><li>prompt Segment Anything (SAM) with the bounding boxes, for which the model will output segmentation masks.</li></ol><pre>def detect(<br>    image: Image.Image,<br>    labels: List[str],<br>    threshold: float = 0.3,<br>    detector_id: Optional[str] = None<br>) -&gt; List[Dict[str, Any]]:<br>    &quot;&quot;&quot;<br>    Use Grounding DINO to detect a set of labels in an image in a zero-shot fashion.<br>    &quot;&quot;&quot;<br>    device = &quot;cuda&quot; if torch.cuda.is_available() else &quot;cpu&quot;<br>    detector_id = detector_id if detector_id is not None else &quot;IDEA-Research/grounding-dino-tiny&quot;<br>    object_detector = pipeline(model=detector_id, task=&quot;zero-shot-object-detection&quot;, device=device)<br><br>    labels = [label if label.endswith(&quot;.&quot;) else label+&quot;.&quot; for label in labels]<br><br>    results = object_detector(image,  candidate_labels=labels, threshold=threshold)<br>    results = [DetectionResult.from_dict(result) for result in results]<br><br>    return results<br><br>def segment(<br>    image: Image.Image,<br>    detection_results: List[Dict[str, Any]],<br>    polygon_refinement: bool = False,<br>    segmenter_id: Optional[str] = None<br>) -&gt; List[DetectionResult]:<br>    &quot;&quot;&quot;<br>    Use Segment Anything (SAM) to generate masks given an image + a set of bounding boxes.<br>    &quot;&quot;&quot;<br>    device = &quot;cuda&quot; if torch.cuda.is_available() else &quot;cpu&quot;<br>    segmenter_id = segmenter_id if segmenter_id is not None else &quot;facebook/sam-vit-base&quot;<br><br>    segmentator = AutoModelForMaskGeneration.from_pretrained(segmenter_id).to(device)<br>    processor = AutoProcessor.from_pretrained(segmenter_id)<br><br>    boxes = get_boxes(detection_results)<br>    inputs = processor(images=image, input_boxes=boxes, return_tensors=&quot;pt&quot;).to(device)<br><br>    outputs = segmentator(**inputs)<br>    masks = processor.post_process_masks(<br>        masks=outputs.pred_masks,<br>        original_sizes=inputs.original_sizes,<br>        reshaped_input_sizes=inputs.reshaped_input_sizes<br>    )[0]<br><br>    masks = refine_masks(masks, polygon_refinement)<br><br>    for detection_result, mask in zip(detection_results, masks):<br>        detection_result.mask = mask<br><br>    return detection_results<br><br>def grounded_segmentation(<br>    image: Union[Image.Image, str],<br>    labels: List[str],<br>    threshold: float = 0.3,<br>    polygon_refinement: bool = False,<br>    detector_id: Optional[str] = None,<br>    segmenter_id: Optional[str] = None<br>) -&gt; Tuple[np.ndarray, List[DetectionResult]]:<br>    if isinstance(image, str):<br>        image = load_image(image)<br><br>    detections = detect(image, labels, threshold, detector_id)<br>    detections = segment(image, detections, polygon_refinement, segmenter_id)<br><br>    return np.array(image), detections</pre><h3>Inference</h3><p>Let’s showcase Grounded SAM on our favorite image: the cats image from the COCO dataset.</p><pre>image_url = &quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;<br>labels = [&quot;a cat.&quot;, &quot;a remote control.&quot;]<br>threshold = 0.3<br><br>detector_id = &quot;IDEA-Research/grounding-dino-tiny&quot;<br>segmenter_id = &quot;facebook/sam-vit-base&quot;</pre><pre>image_array, detections = grounded_segmentation(<br>    image=image_url,<br>    labels=labels,<br>    threshold=threshold,<br>    polygon_refinement=True,<br>    detector_id=detector_id,<br>    segmenter_id=segmenter_id<br>)</pre><p>Let’s visualize the results:</p><pre>plot_detections(image_array, detections, &quot;cute_cats.png&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*nigZoN0WP3UqdcfQmuLaFQ.png" /></figure><pre>plot_detections_plotly(image_array, detections)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*EZYaGiIFOfLi3NNhd9JfXw.png" /></figure><p>By seamlessly integrating the text-driven detection power of Grounding DINO with the precision of SAM’s segmentation, this approach marks a significant leap forward in image interaction and manipulation. It transforms the way we detect and segment objects, making the process faster, more intuitive, and remarkably efficient. As these cutting-edge technologies continue to advance, they will unlock even greater potential for automation and innovation in fields like augmented reality, content creation, and visual analysis, paving the way for a future where human-computer interaction becomes more seamless and dynamic than ever before.</p><h3><strong>Conclusion</strong></h3><p>In conclusion, the fusion of Grounding DINO and Segment Anything (SAM) offers a groundbreaking solution for text-based mask generation in computer vision. By combining the strengths of text-guided object detection with high-precision segmentation, this approach enhances both accuracy and ease of use, enabling users to interact with images in a more intuitive way. This integration not only streamlines workflows but also opens up new possibilities for automation, creative applications, and advanced visual processing. As these technologies continue to evolve, they hold the potential to reshape the landscape of image analysis, making complex tasks simpler and more accessible.</p><p>References:</p><ul><li><a href="https://huggingface.co/docs/transformers/en/model_doc/sam">SAM</a></li><li><a href="https://arxiv.org/abs/2401.14159">Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks</a></li><li><a href="https://github.com/IDEA-Research/Grounded-Segment-Anything?tab=readme-ov-file">GitHub - IDEA-Research/Grounded-Segment-Anything: Grounded SAM: Marrying Grounding DINO with Segment Anything &amp; Stable Diffusion &amp; Recognize Anything - Automatically Detect , Segment and Generate Anything</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0adb59603366" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Depth Anything V2: Revolutionizing Monocular Depth Estimation]]></title>
            <link>https://medium.com/@xanthophile10/depth-anything-v2-revolutionizing-monocular-depth-estimation-c12332736e06?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c12332736e06</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Tue, 13 Aug 2024 21:33:17 GMT</pubDate>
            <atom:updated>2024-08-13T21:41:50.081Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p><strong>Depth Anything V2</strong> is a cutting-edge model in monocular depth estimation, designed to offer exceptional accuracy and efficiency. Built upon the advanced DPT architecture with a DINOv2 backbone, this model has been trained on approximately 600,000 synthetic labeled images and 62 million real unlabeled images.</p><p>Depth Anything V2 sets a new standard in depth estimation by delivering both relative and absolute depth measurements with unparalleled precision. Its robust performance and lightweight design make it ideal for a wide range of applications, from autonomous vehicles to augmented reality and 3D reconstruction. With its rapid processing capabilities and impressive detail resolution, Depth Anything V2 represents the future of depth perception technology.</p><p>Depth Anything V2 is at the forefront of monocular depth estimation technology. It has been meticulously developed to address the limitations of previous models and offer unparalleled depth accuracy, efficiency, and robustness. Leveraging a vast dataset and state-of-the-art techniques, Depth Anything V2 sets a new standard in depth estimation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LhUvvR_ovHl-NvG8" /><figcaption><a href="https://github.com/DepthAnything/Depth-Anything-V2?tab=readme-ov-file">https://github.com/DepthAnything/Depth-Anything-V2?tab=readme-ov-file</a></figcaption></figure><p>Depth Anything V2 utilizes the DPT architecture with a DINOv2 backbone. It has been trained on approximately 600,000 synthetic labeled images and around 62 million real unlabeled images, achieving cutting-edge performance in both relative and absolute depth estimation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1nQBsFedJDwYGKj0.jpg" /><figcaption><a href="https://arxiv.org/abs/2401.10891">https://arxiv.org/abs/2401.10891</a></figcaption></figure><h3>Here is how to use this model to perform zero-shot depth estimation:</h3><pre>from transformers import pipeline<br>from PIL import Image<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import matplotlib.colors as mcolors<br><br>pipe = pipeline(task=&quot;depth-estimation&quot;, model=&quot;depth-anything/Depth-Anything-V2-Large-hf&quot;)<br>#you can use any kind of image<br>image_path = &#39;/content/449648697_500327472666707_4940346724887287099_n.jpg&#39;<br>image = Image.open(image_path)<br><br>result = pipe(image)<br>depth = result[&quot;depth&quot;]<br><br>if isinstance(depth, Image.Image):<br>    depth = np.array(depth)<br><br>print(&quot;Depth information:&quot;)<br>print(depth)<br><br>plt.figure(figsize=(10, 8))<br><br>norm = mcolors.Normalize(vmin=np.min(depth), vmax=np.max(depth))<br><br>plt.imshow(depth, cmap=&#39;inferno&#39;, norm=norm)<br>plt.colorbar(label=&#39;Depth&#39;)<br><br>heatmap_image_path = &#39;/content/depth_heatmap.png&#39;<br>plt.savefig(heatmap_image_path)<br>plt.close()<br><br>print(f&quot;Depth heatmap image saved to: {heatmap_image_path}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*HSElHDUEJHIccPTk9ciLBw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*H66IA0Y58fbxF7cRjBrJcw.jpeg" /></figure><h3>Advanced Training Data</h3><p><strong>Extensive Data Sources</strong>:</p><ul><li><strong>595,000 Synthetic Labeled Images</strong>: The model benefits from a diverse array of synthetic images, which provide a controlled environment for training and enhance its ability to generalize across different scenarios.</li><li><strong>62 Million+ Real Unlabeled Images</strong>: Real-world data is critical for improving model performance in practical applications. This substantial dataset ensures that Depth Anything V2 performs exceptionally well in real-world environments.</li></ul><p><strong>Training Techniques</strong>:</p><ul><li><strong>Hybrid Training Approach</strong>: Combining synthetic and real images enables the model to learn intricate details and adapt to various conditions, resulting in more accurate and reliable depth predictions.</li></ul><h3>Performance Enhancements</h3><p><strong>Fine-Grained Detail</strong>:</p><ul><li><strong>Enhanced Depth Resolution</strong>: Depth Anything V2 delivers more detailed and precise depth maps, capturing finer nuances in depth perception compared to Depth Anything V1.</li><li><strong>Improved Depth Accuracy</strong>: The model’s refined architecture allows for better differentiation between objects at different depths, enhancing overall depth accuracy.</li></ul><p><strong>Robustness and Reliability</strong>:</p><ul><li><strong>Increased Stability</strong>: Depth Anything V2 is engineered to be more resilient to noise and variances in input data, outperforming previous models and other SD-based solutions such as Marigold and Geowizard.</li><li><strong>Adaptive Learning</strong>: The model adapts to diverse environments and lighting conditions, making it versatile for a wide range of applications.</li></ul><h3>Efficiency and Speed</h3><p><strong>Processing Speed</strong>:</p><ul><li><strong>10x Faster</strong>: Depth Anything V2 achieves depth estimation tasks with remarkable speed, significantly faster than traditional SD-based models, facilitating real-time applications and faster processing workflows.</li></ul><p><strong>Lightweight Architecture</strong>:</p><ul><li><strong>Optimized for Performance</strong>: The model is designed to be lightweight, ensuring that it can be deployed on resource-constrained devices without sacrificing performance. This makes it ideal for embedded systems and mobile applications.</li></ul><h3>Pre-Trained Excellence</h3><p><strong>Out-of-the-Box Performance</strong>:</p><ul><li><strong>Immediate Results</strong>: The pre-trained models offer high-quality depth estimation right from the start, reducing the need for extensive additional training and accelerating deployment.</li><li><strong>Fine-Tuned Capabilities</strong>: The pre-trained models have been fine-tuned to deliver exceptional results across various scenarios, ensuring that users can achieve optimal performance with minimal setup.</li></ul><h3>Applications</h3><p><strong>Autonomous Vehicles</strong>:</p><ul><li><strong>Enhanced Navigation</strong>: Improve the accuracy of obstacle detection and collision avoidance systems with detailed depth maps.</li><li><strong>Advanced Sensor Fusion</strong>: Integrate depth information with other sensor data to enhance vehicle perception.</li></ul><p><strong>Augmented Reality (AR)</strong>:</p><ul><li><strong>Immersive Experiences</strong>: Provide more realistic AR experiences by accurately mapping the 3D environment and interactions.</li><li><strong>Contextual Awareness</strong>: Enable applications to understand and interact with the physical world more effectively.</li></ul><p><strong>Robotics</strong>:</p><ul><li><strong>Precision Manipulation</strong>: Enhance robotic vision systems for better grasping and manipulating objects with accurate depth information.</li><li><strong>Environmental Interaction</strong>: Improve robots’ ability to navigate and interact with complex environments.</li></ul><p><strong>3D Reconstruction</strong>:</p><ul><li><strong>High-Fidelity Models</strong>: Achieve detailed and accurate 3D reconstructions for applications in virtual reality, gaming, and cultural heritage preservation.</li><li><strong>Efficient Modeling</strong>: Streamline the process of creating 3D models from 2D images with precise depth data.</li></ul><h3>References:</h3><p>Yang, Lihe, et al. “Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data.” <em>CVPR</em>, 2024.</p><p>Yang, Lihe, et al. “Depth Anything V2.” <em>arXiv:2406.09414</em>, 2024.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c12332736e06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Llama 3.1 by Meta: A New Era in LLM Innovation]]></title>
            <link>https://medium.com/@xanthophile10/introducing-llama-3-1-by-meta-a-new-era-in-llm-innovation-98d5e157c3d7?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/98d5e157c3d7</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Sun, 11 Aug 2024 15:13:33 GMT</pubDate>
            <atom:updated>2024-08-11T22:20:14.062Z</atom:updated>
            <content:encoded><![CDATA[<p>Meta is thrilled to introduce Llama 3.1 405B, a groundbreaking model that redefines the standards of artificial intelligence. This state-of-the-art model excels in various domains including general knowledge, adaptability, mathematical reasoning, tool integration, and multilingual translation. With the launch of Llama 3.1 405B, Meta is set to drive exceptional advancements and unlock new avenues for innovation.</p><p>In conjunction with this release, we’re also unveiling enhanced versions of our 8B and 70B models. These upgraded models come with multilingual capabilities, an extended context length of 128K, cutting-edge tool functionality, and superior reasoning abilities. These improvements allow the models to tackle complex tasks such as long-form text summarization, multilingual conversational agents, and coding support.</p><p>Furthermore, we’ve revised our licensing terms to enable developers to utilize outputs from Llama models — including the 405B — to refine other models. In keeping with our open-source commitment, these models are now available for download on llama.meta.com and Hugging Face, and are ready for immediate development across our broad network of partner platforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cqdURkX2w6s1P_lL" /><figcaption><a href="https://ai.meta.com/blog/meta-llama-3-1/">https://ai.meta.com/blog/meta-llama-3-1/</a></figcaption></figure><h3>System Requirements</h3><p>Running Llama 3.1 on NVIDIA T4 Tensor Cores involves several key considerations. The T4 is a powerful GPU designed for deep learning tasks, so you’ll need a robust setup to maximize its performance. Begin with a multi-core CPU to handle data preprocessing and other tasks efficiently, and ensure you have at least 16 GB of system RAM, though 32 GB or more is recommended for better performance. For storage, an SSD with at least 1 TB of capacity is advisable to accommodate the model and any datasets you’ll be using.</p><p>On the software side, Linux is the preferred operating system for deep learning workloads, though Windows can also be used with additional configuration. Make sure you install a deep learning framework compatible with NVIDIA T4, such as PyTorch or TensorFlow, and ensure it supports Tensor Cores. The T4 supports CUDA versions 10.0 and above, so you’ll need to install the appropriate CUDA toolkit and cuDNN library versions that align with your framework.</p><p>The NVIDIA T4’s 16 GB of VRAM is suitable for many model sizes and tasks, but very large models or batch sizes may require adjustments or distributed setups. Keep your GPU drivers up to date to maintain optimal performance and compatibility. Using virtual environments or containerization tools like Docker can help manage dependencies and avoid conflicts. For the best results, refer to the specific documentation for the Llama model and your chosen deep learning framework.</p><h3><strong>Model evaluations</strong></h3><p>For this release, we assessed performance using over 150 benchmark datasets covering a broad spectrum of languages. We also conducted thorough human evaluations to compare Llama 3.1 with rival models in real-world contexts. Our experimental findings indicate that our flagship model holds its own against top foundation models such as GPT-4, GPT-4o, and Claude 3.5 Sonnet across various tasks. Furthermore, our smaller models demonstrate competitiveness with both closed and open models with a similar parameter count.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L1YxlFkSLro6siwx" /><figcaption><a href="https://ai.meta.com/blog/meta-llama-3-1/">https://ai.meta.com/blog/meta-llama-3-1/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7GVoGWXKMXm6SoRn" /><figcaption><a href="https://ai.meta.com/blog/meta-llama-3-1/">https://ai.meta.com/blog/meta-llama-3-1/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8eQ2h99TUPMyfrAr" /><figcaption><a href="https://ai.meta.com/blog/meta-llama-3-1/">https://ai.meta.com/blog/meta-llama-3-1/</a></figcaption></figure><h3>Here’s what Llama 3.1 can do.</h3><p>Text generation</p><pre>import transformers<br>import torch<br><br>model_id = &quot;meta-llama/Meta-Llama-3.1-8B-Instruct&quot;<br><br>pipeline = transformers.pipeline(<br>    &quot;text-generation&quot;,<br>    model=model_id,<br>    model_kwargs={&quot;torch_dtype&quot;: torch.bfloat16},<br>    device_map=&quot;auto&quot;,<br>)<br><br>messages = [<br>    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Who are you?&quot;},<br>]<br><br>outputs = pipeline(<br>    messages,<br>    max_new_tokens=256,<br>)<br>print(outputs[0][&quot;generated_text&quot;][-1])</pre><p>output</p><pre>config.json: 100%<br> 855/855 [00:00&lt;00:00, 42.5kB/s]<br>model.safetensors.index.json: 100%<br> 23.9k/23.9k [00:00&lt;00:00, 1.52MB/s]<br>Downloading shards: 100%<br> 4/4 [01:32&lt;00:00, 20.52s/it]<br>model-00001-of-00004.safetensors: 100%<br> 4.98G/4.98G [00:29&lt;00:00, 170MB/s]<br>model-00002-of-00004.safetensors: 100%<br> 5.00G/5.00G [00:27&lt;00:00, 248MB/s]<br>model-00003-of-00004.safetensors: 100%<br> 4.92G/4.92G [00:24&lt;00:00, 246MB/s]<br>model-00004-of-00004.safetensors: 100%<br> 1.17G/1.17G [00:10&lt;00:00, 91.4MB/s]<br>Loading checkpoint shards: 100%<br> 4/4 [01:00&lt;00:00, 11.51s/it]<br>generation_config.json: 100%<br> 184/184 [00:00&lt;00:00, 13.6kB/s]<br>WARNING:accelerate.big_modeling:Some parameters are on the meta device device because they were offloaded to the cpu.<br>tokenizer_config.json: 100%<br> 55.4k/55.4k [00:00&lt;00:00, 3.17MB/s]<br>tokenizer.json: 100%<br> 9.09M/9.09M [00:00&lt;00:00, 13.3MB/s]<br>special_tokens_map.json: 100%<br> 296/296 [00:00&lt;00:00, 17.5kB/s]<br>Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.<br>{&#39;role&#39;: &#39;assistant&#39;, &#39;content&#39;: &quot;I&#39;m an artificial intelligence model known <br>as a large language model (LLM). I&#39;m a computer program designed to understand <br>and generate human-like text. My primary function is to assist and communicate <br>with users like you through text-based conversations.\n\nI can answer questions, <br>provide information on a wide range of topics, offer suggestions, generate text, <br>and even engage in creative activities like storytelling or dialogue. <br>I&#39;m constantly learning and improving my responses based on the interactions<br> I have with users.\n\nThink of me as a knowledgeable and helpful assistant <br>who&#39;s always ready to chat and provide assistance. What would you like to talk <br>about or ask?&quot;}</pre><p>Can also perform Math:</p><pre>import transformers<br>import torch<br><br>model_id = &quot;meta-llama/Meta-Llama-3.1-8B-Instruct&quot;<br><br>pipeline = transformers.pipeline(<br>    &quot;text-generation&quot;,<br>    model=model_id,<br>    model_kwargs={&quot;torch_dtype&quot;: torch.bfloat16},<br>    device_map=&quot;auto&quot;,<br>)<br><br>messages = [<br>    {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;Mathematian&quot;},<br>    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Jack has 8 cats and 2 dogs. J<br>    ill has 7 cats and 4 dogs. How many dogs are there in all?&quot;},<br>]<br><br>outputs = pipeline(<br>    messages,<br>    max_new_tokens=256,<br>)<br>print(outputs[0][&quot;generated_text&quot;][-1])</pre><p>output</p><pre>config.json: 100%<br> 855/855 [00:00&lt;00:00, 38.8kB/s]<br>model.safetensors.index.json: 100%<br> 23.9k/23.9k [00:00&lt;00:00, 1.05MB/s]<br>Downloading shards: 100%<br> 4/4 [01:29&lt;00:00, 18.85s/it]<br>model-00001-of-00004.safetensors: 100%<br> 4.98G/4.98G [00:29&lt;00:00, 242MB/s]<br>model-00002-of-00004.safetensors: 100%<br> 5.00G/5.00G [00:26&lt;00:00, 97.3MB/s]<br>model-00003-of-00004.safetensors: 100%<br> 4.92G/4.92G [00:27&lt;00:00, 137MB/s]<br>model-00004-of-00004.safetensors: 100%<br> 1.17G/1.17G [00:04&lt;00:00, 239MB/s]<br>Loading checkpoint shards: 100%<br> 4/4 [00:53&lt;00:00, 10.16s/it]<br>generation_config.json: 100%<br> 184/184 [00:00&lt;00:00, 7.08kB/s]<br>WARNING:accelerate.big_modeling:Some parameters are on the meta device device because they were offloaded to the cpu.<br>tokenizer_config.json: 100%<br> 55.4k/55.4k [00:00&lt;00:00, 679kB/s]<br>tokenizer.json: 100%<br> 9.09M/9.09M [00:00&lt;00:00, 15.4MB/s]<br>special_tokens_map.json: 100%<br> 296/296 [00:00&lt;00:00, 21.7kB/s]<br>Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.<br>{&#39;role&#39;: &#39;assistant&#39;, &#39;content&#39;: &#39;To find the total number of dogs, <br>we need to add the number of dogs Jack has to the number of dogs Jill has. <br>\n\nJack has 2 dogs and Jill has 4 dogs. <br>\n2 + 4 = 6\n\n<br>So, there are 6 dogs in all.&#39;}</pre><p>Translation</p><pre>import transformers<br>import torch<br><br>model_id = &quot;meta-llama/Meta-Llama-3.1-8B-Instruct&quot;<br><br>pipeline = transformers.pipeline(<br>    &quot;text-generation&quot;,<br>    model=model_id,<br>    model_kwargs={&quot;torch_dtype&quot;: torch.bfloat16},<br>    device_map=&quot;auto&quot;,<br>)<br><br>messages = [<br>    {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;Translation&quot;},<br>    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Translate the word &#39;Engineer&#39; to German&quot;},<br>]<br><br>outputs = pipeline(<br>    messages,<br>    max_new_tokens=256,<br>)<br>print(outputs[0][&quot;generated_text&quot;][-1])</pre><p>output</p><pre>Loading checkpoint shards: 100%<br> 4/4 [00:45&lt;00:00,  8.08s/it]<br>WARNING:accelerate.big_modeling:Some parameters are on the meta device device because they were offloaded to the cpu.<br>Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.<br>{&#39;role&#39;: &#39;assistant&#39;, &#39;content&#39;: &quot;The translation of the word &#39;Engineer&#39; to German is:<br>\n\n- &#39;Ingenieur&#39; (male)\n- &#39;Ingenieurin&#39; (female)\n\nIn modern German, <br>the gender-neutral term is often used, especially in informal contexts:<br>\n\n- &#39;Ingenieur&#39; (for both male and female engineers)&quot;}</pre><p>Llama models, including Llama 3.1, typically have a range of capabilities, such as:</p><ol><li><strong>Natural Language Understanding:</strong> Ability to comprehend and interpret text in a way that mirrors human understanding.</li><li><strong>Text Generation:</strong> Generate coherent and contextually relevant text based on given prompts.</li><li><strong>Question Answering:</strong> Provide accurate responses to questions based on its training data.</li><li><strong>Summarization:</strong> Condense long pieces of text into concise summaries while retaining key information.</li><li><strong>Translation:</strong> Translate text between different languages.</li><li><strong>Sentiment Analysis:</strong> Determine the sentiment or emotional tone behind a piece of text.</li><li><strong>Conversational Abilities:</strong> Engage in human-like conversations, understanding and generating responses that are contextually appropriate.</li><li><strong>Content Creation:</strong> Assist in creating content such as articles, stories, or essays.</li><li><strong>Text Classification:</strong> Categorize text into predefined categories or labels.</li></ol><p>These capabilities are enhanced through techniques like supervised fine-tuning (SFT) and reinforcement learning with human feedback (RLHF) to improve alignment with user expectations and safety standards.</p><h3><strong>Model Architecture</strong></h3><p>Llama 3.1 is an auto-regressive language model featuring an enhanced transformer architecture. The refined versions employ supervised fine-tuning (SFT) and reinforcement learning with human feedback (RLHF) to better align with human expectations for usefulness and safety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-qmXXQ5AKEpc1Cqy" /><figcaption><a href="https://ai.meta.com/blog/meta-llama-3-1/">https://ai.meta.com/blog/meta-llama-3-1/</a></figcaption></figure><h3>Llama 3.1 systems</h3><p>Large language models, such as Llama 3.1, are intended to be part of a broader AI system rather than used in isolation. It is important to incorporate additional safety measures when deploying these models. Developers are expected to implement system safeguards when creating autonomous systems to ensure proper alignment between helpfulness and safety, as well as to address the inherent safety and security risks associated with the model and its integration with external tools.</p><p>As part of our commitment to responsible deployment, we provide the community with safety tools for use with Llama models and other large language models (LLMs). These include Llama Guard 3, Prompt Guard, and Code Shield. Our reference implementation demos include these safeguards by default, allowing developers to benefit from built-in system-level safety features.</p><h3>Conclusion</h3><p>In conclusion, Llama 3.1 represents a significant advancement in large language models, boasting a refined transformer architecture and extensive training on over 15 trillion tokens. Its capabilities, including natural language understanding, text generation, and conversational abilities, are enhanced through sophisticated techniques like supervised fine-tuning and reinforcement learning with human feedback. However, to ensure its effective and safe deployment, it is crucial to integrate Llama 3.1 within a comprehensive AI system equipped with necessary safety measures. The provided tools, such as Llama Guard 3, Prompt Guard, and Code Shield, are essential for maintaining the balance between helpfulness and safety, mitigating potential risks, and facilitating responsible use of this powerful technology.</p><p>Reference:</p><p><a href="https://ai.meta.com/blog/meta-llama-3-1/">https://ai.meta.com/blog/meta-llama-3-1/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98d5e157c3d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Florence-2: Integrating Vision Intelligence for Various Applications]]></title>
            <link>https://medium.com/@xanthophile10/florence-2-integrating-vision-intelligence-for-various-applications-a57d67aee0a8?source=rss-390772f43c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a57d67aee0a8</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[vision-language-model]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Gerald Anthony Cabansag]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 09:49:22 GMT</pubDate>
            <atom:updated>2024-07-27T09:53:45.921Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>In an era where technology advances rapidly, the need for sophisticated and adaptable AI systems has never been greater. Enter <strong>Florence-2</strong>, a groundbreaking innovation that represents a major step forward in integrating artificial intelligence across various vision tasks.</p><p>Florence-2 is more than just another vision model; it’s a significant leap in creating a unified system capable of handling diverse visual applications with exceptional precision and efficiency. Developed by a team of forward-thinking engineers and researchers at Microsoft, Florence-2 was designed to overcome the limitations of traditional models that struggled with specialized, fragmented solutions.</p><p>The vision for Florence-2 was to develop a model that could seamlessly manage everything from image recognition and object detection to complex scene understanding within a single, cohesive framework. By leveraging cutting-edge techniques in deep learning, data integration, and scalable architecture, Florence-2 emerged as a model with remarkable versatility and accuracy.</p><p>The impact of Florence-2 was both immediate and profound. It revolutionized industries such as healthcare, where it aided in early disease detection; autonomous vehicles, where it improved safety with enhanced object detection and navigation; and retail, where it transformed customer experiences with precise product recognition and tailored recommendations.</p><p>Florence-2’s journey is a testament to innovation and collaboration, marking a significant milestone in the evolution of artificial intelligence in vision tasks. As it continues to develop, Florence-2 is set to redefine the possibilities in computer vision and establish new benchmarks for AI technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQ37veAhAMl_R33QW17VmQ.png" /><figcaption><em>Illustration showing the level of spatial hierarchy and semantic granularity expressed by each task. Source: Florence-2: Advancing a Unified Representation for a Variety of Vision Tasks.</em></figcaption></figure><p>The model receives images and task prompts as inputs and produces the desired outputs in text form. It utilizes a DaViT vision encoder to transform images into visual token embeddings, which are then combined with text embeddings created by BERT. These combined embeddings are processed by a transformer-based multi-modal encoder-decoder to generate the final response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tAg-o3I6rcReKAhrbpAKVw.png" /><figcaption><em>Overview of Florence-2 architecture. Source: Florence-2: Advancing a Unified Representation for a Variety of Vision Tasks.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*Fd4yd02Gz9U2dMOyakOLIQ.png" /><figcaption><a href="https://huggingface.co/microsoft/Florence-2-base-ft">https://huggingface.co/microsoft/Florence-2-base-ft</a></figcaption></figure><p>These models are optimized for various tasks and sizes, providing flexibility in applications ranging from general-purpose natural language understanding to specific domain tasks.</p><p><strong>How does Florence — 2 work?</strong></p><p>Florence-2 operates through a dual-phase approach: it begins with pre-trained models based on the FLD-5B architecture, which are initially trained on extensive datasets to grasp language patterns comprehensively. Subsequently, these models undergo finetuning, where they are adjusted to specific tasks or datasets, enhancing their performance and applicability in tasks like sentiment analysis and question answering. Florence-2 models are adept at natural language processing tasks, offering scalability with different model sizes (such as base and large) to accommodate varying computational needs and application requirements.</p><h3>Example object detection inference</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zxevWf45Cf0iCwVfSJ0FMg.png" /></figure><p>Here are the tasks Florence-2 could perform:</p><p><strong>Caption</strong></p><pre>prompt = &quot;&lt;CAPTION&gt;&quot;<br>run_example(prompt)</pre><pre>{&#39;&lt;CAPTION&gt;&#39;: &#39;A group of people posing for a picture.&#39;}</pre><p><strong>Detailed Caption</strong></p><pre>prompt = &quot;&lt;DETAILED_CAPTION&gt;&quot;<br>run_example(prompt)</pre><pre>{&#39;&lt;DETAILED_CAPTION&gt;&#39;: &#39;In this image we can see a group of people standing on the ground. <br>In that a woman is holding a mobile in her hand. <br>We can also see some houses with roof, some plants, grass and the sky which looks cloudy.&#39;}</pre><p><strong>More Detailed Caption</strong></p><pre>prompt = &quot;&lt;MORE_DETAILED_CAPTION&gt;&quot;<br>run_example(prompt)</pre><pre>{&#39;&lt;MORE_DETAILED_CAPTION&gt;&#39;: &#39;A group of people are standing on a beach. <br>There is a large body of water behind the people. <br>There are trees behind the water behind a building. &#39;}</pre><p><strong>Caption to Phrase Grounding</strong></p><p>caption to phrase grounding task requires additional text input, i.e. caption.</p><p>Caption to phrase grounding results format: {‘&lt;CAPTION_TO_PHRASE_GROUNDING&gt;’: {‘bboxes’: [[x1, y1, x2, y2], …], ‘labels’: [‘’, ‘’, …]}}</p><pre>task_prompt = &quot;&lt;CAPTION_TO_PHRASE_GROUNDING&gt;&quot;<br>results = run_example(task_prompt, text_input=&quot;In this image we can see a group of people standing on the ground. In that a woman is holding a mobile in her hand. We can also see some houses with roof, some plants, grass and the sky which looks cloudy.&quot;)</pre><pre>{&#39;&lt;CAPTION_TO_PHRASE_GROUNDING&gt;&#39;: {&#39;bboxes&#39;: [[1.0240000486373901, 66.81600189208984, 2044.9281005859375, 1533.696044921875], <br>[1047.552001953125, 358.656005859375, 2044.9281005859375, 1533.696044921875], <br>[1.0240000486373901, 509.1839904785156, 867.3280639648438, 1533.696044921875], <br>[502.7840270996094, 460.0320129394531, 1002.4960327148438, 1533.696044921875], <br>[893.9520263671875, 429.31201171875, 1317.8880615234375, 1533.696044921875], <br>[1584.1280517578125, 358.656005859375, 2044.9281005859375, 1014.5280151367188], <br>[1006.592041015625, 82.1760025024414, 1387.52001953125, 624.384033203125], <br>[412.6720275878906, 191.23199462890625, 756.7360229492188, 753.4080200195312], <br>[707.5840454101562, 68.35199737548828, 1080.320068359375, 564.47998046875], <br>[101.37600708007812, 205.05599975585938, 515.072021484375, 593.6640014648438], [893.9520263671875, 429.31201171875, 1319.93603515625, 1533.696044921875], [709.6320190429688, 297.21600341796875, 816.1280517578125, 390.9120178222656], [300.0320129394531, 1086.719970703125, 674.8160400390625, 1464.5760498046875], [900.0960693359375, 638.2080078125, 1086.464111328125, 916.2239990234375], [1.0240000486373901, 0.7680000066757202, 2044.9281005859375, 235.7760009765625], [1.0240000486373901, 0.7680000066757202, 695.2960205078125, 235.7760009765625], [23.552001953125, 36.09600067138672, 691.2000122070312, 232.70399475097656], [25.600000381469727, 37.63199996948242, 689.1520385742188, 100.60800170898438], [1.0240000486373901, 0.7680000066757202, 693.248046875, 106.75199890136719], [1.0240000486373901, 152.83200073242188, 2044.9281005859375, 801.0239868164062], [1.0240000486373901, 0.7680000066757202, 691.2000122070312, 68.35199737548828]], <br>&#39;labels&#39;: [&#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a group of people&#39;, &#39;a woman&#39;, &#39;a mobile&#39;, &#39;her hand&#39;, &#39;her hand&#39;, &#39;some houses&#39;, &#39;some houses&#39;, &#39;some houses&#39;, &#39;roof&#39;, &#39;some plants&#39;, &#39;grass&#39;, &#39;the sky&#39;]}}</pre><p><strong>Object Detection</strong></p><p>OD results format: {‘&lt;OD&gt;’: {‘bboxes’: [[x1, y1, x2, y2], …], ‘labels’: [‘label1’, ‘label2’, …]} }</p><pre>prompt = &quot;&lt;OD&gt;&quot;<br>results = run_example(prompt)<br>print(results)</pre><pre>{&#39;&lt;OD&gt;&#39;: {&#39;bboxes&#39;: [[1072.1280517578125, 1430.7840576171875, 1158.14404296875, 1499.904052734375], [1100.800048828125, 1380.0960693359375, 1180.6719970703125, 1453.823974609375], [97.2800064086914, 733.4400024414062, 535.552001953125, 871.6799926757812], [695.2960205078125, 592.1279907226562, 875.52001953125, 653.5679931640625], [965.6320190429688, 1062.14404296875, 1145.8560791015625, 1209.5999755859375], [128.0, 589.0560302734375, 523.2640380859375, 1060.6080322265625], [1238.01611328125, 423.1679992675781, 1571.840087890625, 822.5280151367188], [1717.248046875, 436.99200439453125, 1979.39208984375, 742.656005859375], [932.8640747070312, 527.6160278320312, 1168.384033203125, 770.3040161132812], [691.2000122070312, 519.9359741210938, 873.4720458984375, 750.3359985351562], [515.072021484375, 248.06399536132812, 680.9600219726562, 475.3919982910156], [283.64801025390625, 264.9599914550781, 441.3440246582031, 453.88800048828125], [803.8400268554688, 134.39999389648438, 949.248046875, 326.3999938964844], [1033.216064453125, 139.00799560546875, 1176.5760498046875, 321.7919921875], [1.0240000486373901, 507.64801025390625, 863.2320556640625, 1533.696044921875], [408.5760192871094, 192.76800537109375, 750.592041015625, 745.72802734375], [1090.56005859375, 768.7680053710938, 1221.632080078125, 902.4000244140625], [1049.60009765625, 361.7279968261719, 2044.9281005859375, 1533.696044921875], [1.0240000486373901, 512.2559814453125, 857.0880126953125, 1533.696044921875], [1584.1280517578125, 361.7279968261719, 2044.9281005859375, 1532.1600341796875], [504.83203125, 463.10400390625, 988.1600341796875, 1533.696044921875], [889.8560180664062, 432.3840026855469, 1311.7440185546875, 1533.696044921875], [711.6800537109375, 69.88800048828125, 1072.1280517578125, 1533.696044921875], [412.6720275878906, 194.3040008544922, 742.4000244140625, 997.6320190429688], [1008.6400756835938, 85.24800109863281, 1377.280029296875, 619.7760009765625], [105.47200775146484, 211.1999969482422, 508.9280090332031, 590.5919799804688], [992.2560424804688, 810.239990234375, 1012.7360229492188, 830.2080078125], [1070.080078125, 1430.7840576171875, 1156.0960693359375, 1499.904052734375], [1573.8880615234375, 360.1920166015625, 2044.9281005859375, 1012.9920043945312]], &#39;labels&#39;: [&#39;bracelet&#39;, &#39;bracelet&#39;, &#39;glasses&#39;, &#39;glasses&#39;, &#39;handbag&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;man&#39;, &#39;man&#39;, &#39;necklace&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;ring&#39;, &#39;watch&#39;, &#39;woman&#39;]}}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lF8FcxxE43pmjueRZJYEIA.png" /></figure><p><strong>Dense Region Caption</strong></p><p>Dense region caption results format: {‘&lt;DENSE_REGION_CAPTION&gt;’ : {‘bboxes’: [[x1, y1, x2, y2], …], ‘labels’: [‘label1’, ‘label2’, …]} }</p><pre>prompt = &quot;&lt;DENSE_REGION_CAPTION&gt;&quot;<br>run_example(prompt)</pre><pre>{&#39;&lt;DENSE_REGION_CAPTION&gt;&#39;: {&#39;bboxes&#39;: [[130.04800415039062, 589.0560302734375, 525.31201171875, 1060.6080322265625], [1238.01611328125, 423.1679992675781, 1573.8880615234375, 825.6000366210938], [1717.248046875, 438.52801513671875, 1979.39208984375, 742.656005859375], [932.8640747070312, 527.6160278320312, 1170.4320068359375, 771.8400268554688], [693.248046875, 519.9359741210938, 873.4720458984375, 751.8720092773438], [515.072021484375, 249.60000610351562, 680.9600219726562, 476.9280090332031], [283.64801025390625, 264.9599914550781, 441.3440246582031, 453.88800048828125], [803.8400268554688, 134.39999389648438, 949.248046875, 326.3999938964844], [1033.216064453125, 139.00799560546875, 1176.5760498046875, 321.7919921875], [717.8240356445312, 303.3600158691406, 799.7440185546875, 377.0880126953125], [1090.56005859375, 768.7680053710938, 1221.632080078125, 902.4000244140625], [1049.60009765625, 361.7279968261719, 2044.9281005859375, 1533.696044921875], [1.0240000486373901, 512.2559814453125, 857.0880126953125, 1533.696044921875], [1582.080078125, 361.7279968261719, 2044.9281005859375, 1532.1600341796875], [504.83203125, 463.10400390625, 988.1600341796875, 1533.696044921875], [889.8560180664062, 432.3840026855469, 1311.7440185546875, 1533.696044921875], [412.6720275878906, 194.3040008544922, 742.4000244140625, 997.6320190429688], [711.6800537109375, 69.88800048828125, 1072.1280517578125, 562.9440307617188], [1010.6880493164062, 85.24800109863281, 1377.280029296875, 619.7760009765625], [105.47200775146484, 211.1999969482422, 508.9280090332031, 589.0560302734375], [992.2560424804688, 810.239990234375, 1012.7360229492188, 830.2080078125], [1072.1280517578125, 1430.7840576171875, 1158.14404296875, 1499.904052734375], [1098.7520751953125, 1380.0960693359375, 1178.6240234375, 1452.2879638671875]], &#39;labels&#39;: [&#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;human face&#39;, &#39;mobile phone&#39;, &#39;necklace&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;person&#39;, &#39;ring&#39;, &#39;watch&#39;, &#39;watch&#39;]}}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*h1O6xYzc8S0LmIo0JIL08Q.png" /></figure><p>Detailed Caption + Phrase Grounding</p><p>{ ‘&lt;DETAILED_CAPTION’: pure_text, {‘&lt;CAPTION_TO_PHRASE_GROUNDING&gt;’: {‘bboxes’: [[x1, y1, x2, y2], …], ‘labels’: [‘’, ‘’, …]}} }</p><pre>task_prompt = &#39;&lt;DETAILED_CAPTION&gt;&#39;<br>results = run_example(task_prompt)<br>text_input = results[task_prompt]<br>task_prompt = &#39;&lt;CAPTION_TO_PHRASE_GROUNDING&gt;&#39;<br>results = run_example(task_prompt, text_input)<br>results[&#39;&lt;DETAILED_CAPTION&gt;&#39;] = text_input<br>results</pre><pre>{&#39;&lt;CAPTION_TO_PHRASE_GROUNDING&gt;&#39;: {&#39;bboxes&#39;: [[1.0240000486373901,<br>    66.81600189208984,<br>    2044.9281005859375,<br>    1533.696044921875],<br>   [1047.552001953125,<br>    358.656005859375,<br>    2044.9281005859375,<br>    1533.696044921875],<br>   [1.0240000486373901,<br>    509.1839904785156,<br>    867.3280639648438,<br>    1533.696044921875],<br>   [502.7840270996094,<br>    460.0320129394531,<br>    1002.4960327148438,<br>    1533.696044921875],<br>   [893.9520263671875, 429.31201171875, 1317.8880615234375, 1533.696044921875],<br>   [1584.1280517578125,<br>    358.656005859375,<br>    2044.9281005859375,<br>    1014.5280151367188],<br>   [1006.592041015625, 82.1760025024414, 1387.52001953125, 624.384033203125],<br>   [412.6720275878906,<br>    191.23199462890625,<br>    756.7360229492188,<br>    753.4080200195312],<br>   [707.5840454101562, 68.35199737548828, 1080.320068359375, 564.47998046875],<br>   [101.37600708007812,<br>    205.05599975585938,<br>    515.072021484375,<br>    593.6640014648438],<br>   [893.9520263671875, 429.31201171875, 1319.93603515625, 1533.696044921875],<br>   [709.6320190429688,<br>    297.21600341796875,<br>    816.1280517578125,<br>    390.9120178222656],<br>   [300.0320129394531,<br>    1086.719970703125,<br>    674.8160400390625,<br>    1464.5760498046875],<br>   [900.0960693359375, 638.2080078125, 1086.464111328125, 916.2239990234375],<br>   [1.0240000486373901,<br>    0.7680000066757202,<br>    2044.9281005859375,<br>    235.7760009765625],<br>   [1.0240000486373901,<br>    0.7680000066757202,<br>    695.2960205078125,<br>    235.7760009765625],<br>   [23.552001953125, 36.09600067138672, 691.2000122070312, 232.70399475097656],<br>   [25.600000381469727,<br>    37.63199996948242,<br>    689.1520385742188,<br>    100.60800170898438],<br>   [1.0240000486373901, 0.7680000066757202, 693.248046875, 106.75199890136719],<br>   [1.0240000486373901,<br>    152.83200073242188,<br>    2044.9281005859375,<br>    801.0239868164062],<br>   [1.0240000486373901,<br>    0.7680000066757202,<br>    691.2000122070312,<br>    68.35199737548828]],<br>  &#39;labels&#39;: [&#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a group of people&#39;,<br>   &#39;a woman&#39;,<br>   &#39;a mobile&#39;,<br>   &#39;her hand&#39;,<br>   &#39;her hand&#39;,<br>   &#39;some houses&#39;,<br>   &#39;some houses&#39;,<br>   &#39;some houses&#39;,<br>   &#39;roof&#39;,<br>   &#39;some plants&#39;,<br>   &#39;grass&#39;,<br>   &#39;the sky&#39;]},<br> &#39;&lt;DETAILED_CAPTION&gt;&#39;: &#39;In this image we can see a group of people standing on the <br>ground. In that a woman is holding a mobile in her hand. We can also see some houses with roof, some plants, grass and the sky which looks cloudy.&#39;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*GTft-wbpn35JiwNf_c1Vyg.png" /><figcaption>Even the AI model stumble occasionally: learning through mistakes, evolving with every error.</figcaption></figure><p><strong>I provided a video in which Florence 2 is used for inferencing(Object Detection).</strong></p><p><a href="https://drive.google.com/file/d/1R6l5WXeFtcOu1ZWrYcRyZeP-ml_kxj_B/view?usp=drive_link">annotated_video.mp4</a></p><p><strong>Benchmarks</strong></p><p>The table below shows the zero-shot performance of generalist vision foundation models in image captioning and object detection tasks. These models were not exposed to the evaluation tasks’ training data during their initial training phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*l9NJbCWw6HGYabtUYPGZkQ.png" /></figure><p>The following table continues the comparison with performance on other vision-language evaluation tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*8PNvRmHMAH3g1MtybKABmw.png" /><figcaption><a href="https://huggingface.co/microsoft/Florence-2-base-ft">https://huggingface.co/microsoft/Florence-2-base-ft</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*TZCgMX_mvMRY2ZUHu3s4Bg.png" /><figcaption><a href="https://huggingface.co/microsoft/Florence-2-base-ft">https://huggingface.co/microsoft/Florence-2-base-ft</a></figcaption></figure><p>Florence-2 is a comprehensive model designed for diverse applications, including image captioning, object detection, and segmentation. It excels in natural language processing, sentiment analysis, content analysis, and automated document processing. Florence-2 is a valuable asset for machine learning research and can be integrated across various sectors such as healthcare, finance, and customer service to enhance efficiency and decision-making processes.</p><p><strong>Conclusion</strong></p><p>In summary, the Florence-2 models exhibit remarkable proficiency in natural language processing thanks to their two-phase process of pretraining and finetuning. Although they may make occasional errors, their versatility and scalability make them highly effective for numerous applications, including text analysis and advanced conversational agents. The capacity to fine-tune these models for specific tasks ensures their continued relevance and optimal performance across various domains, establishing them as powerful tools in the fields of artificial intelligence and machine learning.</p><p><strong>References</strong></p><p>Xiao, Bin, et al. “Florence-2: Advancing a Unified Representation for a Variety of Vision Tasks.” <em>arXiv Preprint arXiv:2311.06242</em>, 2023.</p><p><a href="https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/how-to-finetune-florence-2-on-detection-dataset.ipynb#scrollTo=KVmYbqqUSlCH">https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/how-to-finetune-florence-2-on-detection-dataset.ipynb#scrollTo=KVmYbqqUSlCH</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a57d67aee0a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>