<?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 Mihaela Catan on Medium]]></title>
        <description><![CDATA[Stories by Mihaela Catan on Medium]]></description>
        <link>https://medium.com/@mihaelacatan?source=rss-7b582a5cd74b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JMNRYByM1p6WdAJhGK2McQ.jpeg</url>
            <title>Stories by Mihaela Catan on Medium</title>
            <link>https://medium.com/@mihaelacatan?source=rss-7b582a5cd74b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 12:43:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mihaelacatan/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[Smaller, Smarter, Cheaper? Rethinking LLM Orchestration for Cost Efficiency]]></title>
            <link>https://medium.com/softplus-publication/smaller-smarter-cheaper-rethinking-llm-orchestration-for-cost-efficiency-5e9e20517ea5?source=rss-7b582a5cd74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e9e20517ea5</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Tue, 03 Mar 2026 10:55:04 GMT</pubDate>
            <atom:updated>2026-03-18T20:16:21.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aP9Av72mu5jkyMXckEPrnQ.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>In the era of AI, large language models are widely used in everyday life, answering coding questions, generating creative content, or providing information-heavy responses. Advanced systems have demonstrated remarkable capabilities that serve as an assistance with decision-making tasks.</p><p>These powerful models come with significant computational and financial costs. While some models are free to use or offer a freemium option, for advanced features, advanced usage often requires paid plans.</p><p>At Sigmoid, this question led to a practical and economically driven hypothesis: for simpler tasks, could smaller, cheaper models be used instead of large, premium models, while still delivering valid and useful answers?</p><p>As a result, an experiment was run to orchestrate multiple smaller models that collaborate within a structured workflow, delegating complexity only when necessary.</p><p>The primary purpose of this experiment is to design and evaluate a collaborative flow of smaller and more cost-efficient AI models that together could produce high-quality responses.</p><p>The key objectives of the experiment are: <br>- achieve equivalent performance at a lower cost, or <br>- achieve better performance at a similar cost; <br>- reduce computational resource consumption; <br>- design an intelligent model orchestration workflow.</p><p>Given a user query, the system first routes the task to a lower-tier, cost-efficient LLM to generate an initial response. The generated output is then evaluated by a dedicated Judge LLM that performs a structured assessment, producing a quality score, a validity verdict, and diagnostic feedback. If the response satisfies predefined acceptance criteria, it is returned immediately, enabling early termination and cost efficiency. Otherwise, the judge’s feedback is incorporated into a refined prompt that includes the original query, the prior response, and the structured critique. This refined prompt is passed to a stronger model in the cascade, and the evaluation–refinement cycle repeats. Escalation continues until either a response meets the acceptance threshold or the highest-capability model is used, a moment when the best answer is returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*V8Q6f8xE7RPofNMWbpcYTg.jpeg" /><figcaption>Fig.1: Flowchart for the Simple Flow Architecture</figcaption></figure><h3><strong>Experiment #1</strong></h3><p>In the first run of the experiment, five different agents were tested as workers:<br>- Worker 1: Meta Llama 3.1 8B (8 billion parameters | $0.02/M input tokens | $0.05/M output tokens)<br>- Worker 2: Microsoft Phi-4 (14 billion parameters | $0.06/M input tokens | $0.14/M output tokens)<br>- Worker 3: Qwen 3 32B (32 billion parameters | $0.08/M input tokens | $0.24/M output tokens)<br>- Worker 4: Meta Llama 3.1 70B (70 billion parameters | $0.40/M input tokens$0.40/M | output tokens)<br>- Worker 5: NVIDIA Llama 3.3 Nemotron Super 49B v1.5 (49 billion parameters | $0.10/M input tokens | $0.40/M output tokens)</p><p>The evaluation was carried out using Google Gemini 2.5 Flash Lite Preview (September 2025), which acted as the judge. The agents’ answers to Arena Hard Auto v2 benchmark questions were compared against OpenAI’s ChatGPT 4.1, serving as the baseline reference.</p><p>At a glance, as shown in Fig. 2, GPT-4.1 won 149 out of 189 matchups, with Simple Flow V1 winning 14 and 26 ending in a tie. The average arena score of 0.541 reflects GPT-4.1’s consistent advantage. Despite this quality gap, Simple Flow achieved a 57% reduction in cost per query, with 19.6% of queries resolved within the first two levels alone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpRH-nUlnjvz1-OCdsfFAQ.png" /><figcaption>Fig.2: Benchmark Results of the Simple Flow v1 vs ChatGPT 4.1</figcaption></figure><p>Fig. 3 breaks down the quality-cost relationship in more detail. The cost dynamic is most visible at the extremes. Queries resolved at Level 1 cost an average of just $0.0001, roughly 80 times cheaper than the GPT-4.1 baseline, though GPT-4.1 won 93.8% of those evaluations (15 out of 16). Even Level 3, which handled the plurality of queries, came in at $0.0026, about one-third the baseline cost, with GPT-4.1 still winning 80.0% of those matchups. Notably, GPT-4.1’s win rate does narrow as the cascade escalates to stronger models: from 93.8% at Level 1 down to 72.2% at Level 5. It is worth mentioning that since the flow is incremental, the price at an upper level is cumulative, also including the prices from the lower levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8P5NuDBBUkeWnavZjBJrhA.png" /><figcaption>Fig.3: Quality and Cost Trade-off Across the Cascade</figcaption></figure><p>Fig. 4 takes a closer look at how the judge evaluated Simple Flow’s responses. 70.4% of cases (133 out of 189) received a GPT ≫ SF verdict (A&gt;&gt;B), with the distribution of arena scores skewed heavily in GPT-4.1’s favour. The cumulative cost curve, however, confirms the 57% savings hold consistently across the full benchmark run, meaning Simple Flow is a cheaper system, even if not a higher-quality one on these benchmark questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*He3Ss76asoztmoudFSaHig.png" /><figcaption>Fig.4: Judge Verdict and Score Breakdown</figcaption></figure><p>The cascade’s efficiency is most clearly illustrated in Fig. 5. Of the 189 questions, 16 (8.5%) were resolved at Level 1, 21 (11.1%) at Level 2, and 75 (39.7%) at Level 3, meaning nearly 60% of all queries were handled before the two largest and most expensive models were ever invoked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IrNkepYodlyWbw5W7OmF3g.png" /><figcaption>Fig.5: Cascade Efficiency and Funnel</figcaption></figure><p>An interesting secondary finding relates to answer length in Fig. 6. GPT-4.1 produced answers averaging 3,534 characters, while Simple Flow’s cascade produced answers averaging 1,188 characters. Despite its conciseness, Simple Flow’s answers were judged as lower quality in the majority of cases, suggesting that for the hard-prompt benchmark used here, more detailed responses tend to score better with the judge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nm0plUJaCxfLWeX0WBvWA.png" /><figcaption>Fig.6: Answer Length of Simple Flow vs ChatGPT 4.1</figcaption></figure><h3><strong>Experiment #2</strong></h3><p>Based on the results, it was decided to run the same experiment again, but with a different configuration of working agents in the hope of obtaining better results:<br>- Worker 1: Meta Llama 3.1 8B (8 billion parameters | $0.02/M input tokens | $0.05/M output tokens)<br>- Worker 2: Mistral Small 3.2 24B (24 billion parameters | $0.06/M input tokens | $0.18/M output tokens)<br>- Worker 3: Qwen 3 32B (32 billion parameters | $0.08/M input tokens | $0.24/M output tokens)<br>- Worker 4: Meta Llama 3.1 70B (70 billion parameters | $0.40/M input tokens$0.40/M | output tokens)<br>- Worker 5: DeepSeek V3.1 (37 billion parameters | $0.15/M input tokens | $0.75/M output tokens)</p><p>At first glance, in Fig. 7, Simple Flow V2 achieved a 41.6% cost reduction compared to the GPT-4.1 baseline. The quality picture remained similar to V1: GPT-4.1 won 76 out of 98 match-ups (77.6%), with Simple Flow V2 winning only 7 (7.1%) and 15 (15.3%) ending in a tie. The average Arena score of 0.538 reflects a distribution skewed heavily toward GPT-4.1, with 80 of 98 verdicts being A≫B (a strong win for the baseline).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNw9ZWykK2LWqcIRe-XDCA.png" /><figcaption>Fig.7: Benchmark Results vs ChatGPT 4.1</figcaption></figure><p>Fig. 8 breaks down the relationship between cost and quality across each escalation level. Queries resolved early are dramatically cheaper, with Level 1 averaging just $0.00021 per query, roughly 97% cheaper than the GPT-4.1 baseline, and Level 2 coming in at $0.00132, still 84% below baseline. Level 3 averaged $0.00405, approximately half the GPT-4.1 cost. Crucially, however, the cost advantage disappears at the top of the cascade. Level 5, reached by 17 queries, averaged $0.01023, more expensive than the GPT-4.1 baseline, while still losing the majority of those evaluations. This is a key difference from V1, where the top-tier model at least remained cost-competitive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzfPrSGAZmBGJnYtDYNFzg.png" /><figcaption>Fig.8: Quality and Cost Trade-off Across the Cascade</figcaption></figure><p>Despite the quality challenges, the cascade’s structural efficiency held up well (Fig. 9). The judge accepted Simple Flow’s response before exhausting the full pipeline in 70 out of 98 questions. Of these, 7 were resolved at Level 1, 17 at Level 2, and 32 at Level 3, meaning 57.1% of all queries were resolved by Level 3, before the two most expensive workers were ever invoked. An additional 7 queries were resolved at Level 4, and 7 at Level 5.<br>The remaining 28 queries were never accepted by the judge, even after all five levels, with the highest-capability model’s output returned as the final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FWUrIv0mH30RKQE7tpKzjw.png" /><figcaption>Fig.9: Cascade Efficiency</figcaption></figure><h3>Experiment #3</h3><p>The previous experiment raised an important structural question: does a longer cascade actually pay off, or do the gains from early termination get cancelled out by expensive tail queries?</p><p>To test this, the experiment was run a third time with a simplified three-model configuration:</p><p>- Worker 1: Qwen 3 32B (32 billion parameters | $0.08/M input tokens | $0.24/M output tokens)<br>- Worker 2: Meta Llama 3.1 70B (70 billion parameters | $0.40/M input tokens$0.40/M | output tokens)<br>- Worker 3: DeepSeek V3.1 (37 billion parameters | $0.15/M input tokens | $0.75/M output tokens)</p><p>It is importan to note that having a smaller number of levels, the overall cost of the upper levels should diminish because we have fewer levels to account for.</p><p>As shown in Fig. 10, Simple Flow achieved a 30.9% cost reduction compared to the GPT-4.1 baseline. The quality picture marks a dramatic shift from all previous runs: Simple Flow won 84 out of 146 matchups (57.5%), with GPT-4.1 winning only 32 (21.9%) and 30 (20.5%) ending in a tie. This is the first configuration in which Simple Flow outright wins the majority of matchups against GPT-4.1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OhY9n0OaZMkHjMOA1F9Cig.png" /><figcaption>Fig.10: Benchmark Results of the Simple Flow v2 (3 levels) vs ChatGPT 4.1</figcaption></figure><p>Fig. 11 breaks down the relationship between cost and quality across each escalation level. Level 1 averages just $0.0026 per query, though GPT-4.1 still wins 26% of evaluations at this tier. Level 2 comes in at $0.0087 and wins 73.6% of matchups. By Level 3, the cost advantage has essentially evaporated, yet Simple Flow still wins 62.5% of those matchups — making the top of the cascade genuinely competitive on quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTEuOOqh06B6QIa3PHFLxw.png" /><figcaption>Fig.11: Quality and Cost Trade-off Across the Cascade</figcaption></figure><p>Fig. 12 takes a closer look at how the judge evaluated Simple Flow’s responses. The arena score distribution is now in favor of Simple Flow, with 86 negative-score verdicts versus 32 positive-score verdicts. The cumulative cost curve confirms the 30.9% savings hold consistently across the full benchmark run. For the first time, Simple Flow is both the cheaper and the higher-quality system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z58d_OnC1Y4roM0BnRD50w.png" /><figcaption>Fig.12: Jugde Verdict and Score Breakdown</figcaption></figure><p>The cascade’s structural efficiency is illustrated in Fig. 13. Of the 146 questions, 78 (53.4%) were resolved at Level 1 alone, more than half of all queries handled by the smallest, cheapest model. A further 54 (37.0%) were resolved at Level 2, and only 14 (9.6%) escalated to Level 3. This means 90.4% of queries were resolved without ever reaching the most expensive model. A total of 22 queries (15.1%) were never accepted by the judge, with the Level 3 output returned as the final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrI8qkN8deDTX0d4nV9wMw.png" /><figcaption>Fig.13: Cascade Efficiency</figcaption></figure><p>An interesting finding emerges in Fig. 14. Unlike V1, where Simple Flow produced answers averaging just 1,188 characters, shorter than GPT-4.1’s 3,534, the 3-level configuration produces answers averaging 7,228 characters, nearly double GPT-4.1’s 3,569. This verbosity is most pronounced at Levels 2 and 3, where the cascade’s iterative refinement produces longer, more detailed responses. Unlike the V1 finding where conciseness correlated with lower quality, here the combination of length and refinement drives genuinely better outcomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpi7CNiUSmyhOpCf6mLfWQ.png" /><figcaption>Fig.14: Answer Length of Simple Flow vs ChatGPT 4.1</figcaption></figure><h3>Conclusion</h3><p>The experiments proved that unsophisticated questions can be answered correctly by a flow of models that are both smaller and cheaper, a result which is comparable with the answers from OpenAI’s ChatGPT 4.1. Further configurations and matches of models, as well as structured output via Pydantic, can be explored for enhanced outcomes.</p><p>The next article from this series will explore what can be obtained from a cascade of models that collaborate and debate each other, and whether they can provide acceptable outcomes for complex questions. Stay tuned!</p><p>This project was made possible with the support of the Innovate Moldova Programme, financed by Sweden and the United Kingdom.</p><p>Made with ❤️ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e9e20517ea5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/smaller-smarter-cheaper-rethinking-llm-orchestration-for-cost-efficiency-5e9e20517ea5">Smaller, Smarter, Cheaper? Rethinking LLM Orchestration for Cost Efficiency</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advancements in Object Detection: A Comprehensive Analysis of Two-Stage Models]]></title>
            <link>https://medium.com/softplus-publication/advancements-in-object-detection-a-comprehensive-analysis-of-two-stage-models-7a3d6ec2bddb?source=rss-7b582a5cd74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a3d6ec2bddb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[two-stage-models]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Sun, 07 Jul 2024 16:09:48 GMT</pubDate>
            <atom:updated>2024-07-12T11:49:58.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*LnzACGn9tUG46udviAM1hQ.png" /></figure><h4>Abstract</h4><p>The concept of object detection, an important task in Computer Vision, might not be well-known to the daily users of technology, but it has various applications in real-life problems. In this article, we will describe the magic behind object detection algorithms, primarily focusing on two-stage models. The research methodology consists of an analysis of two-stage models, highlighting their architecture. The research question is: what are the architectures, advantages, and limitations of two-stage models in object detection?</p><p><strong>Keywords:</strong> Object Detection, Two-Stage Models, R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN, CNN</p><h4><strong>Introduction</strong></h4><p>Object detection is a Computer Vision problem that detects visual items of specific kinds (animals, humans) in digital pictures like photographs or video frames. The purpose of object detection is to create computational models that answer the most basic question that computer vision applications have: “What things are there and where are they?”¹</p><p>For humans, object detection is an effortless task, because it was there throughout their whole evolution. However, for machines, object detection is a complex challenge to be tackled and significant efforts have been done to develop such algorithms. Among these, an important role was played by two-stage models, that offer enhanced accuracy in object detection tasks compared to one-stage models. In the following paragraphs, we will discuss the architecture, functionality, and effectiveness of two-stage models in Computer Vision.</p><h4>What are two-stage models?</h4><p>Two-stage models are Machine Learning models that locate objects in an image and predict their class in two steps. The first step is a regression problem while the second one is a classification problem².</p><p>The first step is a <strong>Regional Proposal Network (RPN)</strong> that scans the regions in an image and proposes them as candidates to be recognized as objects.</p><p>The second step is a <strong>Classifier</strong> that receives as input the regions proposed by the RPN and tries to classify them into an object class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4s4WRGxRQsKW9R01xNqRA.png" /><figcaption><strong>Fig.1</strong> Two-stage detector architecture (Source: <a href="https://www.mdpi.com/1424-8220/23/21/8981">https://www.mdpi.com/1424-8220/23/21/8981</a>)</figcaption></figure><p>The two-stage model pioneer is R-CNN, whose limitations were improved by the Fast R-CNN and Faster R-CNN models. Later Mask R-CNN was created for enhanced accuracy and faster predictions.</p><h4>What is R-CNN?</h4><p>Region-based Convolutional Neural Network (R-CNN) is a type of deep learning architecture that works by proposing a region-of-interest (RoI), extracting features with CNN, and classifying those regions based on the extracted features.</p><p>More concretely, the R-CNN consists of the following four steps:</p><ol><li><strong>Region Proposals</strong>: The first step involves generating region proposals using a method like Selective Search. This step identifies potential regions in an image that may contain objects. Typically, around 2000 region proposals are generated for each image.</li><li><strong>Feature Extraction</strong>: Each region proposal is then resized to a fixed size (e.g., 224×224 pixels) and passed through a pre-trained CNN to extract features. This CNN acts as a feature extractor, producing a fixed-length feature vector for each region.</li><li><strong>Classification</strong>: The extracted feature vectors are then fed into a set of Support Vector Machines (SVMs), where each SVM is trained to classify a specific object category. These SVMs determine the presence of objects within the proposed regions.</li><li><strong>Bounding Box Regression</strong>: To improve localization accuracy, a bounding box regressor is applied to refine the coordinates of the proposed regions. This step adjusts the bounding boxes to better fit the objects³.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*m_gGw6vtHrBG2Ud_.png" /><figcaption>Fig.2 R-CNN Architecture (Source: <a href="https://towardsdatascience.com/r-cnn-fast-r-cnn-faster-r-cnn-yolo-object-detection-algorithms-36d53571365e">https://towardsdatascience.com/r-cnn-fast-r-cnn-faster-r-cnn-yolo-object-detection-algorithms-36d53571365e</a>)</figcaption></figure><p>R-CNN can handle many object classes, but it is computationally expensive, which leads to resource and time consumption. Depending on the training manner, it might have to classify, for example, 2000 region proposals per image which leads to increased training time. Each part of the model requires training separately and cannot be paralleled. As well, the testing time of inference is approximately 50 seconds per image. These drawbacks led to the introduction of the next model.</p><h4>What is Fast R-CNN?</h4><p>Fast R-CNN resulted as an improvement over R-CNN that addresses the computational inefficiency of the original method. It achieves this by using a single CNN to process the entire image and generate the ROIs rather than running the CNN on each ROI individually.</p><p>The Fast R-CNN algorithm includes:</p><ol><li><strong>Region proposal:</strong> In this step, a set of ROIs is generated using a method such as selective search or edge boxes.</li><li><strong>Feature extraction:</strong> A CNN extracts features from the entire image.</li><li><strong>ROI pooling:</strong> The extracted features are then used to compute a fixed-length feature vector for each ROI. This is done by dividing the ROI into a grid of cells and max-pooling the features within each cell.</li><li><strong>Classification and bounding box regression: </strong>The fixed-length feature vectors for each ROI are fed into two fully connected (FC) layers: one for classification and one for bounding box regression. The classification FC layer predicts the object’s class within the ROI, while the bounding box regression FC layer predicts the refined bounding box coordinates for the object⁴.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3wT_MFDeQfdtPs5y.png" /><figcaption><strong>Fig.3</strong> <em>Fast R-CNN architecture (Source: </em><a href="https://www.geeksforgeeks.org/fast-r-cnn-ml/">https://www.geeksforgeeks.org/fast-r-cnn-ml/</a>)</figcaption></figure><p>Since we don’t have to pass 2000 region proposals for each image and the ConvNet operation is done only once per image, this algorithm is more time efficient. Yet, it still uses the selective search algorithm which is slow and it takes around 2 seconds per image to detect objects, which sometimes does not work properly with large real-life datasets⁵. To solve this issue, the implementation of next model was necessary.</p><h4>What is Faster R-CNN?</h4><p>Faster R-CNN is an extension of Fast R-CNN. It reduces the computational cost of object detection by using a single CNN to generate both the ROIs and the features for each ROI, rather than using a separate CNN for each task, as in Fast R-CNN.</p><p>The Faster R-CNN pipeline can be divided into four main steps:</p><ol><li><strong>Feature extraction: </strong>A CNN extracts features from the entire image.</li><li><strong>Region proposal:</strong> A set of ROIs is generated using a fully convolutional network (FCN) that processes the extracted features.</li><li><strong>ROI pooling:</strong> The extracted features are then used to compute a fixed-length feature vector for each ROI using the same ROI pooling process as in Fast R-CNN.</li><li><strong>Classification and bounding box regression: </strong>The fixed-length feature vectors for each ROI are fed into two separate FC layers: one for classification and one for bounding box regression. The classification FC layer predicts the object’s class within the ROI, while the bounding box regression FC layer predicts the refined bounding box coordinates for the object⁴.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*wysTH2z4Y-T3bYTt.jpeg" /><figcaption><strong>Fig.4</strong> <em>Faster R-CNN architecture (Source: </em><a href="https://towardsdatascience.com/faster-r-cnn-for-object-detection-a-technical-summary-474c5b857b46">https://towardsdatascience.com/faster-r-cnn-for-object-detection-a-technical-summary-474c5b857b46</a>)</figcaption></figure><p>Faster-RCNN has maintained its definite advantages in terms of detection accuracy. However, Faster-RCNN has some shortcomings such as it has not reached real-time detection. The way of getting region boxes before classification needs a huge amount of computations⁶. This limitation has led to another advanced approach, discussed next.</p><h4>What is Mask R-CNN?</h4><p>Mask R-CNN is a deep learning model that combines object detection and instance segmentation. It is an extension of the Faster R-CNN architecture.</p><p>The key innovation of Mask R-CNN lies in its ability to perform pixel-wise instance segmentation alongside object detection. This is achieved through the addition of an extra “mask head” branch, which generates precise segmentation masks for each detected object⁷.</p><p>The architecture of Mask R-CNN is built upon the Faster R-CNN architecture, with the addition of an extra “mask head” branch for pixel-wise segmentation.</p><p>The overall architecture can be divided into several key stages:</p><ol><li><strong>Backbone and RPN network:</strong> These networks run once per image to give a set of region proposals. Region proposals are regions in the feature map that contain the object.</li><li><strong>Classification and bounding box prediction</strong>: Each proposed region can be of different sizes whereas fully connected layers in the networks always require a fixed size vector to make predictions. The size of these proposed regions is fixed by using either RoI pool (which is very similar to MaxPooling) or RoIAlign method⁸.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*MuXglFj2ScGpjnte.png" /><figcaption><strong>Fig.5</strong> Mask R-CNN architecture (Source: <a href="https://developers.arcgis.com/python/guide/how-maskrcnn-works/">https://developers.arcgis.com/python/guide/how-maskrcnn-works/</a>)</figcaption></figure><p>The implementation of Mask R-CNN enables fine-grained pixel-level boundaries for accurate and detailed instance segmentation. As well it can also handle overlapping objects, which can make semantic segmentation models confuse pixels from different instances of the same class. However, this model is computationally expensive and requires memory resources which can increase with the number of classes and the resolution of masks⁹.</p><p><strong>Conclusion</strong></p><p>Two-stage models have come a long way and have had positive growth based on the lack of each ancestor. From R-CNN to Mask R-CNN, these models started from the same goal, to detect objects, and have been improved to become more efficient, faster, and to require fewer resources. By pursuing these future directions, two-stage object detection models can continue to evolve, providing efficient and accurate solutions across various fields.</p><p>Bibliography</p><p>[1]: <a href="https://www.tasq.ai/glossary/two-stage-detector/">https://www.tasq.ai/glossary/two-stage-detector/</a></p><p>[2]: <a href="https://www.machinelearningatscale.com/p/computer-vision">https://www.machinelearningatscale.com/p/computer-vision</a></p><p>[3]: <a href="https://www.geeksforgeeks.org/how-does-r-cnn-work-for-object-detection/">https://www.geeksforgeeks.org/how-does-r-cnn-work-for-object-detection/</a></p><p>[4]: <a href="https://www.shiksha.com/online-courses/articles/object-detection-using-rcnn/">https://www.shiksha.com/online-courses/articles/object-detection-using-rcnn/</a></p><p>[5]: <a href="https://medium.com/analytics-vidhya/object-detection-algorithms-r-cnn-vs-fast-r-cnn-vs-faster-r-cnn-3a7bbaad2c4a">https://medium.com/analytics-vidhya/object-detection-algorithms-r-cnn-vs-fast-r-cnn-vs-faster-r-cnn-3a7bbaad2c4a</a></p><p>[6]: <a href="https://www.researchgate.net/publication/346764538_A_brief_review_and_challenges_of_object_detection_in_optical_remote_sensing_imagery">https://www.researchgate.net/publication/346764538_A_brief_review_and_challenges_of_object_detection_in_optical_remote_sensing_imagery</a></p><p>[7]: <a href="https://blog.roboflow.com/mask-rcnn/">https://blog.roboflow.com/mask-rcnn/</a></p><p>[8]: <a href="https://developers.arcgis.com/python/guide/how-maskrcnn-works/">https://developers.arcgis.com/python/guide/how-maskrcnn-works/</a></p><p>[9]: <a href="https://www.linkedin.com/advice/3/how-does-mask-r-cnn-improve-segmentation-accuracy">https://www.linkedin.com/advice/3/how-does-mask-r-cnn-improve-segmentation-accuracy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a3d6ec2bddb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/advancements-in-object-detection-a-comprehensive-analysis-of-two-stage-models-7a3d6ec2bddb">Advancements in Object Detection: A Comprehensive Analysis of Two-Stage Models</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradio: Simplifying GUI Creation for Machine Learning]]></title>
            <link>https://medium.com/softplus-publication/gradio-simplifying-gui-creation-for-machine-learning-9ba19efc0eb4?source=rss-7b582a5cd74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ba19efc0eb4</guid>
            <category><![CDATA[gradio]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[gui]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Sat, 06 Jul 2024 22:43:57 GMT</pubDate>
            <atom:updated>2024-07-12T11:50:43.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*g_qZoo7LWG2OPgfwCoBLXg.png" /></figure><h4>Abstract</h4><p>The integration of Machine Learning models into user-friendly applications plays an important role in enhancing usability and accessibility. The creation of a Graphical User Interface is a major step into deploying the models, because it allows interaction and data input.</p><p>Gradio is an open-source package that bridges this gap for Python Developers. This paper explores the functionalities of Gradio, demonstrating how it enables the construction of GUIs with minimal coding effort. It answers the question: “How can one easily create a GUI for Machine Learning models without extensive application development background?”</p><p>Through specific examples, this article aims to demonstrate the straightforward process of building GUIs with Gradio.</p><p><strong>Keywords: </strong>Application development, Gradio, Graphical User Interface (GUI), Machine Learning, Model deployment, Python, User-friendly applications</p><h4>Introduction</h4><p>When working with Machine Learning models, there is a variety of models and options to choose from. Depending on the data and the goal one wants to achieve, the user might choose a model for classification or regression, one oriented on Natural Language Processing or Computer Vision. Yet, one more important step that ensures the usability of models is the creation of a Graphical User Interface.</p><p>A graphical user interface (GUI) is a digital interface in which a user interacts with graphical components such as icons, buttons, and menus. Such an interface can be obtained by creating a computer, mobile, or web application which would include the Machine Learning model. However such products require knowing additional programming languages and frameworks. To address this challenge and to ensure that individuals who code in Python can easily construct a GUI, Gradio has been developed.</p><h4>What is Gradio?</h4><p>Gradio is an open-source Python package that allows programmers to quickly build a demo or web application for their machine learning model, API, or any arbitrary Python function. One of the most exciting parts is that they can then share a link to their demo or web application in just a few seconds using Gradio’s built-in sharing features¹.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iXS3S4G8e-V-3r7T" /><figcaption><strong>Fig.1</strong> Gradio (Source: <a href="https://pypi.org/project/gradio/">https://pypi.org/project/gradio/</a>)</figcaption></figure><h4><strong>Why choose Gradio?</strong></h4><p>Gradio supports various applications, from showcasing machine learning models to debugging and deploying data science workflows. It integrates with the Python ecosystem, providing real-time feedback and becoming an ideal choice for Python developers seeking to enhance their projects with user-friendly GUIs.</p><h4><strong>Get started</strong></h4><p>Note: For the tutorial, I will use Google Colab.</p><p><strong>Install Gradio</strong></p><p>Create a new code block and run:</p><pre>!pip install gradio</pre><p>Next, import Gradio:</p><pre>import gradio as gr</pre><p>Now we are ready to proceed further!</p><p><strong>How to create your first interfaces?</strong></p><p>Gradio offers the flexibility to handle different types of input and output, including text, images, audio, and video.</p><p>For our initial application, we will use the text functionality. We will create a new code block where we will write:</p><pre>def greet(name):<br>    return &quot;Hello, &quot;+ name + &quot;!&quot;<br><br>iface = gr.Interface(<br>    fn=greet,<br>    inputs=gr.Textbox(info=&quot;Input your name&quot;, placeholder=&quot;Name&quot;, label=&quot;Name&quot;),<br>    outputs=gr.Textbox(label=&quot;Message&quot;),<br>)<br><br>iface.launch()</pre><p>The gr.Interface method is used to create a user interface for the greet function. It accepts several parameters: the function itself (greet), the type of input elements to present (gr.Textbox in our scenario, whose value is sent as a parameter to the greet function), and the type of output to display (gr.Textbox here, which displays the value returned by the greet function).</p><p>The final product should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*8FJc53PsDRuUfgPokAqGwg.gif" /><figcaption><strong>Fig.2</strong> The output of the greet function</figcaption></figure><p>Next, we will create another application that takes input from the user and returns a sentence based on the input.</p><pre>def build_sentence(season, weather, temperature, enjoy_weather):<br>    sentence = f&quot;In {season}, with {weather} weather and {temperature} degrees Celsius outside, you {&#39;enjoy&#39; if enjoy_weather == &#39;Yes&#39; else &#39;do not enjoy&#39;} the weather.&quot;<br>    return sentence<br><br>iface = gr.Interface(<br>    fn=build_sentence,<br>    inputs=[<br>        gr.Dropdown(choices=[&#39;Winter&#39;, &#39;Spring&#39;, &#39;Summer&#39;, &#39;Autumn&#39;], info=&quot;Select the season&quot;, label=&quot;Season&quot;),<br>        gr.Dropdown(choices=[&#39;freezing&#39;, &#39;warm&#39;, &#39;hot&#39;, &#39;cold&#39;], info=&quot;Select the weather&quot;, label=&quot;Weather&quot;),<br>        gr.Slider(minimum=-30, maximum=60, step=2, info=&quot;How many degrees Celsius are outside?&quot;, label=&quot;Temperature&quot;),<br>        gr.Radio([&#39;Yes&#39;, &#39;No&#39;], info=&quot;Do you enjoy the weather?&quot;, label=&quot;Emotion&quot;)<br>    ],<br>    outputs=gr.Textbox(label=&quot;Sentence&quot;)<br>)<br><br>iface.launch()</pre><p>In this code, we create an interface for a function named build_sentence that constructs a sentence about weather conditions based on input parameters such as season, weather type, temperature, and whether the user enjoys the weather or not.</p><p>The interface includes dropdown menus, gr.Dropdown, for selecting the season (Winter, Spring, Summer, Autumn) and the weather type (freezing, warm, hot, cold). Additionally, a slider, gr.Slider, allows users to specify the temperature in degrees Celsius, ranging from -30 to 60 in steps of 2. This interface also provides radio buttons, gr.Radio, to indicate whether the user enjoys the weather (Yes or No).</p><p>All these inputs are sent as parameters to the build_sentence function which creates a string that is returned to the interface and displayed as output.</p><p>The final product looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*itNsX6T952vvo8aBCSTirA.gif" /><figcaption><strong>Fig.3</strong> The output of the make_sentence function</figcaption></figure><p>For more examples, you can refer to the documentation of Gradio, available <a href="https://www.gradio.app/guides/quickstart">here</a>.</p><p><strong>How to use Gradio for Machine Learning?</strong></p><p>As mentioned above, Gradio is a great tool to create GUI for Machine Learning tools. To exemplify this, let’s work on a real dataset.</p><p>For this project, I will use the Mushroom Classification dataset².</p><p>Import the necessary libraries and load the dataset:</p><pre># Import libraries<br>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn  as sns<br>import gradio as gr<br>import pickle</pre><pre># Load dataset<br>dataset = pd.read_csv(&#39;/content/mushrooms.csv&#39;)<br>dataset.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xV35YcBWWHef9Srk_O5b3A.png" /><figcaption><strong>Fig.4</strong> The head of the dataset</figcaption></figure><p>The dataset consists of 23 columns:</p><ul><li><strong>class: </strong>edible = e, poisonous = p;</li><li><strong>cap-shape:</strong> bell = b, conical = c, convex = x, flat = f, knobbed = k, sunken = s;</li><li><strong>cap-surface:</strong> fibrous = f, grooves = g, scaly = y, smooth = s;</li><li><strong>cap-color:</strong> brown = n, buff = b, cinnamon = c, gray = g, green = r, pink = p, purple = u, red = e, white = w, yellow = y;</li><li><strong>bruises:</strong> bruises = t, no = f;</li><li><strong>odor:</strong> almond = a, anise = l, creosote = c, fishy = y, foul = f, musty = m, none = n, pungent = p, spicy = s;</li><li><strong>gill-attachment:</strong> attached = a, descending = d, free = f, notched = n;</li><li><strong>gill-spacing:</strong> close = c, crowded = w, distant = d;</li><li><strong>gill-size: </strong>broad = b, narrow = n;</li><li><strong>gill-color:</strong> black = k, brown = n, buff = b, chocolate = h, gray = g, green = r, orange = o, pink = p, purple = u, red = e, white = w, yellow = y;</li><li><strong>stalk-shape: </strong>enlarging = e, tapering = t;</li><li><strong>stalk-root:</strong> bulbous = b, club = c, cup = u, equal = e, rhizomorphs = z, rooted = r, missing = ?;</li><li><strong>stalk-surface-above-ring:</strong> fibrous = f, scaly = y, silky = k, smooth = s;</li><li><strong>stalk-surface-below-ring:</strong> fibrous = f, scaly = y, silky = k, smooth = s;</li><li><strong>stalk-color-above-ring: </strong>brown = n, buff = b, cinnamon = c, gray = g, orange = o, pink = p, red = e, white = w, yellow = y;</li><li><strong>stalk-color-below-ring: </strong>brown = n, buff = b, cinnamon = c, gray = g, orange = o, pink = p, red = e, white = w, yellow = y;</li><li><strong>veil-type:</strong> partial = p, universal = u;</li><li><strong>veil-color:</strong> brown = n, orange = o, white = w, yellow = y;</li><li><strong>ring-number:</strong> none = n, one = o, two = t;</li><li><strong>ring-type: </strong>cobwebby = c, evanescent = e, flaring = f, large = l, none = n, pendant = p, sheathing = s, zone = z;</li><li><strong>spore-print-color: </strong>black = k, brown = n, buff = b, chocolate = h, green = r, orange = o, purple = u, white = w, yellow = y;</li><li><strong>population: </strong>abundant = a, clustered = c, numerous = n, scattered = s, several = v, solitary = y;</li><li><strong>habitat: </strong>grasses = g, leaves = l, meadows = m, paths = p, urban = u, waste = w, woods = d.</li></ul><p>I am interested in predicting whether a mushroom is edible or not.</p><p>I will skip some steps such as checking for NaN values or duplicate rows as this is outside the scope of this paper, but the full code is available on GitHub³.</p><p>I can get the statistical summary of this dataset using:</p><pre>dataset.describe()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vhfFn47M51ji_Wn2vTZraA.png" /><figcaption><strong>Fig.5</strong> Statistical summary of the dataset</figcaption></figure><p>However, for large datasets, this is hard to read. We can improve this by creating an interface in Gradio that allows analyzing each column separately.</p><pre># Define a function to generate summary statistics for a specified column<br>def summary_statistics(column_name):<br>    summary = dataset[column_name].describe()  # Generate descriptive statistics for the selected column<br>    return summary.to_dict()  # Convert the pandas Series to a dictionary and return it<br><br># Get a list of column names from the dataset<br>column_names = dataset.columns.tolist()<br><br># Set up a Gradio interface<br>iface = gr.Interface(<br>    fn=summary_statistics,  # Function to call when inputs change<br>    inputs=gr.Dropdown(choices=column_names, label=&quot;Column&quot;, info=&quot;Select Column&quot;),  # Dropdown to select a column<br>    outputs=gr.JSON(label=&quot;Summary Statistics&quot;),  # Output field to display summary statistics as JSON<br>    live=True  # Allow live updates while selecting different columns<br>)<br><br># Launch the Gradio interface<br>iface.launch()</pre><p>This code creates a tool to analyze data columns interactively. It defines a function summary_statistic that computes and displays descriptive statistics for a selected column in a dataset. Using inputs, it sets up a dropdown menu where users can choose a column to analyze. When selected, the function computes statistics and displays them in a user-friendly JSON format. The interface looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9wjTgVYLOh_U147XphGrg.png" /><figcaption><strong>Fig.6</strong> Statistical summary of each column using Gradio</figcaption></figure><p>For the univariate analysis, we can create for each column individually a plot. For example, we will create a histogram for the class column:</p><pre>sns.histplot(dataset[&#39;class&#39;])<br>plt.xlabel(&quot;Class&quot;)<br>plt.ylabel(&quot;Count&quot;)<br>plt.title(&quot;Distribution of Mushrooms by Class&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YGLssnxoRF3SyK5wkKxJ8w.png" /><figcaption><strong>Fig.7</strong> Distribution of the mushrooms by class</figcaption></figure><p>But it would take a bit of time to plot individually for each column such a histogram. Gradio can help us to create an interface to visualize each column in a more time-efficient way.</p><pre># Define a function to plot a histogram for a specified column<br>def plot_column(column_name):<br>    plt.figure(figsize=(10, 6)) # Set up the figure size<br>    sns.histplot(dataset[column_name], kde=False) # Plot the histogram using seaborn<br>    plt.title(f&#39;Distribution of Mushrooms by {column_name}&#39;) # Set the plot title<br>    plt.xlabel(column_name) # Set the label for the x-axis<br>    plt.ylabel(&#39;Count&#39;) # Set the label for the y-axis<br>    plt.xticks(rotation=90) # Rotate x-axis labels for better readability<br>    plt.tight_layout() # Ensure the plot layout is tight<br>    return plt.gcf() # Return the current figure<br><br># Get a list of column names from the dataset<br>column_names = dataset.columns.tolist()<br><br># Set up a Gradio interface<br>iface = gr.Interface(<br>    fn=plot_column, # Function to call when inputs change<br>    inputs=gr.Dropdown(choices=column_names, label=&quot;Select Column&quot;),  # Dropdown to select a column<br>    outputs=gr.Plot(), # Output field to display the plot<br>    live=True # Allow live updates while selecting different columns<br>)<br><br># Launch the Gradio interface<br>iface.launch()</pre><p>This code defines a function plot_column that uses seaborn (sns) to plot histograms based on the selected column chosen as input at inputs. The Gradio interface allows users to choose a column from a dropdown menu and see its histogram instantly. The final result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdEwUduRDoefyNvUuLrioQ.png" /><figcaption><strong>Fig.8</strong> Plotting histograms using Gradio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHlS-AjVioLUk4wRq40M_w.png" /><figcaption><strong>Fig.9</strong> Plotting histograms using Gradio</figcaption></figure><p>For the multivariate analysis, we can also add a new input for the hue, which will help us visualize better specific characteristics of this dataset.</p><pre># Define a function to plot a count plot with hue<br>def plot_count(column1, hue_column):<br>    plt.figure(figsize=(12, 6)) # Set up the figure size<br>    sns.countplot(x=dataset[column1], hue=dataset[hue_column]) # Plot countplot using seaborn<br>    plt.title(f&#39;Count Plot of {column1} with Hue {hue_column}&#39;) # Set the plot title<br>    plt.xticks(rotation=45) # Rotate x-axis labels for better readability<br>    plt.tight_layout() # Ensure the plot layout is tight<br>    return plt.gcf() # Return the current figure<br><br># Get a list of column names from the dataset<br>column_names = dataset.columns.tolist()<br><br># Set up a Gradio interface<br>iface = gr.Interface(<br>    fn=plot_count, # Function to call when inputs change<br>    inputs=[gr.Dropdown(choices=column_names, label=&quot;Column 1&quot;), # Dropdown to select the first column<br>            gr.Dropdown(choices=column_names, label=&quot;Hue Column&quot;)], # Dropdown to select the hue column<br>    outputs=gr.Plot(), # Output field to display the plot<br>    live=True # Allow live updates while selecting different columns<br>)<br><br># Launch the Gradio interface<br>iface.launch()</pre><p>This code sets up an interactive tool to plot count plots with a specified column (Column 1) on the x-axis and another column (Hue Column) as a distinguishing factor (hue) using seaborn (sns). Users select columns from dropdown menus in the Gradio interface to visualize how categories in Column 1 are distributed based on categories in Hue Column. The interface has the following aspect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMb3yJEYCkJrWCombB7KtQ.png" /><figcaption><strong>Fig.10</strong> Plotting countplots using Gradio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TI4cX3tyeNUDQPmMOj_WqA.png" /><figcaption><strong>Fig.11</strong> Plotting countplots using Gradio</figcaption></figure><p>Now that the visualization part is over, it’s time to build our model.</p><p>We will prepare the data by splitting it into the X and y set, where X contains all columns except ‘class’ and y contains only the target column — ‘class’.</p><pre># Separate features (X) and target variable (y) from the dataset<br>X = dataset.drop([&#39;class&#39;], axis=1) # X contains all columns except &#39;class&#39;<br>y = dataset[&#39;class&#39;] # y contains only the &#39;class&#39; column</pre><p>Since the dataset contains categorical data, we will apply One-Hot Encoding on X and LabelEncoder() on y.</p><pre># Convert categorical variables into dummy variables<br>X = pd.get_dummies(X)<br>X.head()</pre><pre>from sklearn.preprocessing import LabelEncoder <br>encoder = LabelEncoder()  # Create an instance of LabelEncoder<br>y = encoder.fit_transform(y) # Transform the target variable (y) into numerical labels</pre><p>We will save the column names of data frame X into a file. These names will serve as reference points during the interface creation process.</p><pre>with open(&#39;column_names.txt&#39;, &#39;w&#39;) as file:<br>    file.write(&#39;\n&#39;.join(X.columns))</pre><p>Split the dataset into the Train set and Test set.</p><pre>from sklearn.model_selection import train_test_split  <br># Split the dataset into training and testing sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)</pre><p>To predict the values, we will use the Logistic Regression model from the Scikit-learn library.</p><pre>from sklearn.linear_model import LogisticRegression<br>model = LogisticRegression()  # Create an instance of LogisticRegression<br># Train the Logistic Regression model<br>model.fit(X_train, y_train)</pre><p>To be able to use the interface without fitting the model and the encoder each time, we will save them into pickle files and we will import them when necessary.</p><pre>pickle_out = open(&quot;classifier.pkl&quot;, mode=&quot;wb&quot;) # Open a file named &quot;classifier.pkl&quot; in write-binary mode (&#39;wb&#39;)<br>pickle.dump(model, pickle_out) # Serialize (pickle) the trained model (model) and write it to the file<br>pickle_out.close() # Close the pickle file</pre><pre>pickle_out = open(&quot;encoder.pkl&quot;, mode=&quot;wb&quot;) # Open a file named &quot;encoder.pkl&quot; in write-binary mode (&#39;wb&#39;)<br>pickle.dump(encoder, pickle_out) # Serialize (pickle) the encoder object (encoder) and write it to the file<br>pickle_out.close() # Close the pickle file</pre><p>Now we have all the necessary tools to build our interface.</p><p>Load all the necessary files and define the columns:</p><pre># Load the model<br>with open(&quot;/content/classifier.pkl&quot;, &quot;rb&quot;) as pickle_in:<br>    model = pickle.load(pickle_in)<br><br># Load the encoder<br>with open(&quot;/content/encoder.pkl&quot;, &quot;rb&quot;) as pickle_in:<br>    encoder = pickle.load(pickle_in)<br><br># Load dataset<br>dataset = pd.read_csv(&#39;/content/mushrooms.csv&#39;)<br><br># Define column names from the original dataset for the interface<br>columns = dataset.columns.drop(&#39;class&#39;).tolist()<br><br># Define column names based on the one-hot encoded dataset<br>with open(&#39;/content/column_names.txt&#39;, &#39;r&#39;) as file:<br>    columns_fit = file.read().splitlines()</pre><p>The script first loads the pre-trained machine learning model and the encoder, which were saved in theclassifier.pkl and encoder.pkl files respectively. It then loads the mushroom dataset into a Pandas DataFrame and defines column names based on both the original dataset and the one-hot encoded format used during training, retrieved from the column_names.txt file.</p><pre># Function to preprocess input data<br>def preprocess_input(input_data):<br>    input_dict = {col: 0 for col in columns_fit}     # Initialize an input dictionary with all columns set to 0<br>    index = 0<br>    for element in input_data: # Iterate through each element in input_data and set corresponding keys to 1 in input_dict<br>        input_dict[f&quot;{columns[index]}_{element}&quot;] = 1<br>        index += 1<br>    return pd.DataFrame([input_dict]) # Create a DataFrame from the input dictionary<br><br># Function to predict class<br>def predict_class(*inputs):<br>    inputs_list = []<br>    for input in inputs: # Gather all inputs into a list<br>        inputs_list.append(input)<br>    input_data = preprocess_input(inputs_list) # Preprocess the input data<br>    prediction = model.predict(input_data) # Predict using the trained model<br>    predicted_class = encoder.inverse_transform(prediction)[0] # Convert predicted label index back to the original class label<br>    return predicted_class<br><br># Define Gradio interface<br>iface = gr.Interface(<br>    fn=predict_class, # Function to be executed when inputs are provided<br>    inputs=[gr.Dropdown(label=col, choices=dataset[col].unique().tolist()) for col in columns], # Dropdowns for selecting input values<br>    outputs=gr.Textbox(label=&quot;Predicted Class&quot;), # Textbox to display the predicted class<br>    title=&#39;\U0001F344 Mushroom Edibility Prediction&#39;, # Title of the Gradio interface<br>    description=&#39;Predict if a mushroom is edible or poisonous based on its characteristics.&#39; # Description of the Gradio interface<br>)<br><br># Launch Gradio interface<br>iface.launch() </pre><p>To make predictions, the script includes a function preprocess_input that preprocesses user-selected mushroom characteristics received as input from inputs into a format compatible with the model and respects the one-hot encoded format on which the model was trained.</p><p>Another function, predict_class, predicts whether the mushroom is edible or poisonous based on the data frame received from the preprocess_input function, using the loaded model, and provides a human-readable prediction using the inverse_transform() method of the encoder. This result is returned to the Gradio interface which displays it as output. The final result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzG84rLj6xHyRCIjNoPz0g.png" /></figure><p><strong>Conclusion</strong></p><p>In this project, we successfully implemented interactive interfaces using Gradio to enhance data handling and user interaction in Machine Learning. These interfaces streamline data management tasks, significantly improving accessibility and efficiency. Gradio’s intuitive features not only simplify complex processes but also highlight its capability to save time</p><h4>Bibliography</h4><p>[1] <a href="https://www.gradio.app/guides/quickstart">https://www.gradio.app/guides/quickstart</a></p><p>[2] <a href="https://www.kaggle.com/datasets/uciml/mushroom-classification">https://www.kaggle.com/datasets/uciml/mushroom-classification</a></p><p>[3] <a href="https://github.com/MihaelaCatan04/Gradio-Tutorial.git">https://github.com/MihaelaCatan04/Gradio-Tutorial.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba19efc0eb4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/gradio-simplifying-gui-creation-for-machine-learning-9ba19efc0eb4">Gradio: Simplifying GUI Creation for Machine Learning</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can Artificial Intelligence Outsmart Us?]]></title>
            <link>https://medium.com/softplus-publication/can-artificial-intelligence-outsmart-us-673152fca9a?source=rss-7b582a5cd74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/673152fca9a</guid>
            <category><![CDATA[sigmoid]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Wed, 24 Aug 2022 14:56:35 GMT</pubDate>
            <atom:updated>2022-08-24T14:56:35.651Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OH3XONe8tiJ48s2IgZaHwQ.jpeg" /></figure><p>Artificial Intelligence is a theory and development of computer systems that can perform tasks that usually require human intelligence. Speech recognition, decision-making, and visual perception are, for example, features of human intelligence that Artificial Intelligence may possess.</p><p>Humans can learn as they go along — in other words, learn from experience. However, Artificial Intelligence Machines can also do that. It is called Machine Learning. Yet, there are many differences between Human and Artificial Intelligence. As a consequence, people started worrying about whether Artificial Intelligence is able to outsmart us.</p><p>Will the technology progress to a point where a machine, computer or robot, will be in the position to control society, in part or as a whole?</p><p>Well, on a certain level, Artificial Intelligence is already outsmarting humans in certain tasks such as image recognition and language translation. Computers are known for storing vast amounts of information, processing and retrieving data to solve problems with much higher speed and accuracy.</p><p>Yet, Artificial Intelligence is still not a danger for people. In movies, when something goes wrong with Artificial Intelligence, it’s usually because Artificial Intelligence has decided that it doesn’t want to obey humans anymore, and it’s got its own goals. In real life, though, the Artificial Intelligence that we actually have is not nearly smart enough for that. It has the approximate computing power of an earthworm. So, today’s Artificial Intelligence can do a task like identifying a pedestrian in a picture, but it doesn’t have a concept of what the pedestrian is beyond that it’s a collection of lines and textures and things. It doesn’t know what a human actually is. So, will today’s Artificial Intelligence do what we ask it to do? It will if it can, but it might not understand itself what it really means.</p><p>As a result, even though Artificial Intelligence can do certain tasks and calculations faster, as well as easier, than the human brain, in reality, there are still required people to tell this Artificial Intelligence what to look up for.</p><p>So, in the present, you can be assured that there aren’t any machines that are trying to take your place. Most likely, they are designed to help you and make your work life a little bit easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Y5-Qs4SK3N8A3helzZRDAw.gif" /></figure><p>Made with ❤ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><p>For more information, we recommend the sources:</p><p><a href="https://www.ted.com/talks/janelle_shane_the_danger_of_ai_is_weirder_than_you_think">https://www.ted.com/talks/janelle_shane_the_danger_of_ai_is_weirder_than_you_think</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=673152fca9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/can-artificial-intelligence-outsmart-us-673152fca9a">Can Artificial Intelligence Outsmart Us?</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Latest Advancements in the Artificial Intelligence Field]]></title>
            <link>https://medium.com/softplus-publication/latest-advancements-in-the-artificial-intelligence-field-3eae52c055a5?source=rss-7b582a5cd74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3eae52c055a5</guid>
            <category><![CDATA[sigmoid]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[softplus]]></category>
            <category><![CDATA[softpluspublication]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Sat, 04 Jun 2022 12:27:17 GMT</pubDate>
            <atom:updated>2022-06-04T12:27:17.313Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*jnGKV5aF6M6XaMmqf2drew.png" /></figure><p>The advancements in the Artificial Intelligence Field are being made very quickly.</p><p>Every three months, the speed of Artificial Intelligence computation doubles, according to Stanford University’s 2019 AI Index report.</p><p>Consequently, in the last five years, the field of Artificial Intelligence has made major progress in almost all its standard sub-areas, including vision, speech recognition and generation, natural language processing (understanding and generation), image and video generation, multi-agent systems, planning, decision-making, and integration of vision and motor control for robotics.</p><p>Let’s find out together in what manner these sub-areas have been developing.</p><h4><strong>Chatbots</strong></h4><p>The chatbot industry is becoming the driving force of business communications. Natural Language Processing (NLP) bots use sentiment analysis and predictive analytics to understand the conversations and the intent of the queries intelligently.</p><p>Businesses now are more focused on building chatbots that are indistinguishable from humans with the help of Machine Learning (ML), Artificial Intelligence (AI), and Natural Language Processing (NLP).</p><p>Here are some relatively new chatbot trends:</p><ul><li>Payments via chatbots</li><li>Voice bots</li><li>Chatbots with a human touch</li><li>Chatbots with emotional intelligence</li><li>Multilingual bots</li><li>Recruiting and HR bots</li></ul><h4><strong>Graphic Design</strong></h4><p>Designers working with Artificial Intelligence can create designs faster and more cheaply due to the increased speed and efficiency it offers. The power of Artificial Intelligence lies in the speed at which it can analyze vast amounts of data and suggest design adjustments. A designer can then cherry-pick and approve adjustments based on that data. The most effective designs to test can be created expediently, and multiple prototype versions can be A/B tested with users.</p><p>For example, an Artificial Intelligence algorithm has already usurped the traditional role of a designer to generate millions of unique packaging designs for Nutella. The Artificial Intelligence algorithm pulled from a database of dozens of patterns and colors to create seven million different versions of Nutella’s graphic identity, all of them unique, which have been splashed across the front of jars in Italy. All seven million jars were sold out in a month.</p><h4>Healthcare</h4><p>In 2020 and 2021, the Covid-19 pandemic forced healthcare into the future, and, as a result, several promising medical technologies were tested on a massive scale. In 2022, the question is how those technologies can be used together in a post-pandemic world.</p><p>Artificial Intelligence takes on many different forms in healthcare. The primary trend for Artificial Intelligence in healthcare 2022 will be in utilizing machine learning to evaluate large amounts of patient data and other information. By creating tailored algorithms, programmers can mimic human thought and write programs that can seemingly think, learn, make decisions, and take action.</p><p>No, this does not mean that medical care will suddenly be delivered by sentient robots. However, it does mean that, given a patient’s particular medical records, history, and current symptoms, physicians may be given suggested diagnoses, medications, and treatment plans. The physicians will always have the final say, but the information will be at their disposal.</p><p>Overall, by analyzing healthcare data in this robust and comprehensive way, healthcare leaders will be able to use the findings to improve patient outcomes, reduce costs, and boost staff job satisfaction.</p><p>In the end, I want to mention that these are only some examples of the latest advancements in the Artificial Intelligence field, but there are many more to come!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Y5-Qs4SK3N8A3helzZRDAw.gif" /></figure><p>Made with ❤ by Sigmoid.</p><p>If you want to continue learning new, cool things about Artificial Intelligence, make sure you’re following us on:</p><p>Facebook: <a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p>Instagram: <a href="https://www.instagram.com/sigmo.ai">https://www.instagram.com/sigmo.ai</a></p><p>LinkedIn: <a href="https://www.likedin.com/company/sigmoid">https://www.likedin.com/company/sigmoid</a></p><p>Bibliography:</p><p><a href="https://marutitech.com/chatbot-trends/">https://marutitech.com/chatbot-trends/</a> <a href="https://www.toptal.com/designers/product-design/infographic-ai-in-design">https://www.toptal.com/designers/product-design/infographic-ai-in-design</a> <a href="https://www.toptal.com/designers/product-design/infographic-ai-in-design">https://www.toptal.com/designers/product-design/infographic-ai-in-design</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3eae52c055a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/latest-advancements-in-the-artificial-intelligence-field-3eae52c055a5">Latest Advancements in the Artificial Intelligence Field</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>