<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Industrial Internet of Things Archives - Sensr</title>
	<atom:link href="https://www.sensr.ai/tag/industrial-internet-of-things/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sensr.ai/tag/industrial-internet-of-things/</link>
	<description>Advanced Analytics on Industrial Data. Turning unplannable into achievable.</description>
	<lastBuildDate>Mon, 17 Nov 2025 09:50:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Beyond Accuracy: Evaluating forecasting models to predict city center crowdedness</title>
		<link>https://www.sensr.ai/2024/02/23/beyond-accuracy/</link>
		
		<dc:creator><![CDATA[Imke Heusschen]]></dc:creator>
		<pubDate>Fri, 23 Feb 2024 11:00:11 +0000</pubDate>
				<category><![CDATA[Blogpost]]></category>
		<category><![CDATA[Edge Computing]]></category>
		<category><![CDATA[Industrial Internet of Things]]></category>
		<category><![CDATA[Internet of Things]]></category>
		<guid isPermaLink="false">https://www.sensr.ai/?p=863</guid>

					<description><![CDATA[<p>Beyond Accuracy: Evaluating forecasting models to predict city center crowdedness    As machine learning models grow in sophistication, their increased complexity often reduces their interpretability. Standard methods of assessing model performance, such as mean squared error and mean absolute error for regression tasks, often overlook the nuanced insights that could be gained  [...]</p>
<p>The post <a href="https://www.sensr.ai/2024/02/23/beyond-accuracy/">Beyond Accuracy: Evaluating forecasting models to predict city center crowdedness</a> appeared first on <a href="https://www.sensr.ai">Sensr</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="fusion-fullwidth fullwidth-box fusion-builder-row-1 fusion-flex-container has-pattern-background has-mask-background nonhundred-percent-fullwidth non-hundred-percent-height-scrolling" style="--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;" ><div class="fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap" style="max-width:1248px;margin-left: calc(-4% / 2 );margin-right: calc(-4% / 2 );"><div class="fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_2 1_2 fusion-flex-column fusion-flex-align-self-stretch" style="--awb-bg-size:cover;--awb-width-large:50%;--awb-margin-top-large:0px;--awb-spacing-right-large:3.84%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:3.84%;--awb-width-medium:50%;--awb-order-medium:0;--awb-spacing-right-medium:3.84%;--awb-spacing-left-medium:3.84%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-center fusion-content-layout-column"><div class="fusion-title title fusion-title-1 fusion-sep-none fusion-title-text fusion-title-size-two" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h2 class="fusion-title-heading title-heading-left" style="margin:0;"><p class="entry-title" style="text-align: left;">Beyond Accuracy: Evaluating forecasting models to predict city center crowdedness</p></h2></div></div></div><div class="fusion-layout-column fusion_builder_column fusion-builder-column-1 fusion_builder_column_1_2 1_2 fusion-flex-column" style="--awb-bg-size:cover;--awb-width-large:50%;--awb-margin-top-large:0px;--awb-spacing-right-large:3.84%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:3.84%;--awb-width-medium:50%;--awb-order-medium:0;--awb-spacing-right-medium:3.84%;--awb-spacing-left-medium:3.84%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column"><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-1 hover-type-none"><img fetchpriority="high" decoding="async" width="7420" height="7420" title="Tekengebied 36@2x" src="https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x.png" alt class="img-responsive wp-image-1167" srcset="https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x-200x200.png 200w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x-400x400.png 400w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x-600x600.png 600w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x-800x800.png 800w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x-1200x1200.png 1200w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-36@2x.png 7420w" sizes="(max-width: 640px) 100vw, 600px" /></span></div></div></div><div class="fusion-layout-column fusion_builder_column fusion-builder-column-2 fusion_builder_column_1_1 1_1 fusion-flex-column" style="--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:3rem;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:10rem;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column"><div class="fusion-text fusion-text-1"><p>As machine learning models grow in sophistication, their increased complexity often reduces their interpretability. Standard methods of assessing model performance, such as mean squared error and mean absolute error for regression tasks, often overlook the nuanced insights that could be gained from a more comprehensive evaluation. This is particularly true for complex models like time series forecasting, where a simple accuracy number might not capture the full story.</p>
</div><div class="fusion-text fusion-text-2"><p>The real-world impact of trusting a model without understanding its inner workings can lead to mistakes and potentially damaging results. Thankfully, the importance of interpretability in machine learning has gained significant attention recently, and with it, the need for more robust evaluation methods. In this blog post, we delve into the importance of using more detailed visualization techniques like plots and graphs for assessing the performance of multivariate time series models. By exploring innovative evaluation metrics designed specifically for time series forecasting, we shed light on local interpretability, allowing for more informed decision-making.</p>
</div><div class="fusion-title title fusion-title-2 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">What are we trying to do?</h4></div><div class="fusion-text fusion-text-3"><p>When attempting to forecast occupancy in larger areas, there are several factors to consider. When building a forecasting system, we have to factor in all the external parameters that can (or can’t) be added as variables. There are some typical variables that we can account for …</p>
</div><div class="fusion-title title fusion-title-3 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Some data challenges along the way</h4></div><div class="fusion-text fusion-text-4"><p>Firstly, seasonality plays a significant role with multiple cycles affecting occupancy rates. In public spaces, the number of visitors is closely related to the seasons and weather conditions.</p>
</div><div class="fusion-text fusion-text-5"><p>Secondly, the quality and quantity of data can vary depending on the time of day, with some periods potentially having more and better data than others. This is also heavily impacted by the measurement systems that are in place (eg. computer vision systems might have shortcomings in the dark, systems with radio waves might be more robust, but less precise).</p>
</div><div class="fusion-text fusion-text-6"><p>Lastly, there can be more variability in occupancy at specific parts of the day. The challenge lies in effectively measuring all these aspects to ensure accurate predictions. Unexpected events can also have a big impact on the consistency of the measurements.</p>
</div><div class="fusion-text fusion-text-7"><p>To mitigate these effects and improve the accuracy of occupancy predictions, several methods can be employed:</p>
</div><div class="fusion-text fusion-text-8"><ul>
<li><strong>Seasonality Adjustment</strong>: To handle the impact of seasonality, methods such as time series decomposition can be employed. This involves breaking down a time series into its components (trend, seasonal, and residual). Seasonal adjustment can help in identifying the underlying trends more accurately.</li>
<li><strong>Data Aggregation</strong>: For times of the day where data is sparse, one solution could be to aggregate the data over larger time intervals. For example, instead of considering hourly data, one could aggregate data at a daily level. This can help in making the data more robust and less prone to fluctuations.</li>
<li><strong>Smoothing Techniques</strong>: To handle the variability in specific parts of the day, smoothing techniques such as moving averages or exponential smoothing can be used. These techniques can help in reducing the noise and uncovering the underlying patterns in the data.</li>
<li><strong>Utilizing Advanced Forecasting Models</strong>: Today there are quite some tools and frameworks out there for time series forecasting, varying from univariate approaches (like ARIMA models) to extended multi-variate models that can account for a lot of interaction effects (like custom LSTM models or other model architectures).</li>
</ul>
</div><div class="fusion-text fusion-text-9"><p>So, long story short: There are a lot of possibilities, but the key component will remain to have proper evaluation methods, which assess a model’s usability in the business context in which it is supposed to run.</p>
</div><div class="fusion-title title fusion-title-4 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">The model</h4></div><div class="fusion-text fusion-text-10"><p>For the current case, we eventually went with an LSTM model with over 50 input features over 24 time steps. The picture below shows a quick overview of the model input:</p>
</div><div class="fusion-image-element" style="text-align:center;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-2 hover-type-none"><img decoding="async" width="1627" height="150" title="1*CubzHUPq9Ruuk2VYQsWG1w" src="https://www.sensr.ai/wp-content/uploads/2024/05/1CubzHUPq9Ruuk2VYQsWG1w.gif" alt class="img-responsive wp-image-977"/></span></div><div class="fusion-text fusion-text-11" style="--awb-margin-top:1.5rem;"><p><span style="font-family: var(--awb-text-font-family); font-size: var(--awb-font-size); font-style: var(--awb-text-font-style); letter-spacing: var(--awb-letter-spacing); text-align: var(--awb-content-alignment); text-transform: var(--awb-text-transform);">This model primarily uses data from occupation metrics in and around the city, such as parking occupancy, high-level telecom information, and other specific occupancy measurement tools. It also considers contextual information about events that may affect occupancy levels.</span></p>
</div><div class="fusion-text fusion-text-12"><p>While these input features do not cover all city activities, they offer a comprehensive overview of the current situation.</p>
</div><div class="fusion-title title fusion-title-5 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Seeing is believing</h4></div><div class="fusion-text fusion-text-13"><p>In assessing the complexity of the forecasting model, it’s crucial to examine its performance at different parts of the day. This is particularly important for ensuring the model’s effectiveness during critical periods such as mornings and noons. These are crucial periods of the day, to make sure the traffic conditions are adapted properly and to optimize the staffing in shops and restaurants over noon (and other shopping hours).</p>
</div><div class="fusion-text fusion-text-14"><p>Next to that, we also wanted to know how much into the future we can predict. The amount of timesteps that we can predict into the future had an immediate impact on the (use) cases that can be enabled by this model.</p>
</div><div class="fusion-title title fusion-title-6 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">How far can (and should) we predict?</h4></div><div class="fusion-text fusion-text-15"><p>In a best attempt to compare the accuracy for different forecasting horizons, we trained 24 models with 1 to 24 timesteps into the future. We stopped training at 20 epochs, to have an early indication of where the accuracy is going. On the test set we used the best_model_weights.</p>
</div><div class="fusion-image-element" style="text-align:center;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-3 hover-type-none"><img decoding="async" width="1400" height="617" title="graph" src="https://www.sensr.ai/wp-content/uploads/2024/05/graph.webp" alt class="img-responsive wp-image-978" srcset="https://www.sensr.ai/wp-content/uploads/2024/05/graph-200x88.webp 200w, https://www.sensr.ai/wp-content/uploads/2024/05/graph-400x176.webp 400w, https://www.sensr.ai/wp-content/uploads/2024/05/graph-600x264.webp 600w, https://www.sensr.ai/wp-content/uploads/2024/05/graph-800x353.webp 800w, https://www.sensr.ai/wp-content/uploads/2024/05/graph-1200x529.webp 1200w, https://www.sensr.ai/wp-content/uploads/2024/05/graph.webp 1400w" sizes="(max-width: 640px) 100vw, 1200px" /></span></div><div class="fusion-text fusion-text-16" style="--awb-margin-top:1.5rem;"><p>When plotting the Mean Absolute Percentage Error (MAPE) in this manner, we observe a gradually increasing MAPE. Which shows that the accuracy reduces as the forecasting horizon increases. This makes sense, and is what we expected. Nevertheless, we still observed quite some variability in the MAPE, which means the model didn’t entirely capture the complexity. This is also strongly related to the fact that we stopped training after 20 epochs, independently of the learning curve of the model.</p>
</div><div class="fusion-title title fusion-title-7 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Are we able to predict accurately at all times?</h4></div><div class="fusion-text fusion-text-17"><p>We also wanted to know whether we were better during some times of the day. In a somewhat different fashion than the tests above, we trained a model to predict the upcoming 24 hours of the day.</p>
</div><div class="fusion-image-element" style="text-align:center;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-4 hover-type-none"><img decoding="async" width="868" height="700" title="1*e5CroE17pYRTvHJx-17OUA" src="https://www.sensr.ai/wp-content/uploads/2024/05/1e5CroE17pYRTvHJx-17OUA.webp" alt class="img-responsive wp-image-979" srcset="https://www.sensr.ai/wp-content/uploads/2024/05/1e5CroE17pYRTvHJx-17OUA-200x161.webp 200w, https://www.sensr.ai/wp-content/uploads/2024/05/1e5CroE17pYRTvHJx-17OUA-400x323.webp 400w, https://www.sensr.ai/wp-content/uploads/2024/05/1e5CroE17pYRTvHJx-17OUA-600x484.webp 600w, https://www.sensr.ai/wp-content/uploads/2024/05/1e5CroE17pYRTvHJx-17OUA-800x645.webp 800w, https://www.sensr.ai/wp-content/uploads/2024/05/1e5CroE17pYRTvHJx-17OUA.webp 868w" sizes="(max-width: 640px) 100vw, 868px" /></span></div><div class="fusion-text fusion-text-18" style="--awb-margin-top:1.5rem;"><p>To evaluate our performance through-out the day we combined the hour in which we did the prediction (X-axis), the number of hours in the future we predicted in relation to the hour of the day (Y-axis) and the Mean Absolute Percentage Error (colour).</p>
</div><div class="fusion-text fusion-text-19"><p>The plot above led us to the conclusion that we are somewhat better at predicting the first half of the day at the beginning of the day. This is quite useful to manage crowdedness in the morning.</p>
</div><div class="fusion-text fusion-text-20"><p>Next to that, we observed that we’re less accurate in predicting the first hours of the afternoon at noon, and it gets better in the afternoon.</p>
</div><div class="fusion-title title fusion-title-8 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Leasons Learned</h4></div><div class="fusion-title title fusion-title-9 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Models are not only for predictions</h4></div><div class="fusion-text fusion-text-21"><p>It’s not uncommon for ML Engineers to try to jump straight to model development to solve a problem (yes, let’s admit it). However, model development and the different flavours and set-ups are an important part of capturing and evaluating the possibilities with the data at hand. So take your time to develop different model architectures in the light of the (business) evaluations you want to do.</p>
</div><div class="fusion-title title fusion-title-10 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">No one-size-fits-all</h4></div><div class="fusion-text fusion-text-22"><p>It’s generally known that neural networks are incredibly good at solving well-defined, narrow problems (despite the perceived general problem-solving capabilities of Large Language Models — we’re not just yet at the level of AGI).</p>
</div><div class="fusion-text fusion-text-23"><p>So this also goes for this use case: It’s less effective to have one model that forecasts the upcoming 24 hours and to build multiple use cases on top of that. Instead we opt to build dedicated models per specific use case (eg. morning shift predictions, lunch-staffing predictions, …).</p>
</div><div class="fusion-title title fusion-title-11 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">No one-size-fits-all</h4></div><div class="fusion-text fusion-text-24"><p>We still observed quite some variance in our test results, which shows that our model(s) didn’t (yet) capture all complexity. Next to that, we observed some systematic, lower accuracy of measurements during the night. This got (partly) resolved by moving to multi-variate models (the LSTM with the features displayed above), which was able to get the best of the different measurements at hand. Yet again, we learned that data quality is key in building proper data solutions.</p>
</div></div></div></div></div>
<p>The post <a href="https://www.sensr.ai/2024/02/23/beyond-accuracy/">Beyond Accuracy: Evaluating forecasting models to predict city center crowdedness</a> appeared first on <a href="https://www.sensr.ai">Sensr</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Robust Deployment Pattern for ML Models at the Edge.</title>
		<link>https://www.sensr.ai/2024/02/16/a-robust-deployment-pattern-for-ml-models-at-the-edge-3/</link>
		
		<dc:creator><![CDATA[Imke Heusschen]]></dc:creator>
		<pubDate>Fri, 16 Feb 2024 12:58:57 +0000</pubDate>
				<category><![CDATA[Blogpost]]></category>
		<category><![CDATA[Edge Computing]]></category>
		<category><![CDATA[Industrial Internet of Things]]></category>
		<category><![CDATA[Internet of Things]]></category>
		<category><![CDATA[Machine Learning Operations]]></category>
		<guid isPermaLink="false">https://www.sensr.ai/?p=840</guid>

					<description><![CDATA[<p>A Robust Deployment Pattern for ML Models at the Edge.   At Sensr we recently had the opportunity to serve as an implementation partner on the DAP²CHEM project , an innovative project aiming to stimulate the transition of chemical and life science companies towards Industry 4.0. This project was a collaboration between top Flemish  [...]</p>
<p>The post <a href="https://www.sensr.ai/2024/02/16/a-robust-deployment-pattern-for-ml-models-at-the-edge-3/">A Robust Deployment Pattern for ML Models at the Edge.</a> appeared first on <a href="https://www.sensr.ai">Sensr</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="fusion-fullwidth fullwidth-box fusion-builder-row-2 fusion-flex-container has-pattern-background has-mask-background nonhundred-percent-fullwidth non-hundred-percent-height-scrolling" style="--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;" ><div class="fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap" style="max-width:1248px;margin-left: calc(-4% / 2 );margin-right: calc(-4% / 2 );"><div class="fusion-layout-column fusion_builder_column fusion-builder-column-3 fusion_builder_column_1_2 1_2 fusion-flex-column fusion-flex-align-self-stretch" style="--awb-bg-size:cover;--awb-width-large:50%;--awb-margin-top-large:0px;--awb-spacing-right-large:3.84%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:3.84%;--awb-width-medium:50%;--awb-order-medium:0;--awb-spacing-right-medium:3.84%;--awb-spacing-left-medium:3.84%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-center fusion-content-layout-column"><div class="fusion-title title fusion-title-12 fusion-sep-none fusion-title-text fusion-title-size-two" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h2 class="fusion-title-heading title-heading-left" style="margin:0;"><h1 class="entry-title">A Robust Deployment Pattern for ML Models at the Edge.</h1></h2></div></div></div><div class="fusion-layout-column fusion_builder_column fusion-builder-column-4 fusion_builder_column_1_2 1_2 fusion-flex-column" style="--awb-bg-size:cover;--awb-width-large:50%;--awb-margin-top-large:0px;--awb-spacing-right-large:3.84%;--awb-margin-bottom-large:20px;--awb-spacing-left-large:3.84%;--awb-width-medium:50%;--awb-order-medium:0;--awb-spacing-right-medium:3.84%;--awb-spacing-left-medium:3.84%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column"><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-5 hover-type-none"><img decoding="async" width="7420" height="7420" title="Tekengebied 31@2x" src="https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x.png" alt class="img-responsive wp-image-1164" srcset="https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x-200x200.png 200w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x-400x400.png 400w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x-600x600.png 600w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x-800x800.png 800w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x-1200x1200.png 1200w, https://www.sensr.ai/wp-content/uploads/2025/03/Tekengebied-31@2x.png 7420w" sizes="(max-width: 640px) 100vw, 600px" /></span></div></div></div><div class="fusion-layout-column fusion_builder_column fusion-builder-column-5 fusion_builder_column_1_1 1_1 fusion-flex-column" style="--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:3rem;--awb-spacing-right-large:1.92%;--awb-margin-bottom-large:10rem;--awb-spacing-left-large:1.92%;--awb-width-medium:100%;--awb-order-medium:0;--awb-spacing-right-medium:1.92%;--awb-spacing-left-medium:1.92%;--awb-width-small:100%;--awb-order-small:0;--awb-spacing-right-small:1.92%;--awb-spacing-left-small:1.92%;"><div class="fusion-column-wrapper fusion-column-has-shadow fusion-flex-justify-content-flex-start fusion-content-layout-column"><div class="fusion-text fusion-text-25"><p><em class="nu">At </em><a class="af nt" href="https://sensr.ai/" target="_blank" rel="noopener ugc nofollow"><em class="nu" style="color: #3883ce;">Sensr</em></a><em class="nu"> we recently had the opportunity to serve as an implementation partner on the </em><a class="af nt" href="https://catalisti.be/project/dap%C2%B2chem/" target="_blank" rel="noopener ugc nofollow"><em class="nu" style="color: #3883ce;">DAP²CHEM project</em></a><em class="nu"> , an innovative project aiming to stimulate the transition of chemical and life science companies towards Industry 4.0. This project was a collaboration between top Flemish research institutes and top players in the chemical and life space (with a Flemish presence), Procter and Gamble, Ajinomoto Bio-Pharma Services and Janssen. Through this article we share our learnings about machine learning at the edge from that project.</em></p>
</div><div class="fusion-title title fusion-title-13 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Why ML at the Edge?</h4></div><div class="fusion-text fusion-text-26"><p id="c1c1" class="pw-post-body-paragraph mc md fr me b mf oq mh mi mj or ml mm mn os mp mq mr ot mt mu mv ou mx my mz fk bj" data-selectable-paragraph="">Most of our interactions with machine learning (ML) backed systems happen through communication over the internet. We send data to an ML model in the cloud for inferencing, wait a few (milli)seconds, and get a response with the results. At <a class="af nt" href="https://www.sensr.ai/" target="_blank" rel="noopener ugc nofollow">Sensr</a> we often encounter Industrial Internet of Things (IIoT) systems where this pattern for ML inference can be prohibitive due to:</p>
<ul class="">
<li id="f822" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz ov ow ox bj" data-selectable-paragraph="">The <strong class="me fs">latency</strong> inherent to communication over the internet. The (milli)second delay that we mentioned might be enough for the window of opportunity where the output of the model is useful to pass. For example, a faulty item on a production line might be too far down the conveyor belt to be discarded.</li>
<li id="a5ca" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">The absence of stable <strong class="me fs">connectivity</strong> to the internet. This can be due to the environment the system operates in, or due to the nature of the device producing the data. ML-backed systems must be able to provide at least the same level of <strong class="me fs">reliability</strong> as the systems they are replacing or improving upon in order to be viable. Hence, they must be able to properly function even when connectivity drops (un)expectedly.</li>
<li id="d31e" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">The high <strong class="me fs">velocity</strong> and <strong class="me fs">volume</strong> at which data is produced. In addition to amplifying the issues caused by the previous two points. Sending all of this data to the cloud for processing, whether in batch or real-time, would incur quite a cost. This is especially the case when the number of edge devices that produce data grow into the thousands.</li>
<li id="9b91" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">Although less relevant for industrial applications of IoT, laws and regulations may be in place for <strong class="me fs">sensitive data</strong>, in order to protect the privacy of individuals. In this case, sending certain information to the cloud might be prohibited, or the risk of interception and leakage may outweigh the benefit of processing the data in the cloud.</li>
</ul>
<p id="e25e" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">By deploying ML models closer to the source of the data they are processing we can eliminate the need for internet communication in our flow. This increases the viability of some interesting industrial use cases of ML including:</p>
<ul class="">
<li id="9659" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz ov ow ox bj" data-selectable-paragraph="">The integration of <strong class="me fs">computer vision</strong> models in visual inspection, security, and safety systems, where inclusion of ML into the loop can only be beneficial if the rest of the system can react to the output of the models in real time.</li>
<li id="d40b" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">Performing <strong class="me fs">predictive maintenance</strong> using data collected by audio and vibration sensors attached to industrial machinery. When the data collected by a sensor indicates anomalous behavior, real-time contingency measures can be taken to prevent damage to the machine or the environment it operates in.</li>
</ul>
</div><div class="fusion-title title fusion-title-14 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Challenges and Considerations</h4></div><div class="fusion-text fusion-text-27"><p id="c1c1" class="pw-post-body-paragraph mc md fr me b mf oq mh mi mj or ml mm mn os mp mq mr ot mt mu mv ou mx my mz fk bj" data-selectable-paragraph="">Most of our interactions with machine learning (ML) backed systems happen through communication over the internet. We send data to an ML model in the cloud for inferencing, wait a few (milli)seconds, and get a response with the results. At <a class="af nt" href="https://www.sensr.ai/" target="_blank" rel="noopener ugc nofollow">Sensr</a> we often encounter Industrial Internet of Things (IIoT) systems where this pattern for ML inference can be prohibitive due to:</p>
<ul class="">
<li id="f822" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz ov ow ox bj" data-selectable-paragraph="">The <strong class="me fs">latency</strong> inherent to communication over the internet. The (milli)second delay that we mentioned might be enough for the window of opportunity where the output of the model is useful to pass. For example, a faulty item on a production line might be too far down the conveyor belt to be discarded.</li>
<li id="a5ca" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">The absence of stable <strong class="me fs">connectivity</strong> to the internet. This can be due to the environment the system operates in, or due to the nature of the device producing the data. ML-backed systems must be able to provide at least the same level of <strong class="me fs">reliability</strong> as the systems they are replacing or improving upon in order to be viable. Hence, they must be able to properly function even when connectivity drops (un)expectedly.</li>
<li id="d31e" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">The high <strong class="me fs">velocity</strong> and <strong class="me fs">volume</strong> at which data is produced. In addition to amplifying the issues caused by the previous two points. Sending all of this data to the cloud for processing, whether in batch or real-time, would incur quite a cost. This is especially the case when the number of edge devices that produce data grow into the thousands.</li>
<li id="9b91" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">Although less relevant for industrial applications of IoT, laws and regulations may be in place for <strong class="me fs">sensitive data</strong>, in order to protect the privacy of individuals. In this case, sending certain information to the cloud might be prohibited, or the risk of interception and leakage may outweigh the benefit of processing the data in the cloud.</li>
</ul>
<p id="e25e" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">By deploying ML models closer to the source of the data they are processing we can eliminate the need for internet communication in our flow. This increases the viability of some interesting industrial use cases of ML including:</p>
<ul class="">
<li id="9659" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz ov ow ox bj" data-selectable-paragraph="">The integration of <strong class="me fs">computer vision</strong> models in visual inspection, security, and safety systems, where inclusion of ML into the loop can only be beneficial if the rest of the system can react to the output of the models in real time.</li>
<li id="d40b" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">Performing <strong class="me fs">predictive maintenance</strong> using data collected by audio and vibration sensors attached to industrial machinery. When the data collected by a sensor indicates anomalous behavior, real-time contingency measures can be taken to prevent damage to the machine or the environment it operates in.</li>
</ul>
</div><div class="fusion-title title fusion-title-15 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Deployment Pattern</h4></div><div class="fusion-text fusion-text-28"><p>We boiled down <a class="af nt" href="https://aws.amazon.com/blogs/machine-learning/build-machine-learning-at-the-edge-applications-using-amazon-sagemaker-edge-manager-and-aws-iot-greengrass-v2/" target="_blank" rel="noopener ugc nofollow">Amazon Web Services’</a> (AWS) and <a class="af nt" href="https://learn.microsoft.com/en-us/azure/architecture/guide/iot/machine-learning-inference-iot-edge" target="_blank" rel="noopener ugc nofollow">Microsoft Azure’s</a> reference architectures for enabling ML inference at the edge to their essence; the pattern described by the following sequence diagram:</p>
</div><div class="fusion-image-element" style="text-align:center;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-6 hover-type-none"><img decoding="async" width="650" height="557" title="1*CEkyBaBd47iZE-Eo-VVemg" src="https://www.sensr.ai/wp-content/uploads/2024/02/1CEkyBaBd47iZE-Eo-VVemg.webp" alt class="img-responsive wp-image-844" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/1CEkyBaBd47iZE-Eo-VVemg-200x171.webp 200w, https://www.sensr.ai/wp-content/uploads/2024/02/1CEkyBaBd47iZE-Eo-VVemg-400x343.webp 400w, https://www.sensr.ai/wp-content/uploads/2024/02/1CEkyBaBd47iZE-Eo-VVemg-600x514.webp 600w, https://www.sensr.ai/wp-content/uploads/2024/02/1CEkyBaBd47iZE-Eo-VVemg.webp 650w" sizes="(max-width: 640px) 100vw, 650px" /></span></div><div class="fusion-text fusion-text-29" style="--awb-margin-top:2rem;"><p><span style="font-family: var(--awb-text-font-family); font-size: var(--awb-font-size); font-style: var(--awb-text-font-style); letter-spacing: var(--awb-letter-spacing); text-align: var(--awb-content-alignment); text-transform: var(--awb-text-transform);">A central part of the flow is some entity that represents the </span><strong class="me fs" style="font-family: var(--awb-text-font-family); font-size: var(--awb-font-size); font-style: var(--awb-text-font-style); letter-spacing: var(--awb-letter-spacing); text-align: var(--awb-content-alignment); text-transform: var(--awb-text-transform);">desired state</strong> <strong class="me fs" style="font-family: var(--awb-text-font-family); font-size: var(--awb-font-size); font-style: var(--awb-text-font-style); letter-spacing: var(--awb-letter-spacing); text-align: var(--awb-content-alignment); text-transform: var(--awb-text-transform);">of the edge device</strong><span style="font-family: var(--awb-text-font-family); font-size: var(--awb-font-size); font-style: var(--awb-text-font-style); letter-spacing: var(--awb-letter-spacing); text-align: var(--awb-content-alignment); text-transform: var(--awb-text-transform);">. This entity is part of your “always available” IT infrastructure and can thus be reliably updated as part of a continuous deployment flow. The associated edge device periodically polls this entity for state changes and updates its own state when necessary. This approach solves the three deployment related challenges we listed earlier:<br />
</span></p>
<ul class="">
<li id="3b6b" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz ov ow ox bj" data-selectable-paragraph="">The desired state entity can be updated programmatically, that is, very efficiently, for thousands of devices.</li>
<li id="0b49" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">Since the edge device initiates any communication it is considered to be outbound. Outbound communication is often less strictly policed by corporate firewalls than inbound communication, making it easier to comply with existing firewall rules.</li>
<li id="1c29" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">If the device is offline while the desired state is updated, the change will be picked up by the device once it is back online.</li>
</ul>
</div><div class="fusion-text fusion-text-30"><p id="afa2" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">You could, in theory, roll your own implementation, but both AWS and Azure have a suite of IoT services that can help you quickly facilitate this pattern as we will show in the following section.</p>
</div><div class="fusion-title title fusion-title-16 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">A running start with Azure IoT</h4></div><div class="fusion-text fusion-text-31"><p id="5b64" class="pw-post-body-paragraph mc md fr me b mf oq mh mi mj or ml mm mn os mp mq mr ot mt mu mv ou mx my mz fk bj" data-selectable-paragraph="">The Azure IoT suite of services can give you a running start when trying to implement this pattern. <strong class="me fs">Azure IoT Hub</strong> and <strong class="me fs">Azure IoT Edge</strong> together provide a comprehensive solution for managing IoT devices and processing IoT data at scale:</p>
<ul class="">
<li id="379d" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz ov ow ox bj" data-selectable-paragraph="">Azure IoT Hub is a cloud-based service that enables bidirectional communication between IoT devices and the cloud, allowing for device management, data ingestion, and monitoring at scale. Device and module twins in IoT Hub are used to maintain the desired state of the IoT devices and their associated modules.</li>
<li id="7ed1" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz ov ow ox bj" data-selectable-paragraph="">Azure IoT Edge extends the capabilities of Azure IoT Hub by providing a way to run cloud workloads locally on IoT Edge devices, enabling them to perform edge computing and analytics, even when the devices are offline or have limited connectivity. One of the responsibilities of the runtime that comes with IoT Edge is handling communication between the IoT Edge device and the cloud.</li>
</ul>
<p id="a95b" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">In what follows we assume that you already:</p>
<ol class="">
<li id="9406" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz pe ow ox bj" data-selectable-paragraph=""><a class="af nt" style="color: #3883ce;" href="https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal" target="_blank" rel="noopener ugc nofollow">Set up an IoT Hub</a>. Be sure to choose <a class="af nt" style="color: #3883ce;" href="https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-scaling" target="_blank" rel="noopener ugc nofollow">a tier that supports Azure IoT Edge</a>.</li>
<li id="d72a" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz pe ow ox bj" data-selectable-paragraph=""><a class="af nt" style="color: #3883ce;" href="https://learn.microsoft.com/en-us/azure/iot-edge/how-to-provision-single-device-linux-symmetric?view=iotedge-1.4&amp;tabs=azure-portal%2Cubuntu" target="_blank" rel="noopener ugc nofollow">Created and provisioned an IoT Edge device</a>.</li>
<li id="baf9" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz pe ow ox bj" data-selectable-paragraph="">Have a basic understanding of <a class="af nt" style="color: #3883ce;" href="https://learn.microsoft.com/en-us/azure/iot-edge/tutorial-develop-for-linux?view=iotedge-1.4&amp;tabs=python&amp;pivots=iotedge-dev-cli" target="_blank" rel="noopener ugc nofollow">how to develop IoT Edge modules</a>.</li>
</ol>
<p id="c407" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">As an example we set up a free tier IoT Hub and provisioned an IoT Edge device that we set up in a local virtual machine. To serve as a starting point we have also created a custom Python IoT Edge module, called <code class="cw pf pg ph pi b">model_loader</code>, based on the <a class="af nt" style="color: #3883ce;" href="https://github.com/Azure/cookiecutter-azure-iot-edge-module" target="_blank" rel="noopener ugc nofollow">Python Cookiecutter template</a>.</p>
<p id="6f50" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">By setting up these Azure-provided building blocks we have already “implemented” three components crucial to our pattern; an edge device, a way to set its desired state via device and module twins in the cloud, and communication between the edge device and the cloud. As such most of the heavy lifting has been done for us by Microsoft. All that is left to do for us is some fine-tuning to enable the rest of the pattern.</p>
</div><div class="fusion-title title fusion-title-17 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Setting up artifact storage</h4></div><div class="fusion-text fusion-text-32"><p>IoT edge modules run in containerized environments. Hence when a module, or the device needs to restart any files that have been created in a module’s filesystem are lost, e.g., downloaded model artifacts. We can provide our custom module with access to persistent storage on the host file system by extending the module’s create options in the deployment manifest with a storage binding, where <code class="cw pf pg ph pi b">Source</code> and <code class="cw pf pg ph pi b">Target</code> contain your host and module storage path, respectively; both must be absolute paths. The deployment manifest for our <code class="cw pf pg ph pi b">model_loader</code> module looks as follows:</p>
</div><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-7 hover-type-none"><img decoding="async" width="1372" height="1084" title="Scherm­afbeelding 2024-02-23 om 08.14.32" src="https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32.png" alt class="img-responsive wp-image-854" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32-200x158.png 200w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32-400x316.png 400w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32-600x474.png 600w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32-800x632.png 800w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32-1200x948.png 1200w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.14.32.png 1372w" sizes="(max-width: 640px) 100vw, 1200px" /></span></div><div class="fusion-title title fusion-title-18 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Reacting to desired state changes</h4></div><div class="fusion-text fusion-text-33"><p>In Azure IoT Hub we can set the desired state for a device/module through the desired properties object in the device/module twin. For example, we set the following desired properties on the twin of our <code class="cw pf pg ph pi b">model_loader</code> module to indicate which model we want the module to load, where to save it, and which checksum to use for validating the downloaded model:</p>
</div><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-8 hover-type-none"><img decoding="async" width="1374" height="480" title="Scherm­afbeelding 2024-02-23 om 08.17.43" src="https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43.png" alt class="img-responsive wp-image-855" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43-200x70.png 200w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43-400x140.png 400w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43-600x210.png 600w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43-800x279.png 800w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43-1200x419.png 1200w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.17.43.png 1374w" sizes="(max-width: 640px) 100vw, 1200px" /></span></div><div class="fusion-text fusion-text-34" style="--awb-margin-top:1.5rem;"><p id="e402" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">For the purpose of this article we are using a publicly available model, but under normal circumstances you would host your model in a private repository.</p>
<p id="a1c0" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">The module template that we used to create our <code class="cw pf pg ph pi b">model_loader</code> module does not implement any handling of changes in the desired state, so called <strong class="me fs">twin patches</strong>. Further down we provide a basic implementation of an incoming twin patch handler, which is invoked when <strong class="me fs">desired properties</strong> are updated on the module twin. Inside the handler we also set a <strong class="me fs">reported property</strong>, to provide some form of feedback to IoT Hub.</p>
<p id="9929" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">The handler shown below performs the following steps when a twin patch is received:</p>
<ol class="">
<li id="4b8d" class="mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz pe ow ox bj" data-selectable-paragraph="">Check whether the twin patch is valid, that is, contains all expected keys.</li>
<li id="12c0" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz pe ow ox bj" data-selectable-paragraph="">Extract the model’s download url, MD5 checksum, and local file name from the twin patch.</li>
<li id="deb3" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz pe ow ox bj" data-selectable-paragraph="">Check whether the model already exists locally. If so, returns in order to prevent an unnecessary download.</li>
<li id="bfd8" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz pe ow ox bj" data-selectable-paragraph="">Downloads the model and validates the downloaded file using the MD5 checksum from the twin patch.</li>
<li id="d6f9" class="mc md fr me b mf oy mh mi mj oz ml mm mn pa mp mq mr pb mt mu mv pc mx my mz pe ow ox bj" data-selectable-paragraph="">Sets the reported property <code class="cw pf pg ph pi b">lastModelUpdate</code> to the current time to indicate when the model.</li>
</ol>
</div><div class="fusion-image-element" style="text-align:center;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-9 hover-type-none"><img decoding="async" width="5287" height="11483" title="Tekengebied 1@4x" src="https://www.sensr.ai/wp-content/uploads/2024/02/Tekengebied-1@4x-1.png" alt class="img-responsive wp-image-858" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/Tekengebied-1@4x-1-200x434.png 200w, https://www.sensr.ai/wp-content/uploads/2024/02/Tekengebied-1@4x-1-400x869.png 400w, https://www.sensr.ai/wp-content/uploads/2024/02/Tekengebied-1@4x-1-600x1303.png 600w, https://www.sensr.ai/wp-content/uploads/2024/02/Tekengebied-1@4x-1-800x1738.png 800w, https://www.sensr.ai/wp-content/uploads/2024/02/Tekengebied-1@4x-1.png 5287w" sizes="(max-width: 640px) 100vw, 5287px" /></span></div><div class="fusion-text fusion-text-35 fusion-text-no-margin" style="--awb-margin-top:2rem;--awb-margin-bottom:0px;"><p>In our module’s <code class="cw pf pg ph pi b">main.py</code> file we register the handler using the following code snippet:</p>
</div><div class="fusion-image-element" style="text-align:center;--awb-margin-top:2rem;--awb-margin-bottom:2rem;--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-10 hover-type-none"><img decoding="async" width="1372" height="622" title="Scherm­afbeelding 2024-02-23 om 08.19.01" src="https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01.png" alt class="img-responsive wp-image-859" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01-200x91.png 200w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01-400x181.png 400w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01-600x272.png 600w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01-800x363.png 800w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01-1200x544.png 1200w, https://www.sensr.ai/wp-content/uploads/2024/02/Scherm­afbeelding-2024-02-23-om-08.19.01.png 1372w" sizes="(max-width: 640px) 100vw, 1200px" /></span></div><div class="fusion-title title fusion-title-19 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Testing the setup</h4></div><div class="fusion-text fusion-text-36"><p>After implementing and deploying the handler, the logs of our <code class="cw pf pg ph pi b">model_loader</code>module look as follows:</p>
</div><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-11 hover-type-none"><img decoding="async" width="1400" height="958" alt="Edge device - Model loader module logs" title="1*gLGGSvD7Y_7GDLNkj0b82Q" src="https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q.webp" class="img-responsive wp-image-850" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q-200x137.webp 200w, https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q-400x274.webp 400w, https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q-600x411.webp 600w, https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q-800x547.webp 800w, https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q-1200x821.webp 1200w, https://www.sensr.ai/wp-content/uploads/2024/02/1gLGGSvD7Y_7GDLNkj0b82Q.webp 1400w" sizes="(max-width: 640px) 100vw, 1200px" /></span></div><div class="fusion-text fusion-text-37"><p id="caae" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">We can see that the twin patch handler was invoked twice. The first time, triggered by the module starting up, the handler finds an existing model file, which was downloaded during development of the module. The second invocation was triggered by editing <code class="cw pf pg ph pi b">modelFileName</code> in the module twin through the Azure Portal UI. A file with that name does not yet exist and therefore a download is triggered.</p>
<p id="cdbf" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">If we then look in the edge device’s local folder that we set as mount source in the deployment manifest, we see both files mentioned in the logs. These won’t be lost if the device or the module’s container is restarted and can be accessed by other modules through the same mounting mechanism.</p>
</div><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-12 hover-type-none"><img decoding="async" width="1400" height="954" alt="Edge device - Model files in local storage" title="1*uxIig955TUjmt2OvTvMFTA" src="https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA.webp" class="img-responsive wp-image-851" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA-200x136.webp 200w, https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA-400x273.webp 400w, https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA-600x409.webp 600w, https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA-800x545.webp 800w, https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA-1200x818.webp 1200w, https://www.sensr.ai/wp-content/uploads/2024/02/1uxIig955TUjmt2OvTvMFTA.webp 1400w" sizes="(max-width: 640px) 100vw, 1200px" /></span></div><div class="fusion-text fusion-text-38 fusion-text-no-margin" style="--awb-margin-bottom:2rem;"><p>We can also verify that the model file was updated by looking at the reported properties in the module’s twin in Azure Portal. We see that the <code class="cw pf pg ph pi b">lastModelUpdate</code> property has been set to the timestamp when our handler successfully downloaded the model file:</p>
</div><div class="fusion-image-element" style="--awb-caption-title-font-family:var(--h2_typography-font-family);--awb-caption-title-font-weight:var(--h2_typography-font-weight);--awb-caption-title-font-style:var(--h2_typography-font-style);--awb-caption-title-size:var(--h2_typography-font-size);--awb-caption-title-transform:var(--h2_typography-text-transform);--awb-caption-title-line-height:var(--h2_typography-line-height);--awb-caption-title-letter-spacing:var(--h2_typography-letter-spacing);"><span class=" fusion-imageframe imageframe-none imageframe-13 hover-type-none"><img decoding="async" width="753" height="473" alt="Model twin - Reported properties" title="1*U1ieEbFYQpuMnVrHASYMDQ" src="https://www.sensr.ai/wp-content/uploads/2024/02/1U1ieEbFYQpuMnVrHASYMDQ.webp" class="img-responsive wp-image-852" srcset="https://www.sensr.ai/wp-content/uploads/2024/02/1U1ieEbFYQpuMnVrHASYMDQ-200x126.webp 200w, https://www.sensr.ai/wp-content/uploads/2024/02/1U1ieEbFYQpuMnVrHASYMDQ-400x251.webp 400w, https://www.sensr.ai/wp-content/uploads/2024/02/1U1ieEbFYQpuMnVrHASYMDQ-600x377.webp 600w, https://www.sensr.ai/wp-content/uploads/2024/02/1U1ieEbFYQpuMnVrHASYMDQ.webp 753w" sizes="(max-width: 640px) 100vw, 753px" /></span></div><div class="fusion-title title fusion-title-20 fusion-sep-none fusion-title-text fusion-title-size-four" style="--awb-margin-top:2rem;--awb-margin-top-small:10px;--awb-margin-right-small:0px;--awb-margin-bottom-small:10px;--awb-margin-left-small:0px;"><h4 class="fusion-title-heading title-heading-left" style="margin:0;">Conclusion</h4></div><div class="fusion-text fusion-text-39"><p id="7f64" class="pw-post-body-paragraph mc md fr me b mf oq mh mi mj or ml mm mn os mp mq mr ot mt mu mv ou mx my mz fk bj" data-selectable-paragraph="">In this article, we cover the need for ML at the edge and associated deployment challenges. We also describe a generic pattern for tackling said challenges and provide an example implementation using the Azure IoT Edge framework. I hope that this article helped you in a meaningful way and that you had as much fun reading it as I had writing it.</p>
<p id="7587" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">Cheers,</p>
<p id="31bc" class="pw-post-body-paragraph mc md fr me b mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fk bj" data-selectable-paragraph="">— Andrei</p>
</div></div></div></div></div>
<p>The post <a href="https://www.sensr.ai/2024/02/16/a-robust-deployment-pattern-for-ml-models-at-the-edge-3/">A Robust Deployment Pattern for ML Models at the Edge.</a> appeared first on <a href="https://www.sensr.ai">Sensr</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
