I lately acquired a query from a good friend concerning barcode era utilizing Swift. The CoreImage framework gives handy built-in APIs for creating varied forms of barcodes, together with QR codes. On this tutorial, we’ll discover how one can leverage SwiftUI and these highly effective APIs to develop your very personal barcode generator.
Let’s first check out the ultimate consequence. It’s a really elementary barcode era app with easy UIs. Whenever you enter textual content into the designated subject, the app immediately generates the corresponding barcode utilizing the Code 128 format, which is used for alphanumeric or numeric-only barcodes.
Creating the Barcode Generator
Assuming you’ve created a brand new SwiftUI venture in Xcode, open the ContentView.swift file. Begin by importing the required package deal for utilizing the filters:
import CoreImage.CIFilterBuiltins
Subsequent, we create a BarcodeGenerator struct for producing the barcode:
struct BarcodeGenerator {
let context = CIContext()
let generator = CIFilter.code128BarcodeGenerator()
func generateBarcode(textual content: String) -> Picture {
let generator = CIFilter.code128BarcodeGenerator()
generator.message = Knowledge(textual content.utf8)
if let outputImage = generator.outputImage,
let cgImage = context.createCGImage(outputImage, from: outputImage.extent) {
let uiImage = UIImage(cgImage: cgImage)
return Picture(uiImage: uiImage)
}
return Picture(systemName: "barcode")
}
}
To create the barcode, we declare two variables: the context and the Code 128 generator. Should you discover the CIFilter class, you’ll uncover different code turbines such because the QR code generator and the Aztec code generator. Nonetheless, for this demonstration, we’ll concentrate on utilizing the Code 128 barcode generator.
The generateBarcode methodology accepts a string enter and returns the generated barcode picture. Throughout the methodology, we first initialize the code128BarcodeGenerator and assign the enter textual content to its message property. Because the message property expects Knowledge, we convert the enter textual content to Knowledge. Subsequently, we retrieve the generated barcode picture from the outputImage property of the generator.
Because the ensuing picture is of kind CIImage, we make the most of the createCGImage methodology of the context to transform it to a CGImage. We then proceed with further steps to transform it into an Picture.
Constructing the Consumer Interface
Now that now we have completed constructing the barcode generator, let’s transfer on to growing the person interface for displaying the barcode picture.
First, declare the next properties in ContentView for the enter textual content and the barcode generator:
@State personal var inputText = ""
var barcodeGenerator = BarcodeGenerator()
For the person interface, let’s preserve it easy and lay out all of the views in a VStack like this:
On the display, now we have a textual content subject that captures person enter. In direction of the underside of the display, the app shows the generated barcode. In case there isn’t a person enter, we present a default picture with the caption “Unknown information.”
That’s it! You need to now be capable of take a look at the app within the preview pane. Merely enter any textual content within the textual content subject, and the app will mechanically generate the barcode on the fly.
Abstract
This tutorial gives a complete information on constructing a barcode generator utilizing the CoreImage framework and SwiftUI. Whereas the main focus is on making a Code 128 barcode, you possibly can simply modify the code to assist a number of forms of barcodes together with QR codes.
Apple periodically gives info for buyers on its company web site, apple.com, and its investor relations web site, investor.apple.com. This consists of press releases and different details about monetary efficiency, studies filed or furnished with the SEC, info on company governance, and particulars associated to its annual assembly of shareholders.
This press launch accommodates forward-looking statements, throughout the that means of the Non-public Securities Litigation Reform Act of 1995. These forward-looking statements embody with out limitation these about fee of the Firm’s quarterly dividend and future enterprise plans. These statements contain dangers and uncertainties, and precise outcomes might differ materially from any future outcomes expressed or implied by the forward-looking statements. Dangers and uncertainties embody with out limitation: results of world and regional financial circumstances, together with because of authorities insurance policies, warfare, terrorism, pure disasters, and public well being points; dangers regarding the design, manufacture, introduction, and transition of services in extremely aggressive and quickly altering markets, together with from reliance on third events for elements, expertise, manufacturing, purposes, and content material; dangers regarding info expertise system failures, community disruptions, and failure to guard, lack of, or unauthorized entry to, or launch of, information; and results of unfavorable authorized proceedings, authorities investigations, and complicated and altering legal guidelines and laws. Extra info on these dangers and different potential components that might have an effect on the Firm’s enterprise, repute, outcomes of operations, monetary situation, and inventory worth is included within the Firm’s filings with the SEC, together with within the “Danger Elements” and “Administration’s Dialogue and Evaluation of Monetary Situation and Outcomes of Operations” sections of the Firm’s most not too long ago filed periodic studies on Kind 10-Ok and Kind 10-Q and subsequent filings. The Firm assumes no obligation to replace any forward-looking statements, which communicate solely as of the date they’re made.
About Apple
Apple revolutionized private expertise with the introduction of the Macintosh in 1984. Right now, Apple leads the world in innovation with iPhone, iPad, Mac, AirPods, Apple Watch, and Apple Imaginative and prescient Professional. Apple’s six software program platforms — iOS, iPadOS, macOS, watchOS, visionOS, and tvOS — present seamless experiences throughout all Apple gadgets and empower folks with breakthrough providers together with the App Retailer, Apple Music, Apple Pay, iCloud, and Apple TV+. Apple’s greater than 150,000 staff are devoted to creating the perfect merchandise on earth and to leaving the world higher than we discovered it.
Posted by Benjamin Ackerman, Anunoy Ghosh and David Warren, Chrome Safety Staff
Chrome extensions can increase your shopping, empowering you to do something from customizing the look of websites to offering customized recommendation while you’re planning a trip. However as with every software program, extensions may introduce danger.
That’s why we now have a group whose solely job is to give attention to holding you secure as you put in and make the most of Chrome extensions. Our group:
Gives you with a personalised abstract of the extensions you’ve put in
Evaluations extensions earlier than they’re printed on the Chrome Internet Retailer
Repeatedly displays extensions after they’re printed
A abstract of your extensions
The highest of the extensions web page (chrome://extensions) warns you of any extensions you’ve put in that may pose a safety danger. (In case you don’t see a warning panel, you most likely don’t have any extensions it is advisable fear about.) The panel contains:
Extensions suspected of together with malware
Extensions that violate Chrome Internet Retailer insurance policies
Extensions which have been unpublished by a developer, which could point out that an extension is not supported
Extensions that haven’t printed what they do with information they acquire and different privateness practices
You’ll get notified when Chrome’s Security Verify has suggestions for you or you’ll be able to verify by yourself by working Security Verify. Simply sort “run security verify” in Chrome’s handle bar and choose the corresponding shortcut: “Go to Chrome security verify.”
Consumer move of eradicating extensions highlighted by Security Verify.
Moreover the Security Verify, you’ll be able to go to the extensions web page straight in numerous methods:
Navigate to chrome://extensions
Click on the puzzle icon and select “Handle extensions”
Click on the Extra selections menu and select menu > Extensions > Handle Extensions
Reviewing extensions earlier than they’re printed
Earlier than an extension is even accessible to put in from the Chrome Internet Retailer, we now have two ranges of verification to make sure an extension is secure:
An automatic evaluate: Every extension will get examined by our machine-learning techniques to identify attainable violations or suspicious habits.
A human evaluate: Subsequent, a group member examines the pictures, descriptions, and public insurance policies of every extension. Relying on the outcomes of each the automated and guide evaluate, we could carry out a good deeper and extra thorough evaluate of the code.
This evaluate course of weeds out the overwhelming majority of dangerous extensions earlier than they even get printed. In 2024, lower than 1% of all installs from the Chrome Internet Retailer have been discovered to incorporate malware. We’re pleased with this document and but some dangerous extensions nonetheless get by way of, which is why we additionally monitor printed extensions.
Monitoring printed extensions
The identical Chrome group that evaluations extensions earlier than they get printed additionally evaluations extensions which are already on the Chrome Internet Retailer. And similar to the pre-check, this monitoring contains each human and machine evaluations. We additionally work intently with trusted safety researchers exterior of Google, and even pay researchers who report attainable threats to Chrome customers by way of our Developer Knowledge Safety Rewards Program.
What about extensions that get up to date over time, or are programmed to execute malicious code at a later date? Our techniques monitor for that as effectively, by periodically reviewing what extensions are literally doing and evaluating that to the acknowledged aims outlined by every extension within the Chrome Internet Retailer.
If the group finds that an extension poses a extreme danger to Chrome customers, it’s instantly take away from the Chrome Internet Retailer and the extension will get disabled on all browsers which have it put in.
The extensions web page highlights when you’ve a doubtlessly unsafe extension downloaded
Others steps you’ll be able to take to remain secure
Overview new extensions earlier than putting in them
The Chrome Internet Retailer gives helpful details about every extension and its developer. The next info ought to make it easier to determine whether or not it’s secure to put in an extension:
Verified and featured badges are awarded by the Chrome group to extensions that observe our technical finest practices and meet a excessive customary of person expertise and design
Scores and evaluations from our customers
Details about the developer
Privateness practices, together with details about how an extension handles your information
Watch out of websites that attempt to shortly persuade you to put in extensions, particularly if the positioning has little in frequent with the extension.
Overview extensions you’ve already put in
Despite the fact that Security Verify and your Extensions web page (chrome://extensions) warn you of extensions that may pose a danger, it’s nonetheless a good suggestion to evaluate your extensions on occasion.
Uninstall extensions that you just not use.
Overview the outline of an extension within the Chrome Internet Retailer, contemplating the extension’s scores, evaluations, and privateness practices — evaluations can change over time.
Examine an extension’s acknowledged objectives with 1) the permissions requested by an extension and a couple of) the privateness practices printed by the extension. If requested permissions don’t align with acknowledged objectives, think about uninstalling the extension.
The Enhanced safety mode of Secure Looking is Chrome’s highest stage of safety that we provide. Not solely does this mode give you the most effective protections towards phishing and malware, however it additionally gives further options focused to maintain you secure towards doubtlessly dangerous extensions. Threats are continuously evolving and Secure Looking’s Enhanced safety mode is one of the best ways to make sure that you’ve probably the most superior safety features in Chrome. This may be enabled from the Secure Looking settings web page in Chrome (chrome://settings/safety) and choosing “Enhanced”.
An Introduction to Time Sequence Forecasting with Generative AI
Time collection forecasting has been a cornerstone of enterprise useful resource planning for many years. Predictions about future demand information important selections such because the variety of models to inventory, labor to rent, capital investments into manufacturing and success infrastructure, and the pricing of products and companies. Correct demand forecasts are important for these and lots of different enterprise selections.
Nonetheless, forecasts are not often if ever excellent. Within the mid-2010s, many organizations coping with computational limitations and restricted entry to superior forecasting capabilities reported forecast accuracies of solely 50-60%. However with the broader adoption of the cloud, the introduction of much more accessible applied sciences and the improved accessibility of exterior information sources comparable to climate and occasion information, organizations are starting to see enhancements.
As we enter the period of generative AI, a brand new class of fashions known as time collection transformers seems able to serving to organizations ship much more enchancment. Just like massive language fashions (like ChatGPT) that excel at predicting the following phrase in a sentence, time collection transformers predict the following worth in a numerical sequence. With publicity to massive volumes of time collection information, these fashions change into consultants at choosing up on refined patterns of relationships between the values in these collection with demonstrated success throughout a wide range of domains.
On this weblog, we’ll present a high-level introduction to this class of forecasting fashions, meant to assist managers, analysts and information scientists develop a primary understanding of how they work. We’ll then present entry to a collection of notebooks constructed round publicly out there datasets demonstrating how organizations housing their information in Databricks could simply faucet into a number of of the most well-liked of those fashions for his or her forecasting wants. We hope that this helps organizations faucet into the potential of generative AI for driving higher forecast accuracies.
Understanding Time Sequence Transformers
Generative AI fashions are a type of a deep neural community, a posh machine studying mannequin inside which numerous inputs are mixed in a wide range of methods to reach at a predicted worth. The mechanics of how the mannequin learns to mix inputs to reach at an correct prediction is known as a mannequin’s structure.
The breakthrough in deep neural networks which have given rise to generative AI has been the design of a specialised mannequin structure referred to as a transformer. Whereas the precise particulars of how transformers differ from different deep neural community architectures are fairly complicated, the easy matter is that the transformer is excellent at choosing up on the complicated relationships between values in lengthy sequences.
To coach a time collection transformer, an appropriately architected deep neural community is uncovered to a big quantity of time collection information. After it has had the chance to coach on hundreds of thousands if not billions of time collection values, it learns the complicated patterns of relationships present in these datasets. When it’s then uncovered to a beforehand unseen time collection, it might probably use this foundational data to determine the place comparable patterns of relationships throughout the time collection exist and predict new values within the sequence.
This means of studying relationships from massive volumes of information is known as pre-training. As a result of the data gained by the mannequin throughout pre-training is extremely generalizable, pre-trained fashions known as basis fashions could be employed towards beforehand unseen time collection with out extra coaching. That stated, extra coaching on a company’s proprietary information, a course of known as fine-tuning, could in some cases assist the group obtain even higher forecast accuracy. Both means, as soon as the mannequin is deemed to be in a passable state, the group merely must current it with a time collection and ask, what comes subsequent?
Addressing Widespread Time Sequence Challenges
Whereas this high-level understanding of a time collection transformer could make sense, most forecast practitioners will probably have three instant questions. First, whereas two time collection could comply with the same sample, they might function at fully totally different scales, how does a transformer overcome that downside? Second, inside most time collection fashions there are day by day, weekly and annual patterns of seasonality that should be thought-about, how do fashions know to search for these patterns? Third, many time collection are influenced by exterior elements, how can this information be integrated into the forecast era course of?
The primary of those challenges is addressed by mathematically standardizing all time collection information utilizing a set of methods known as scaling. The mechanics of this are inside to every mannequin’s structure however basically incoming time collection values are transformed to a regular scale that permits the mannequin to acknowledge patterns within the information primarily based on its foundational data. Predictions are made and people predictions are then returned to the unique scale of the unique information.
Relating to the seasonal patterns, on the coronary heart of the transformer structure is a course of referred to as self-attention. Whereas this course of is kind of complicated, essentially this mechanism permits the mannequin to be taught the diploma to which particular prior values affect a given future worth.
Whereas that seems like the answer for seasonality, it is essential to grasp that fashions differ of their capacity to choose up on low-level patterns of seasonality primarily based on how they divide time collection inputs. By a course of referred to as tokenization, values in a time collection are divided into models referred to as tokens. A token could also be a single time collection worth or it might be a brief sequence of values (sometimes called a patch).
The scale of the token determines the bottom degree of granularity at which seasonal patterns could be detected. (Tokenization additionally defines logic for coping with lacking values.) When exploring a specific mannequin, it is essential to learn the generally technical data round tokenization to grasp whether or not the mannequin is suitable to your information.
Lastly, concerning exterior variables, time collection transformers make use of a wide range of approaches. In some, fashions are skilled on each time collection information and associated exterior variables. In others, fashions are architected to grasp {that a} single time collection could also be composed of a number of, parallel, associated sequences. Whatever the exact method employed, some restricted help for exterior variables could be discovered with these fashions.
A Temporary Have a look at 4 In style Time Sequence Transformers
With a high-level understanding of time collection transformers beneath our belt, let’s take a second to have a look at 4 fashionable basis time collection transformer fashions:
Chronos
Chronos is a household of open-source, pretrained time collection forecasting fashions from Amazon. These fashions take a comparatively naive strategy to forecasting by decoding a time collection as only a specialised language with its personal patterns of relationships between tokens. Regardless of this comparatively simplistic strategy which incorporates help for lacking values however not exterior variables, the Chronos household of fashions has demonstrated some spectacular outcomes as a general-purpose forecasting resolution (Determine 1).
TimesFM is an open-source basis mannequin developed by Google Analysis, pre-trained on over 100 billion real-world time collection factors. Not like Chronos, TimesFM contains a while series-specific mechanisms in its structure that allow the consumer to exert fine-grained management over how inputs and outputs are organized. This has an affect on how seasonal patterns are detected but additionally the computation occasions related to the mannequin. TimesFM has confirmed itself to be a really highly effective and versatile time collection forecasting software (Determine 2).
Moirai, developed by Salesforce AI Analysis, is one other open-source basis mannequin for time collection forecasting. Skilled on “27 billion observations spanning 9 distinct domains”, Moirai is introduced as a common forecaster able to supporting each lacking values and exterior variables. Variable patch sizes enable organizations to tune the mannequin to the seasonal patterns of their datasets and when utilized correctly have been demonstrated to carry out fairly nicely towards different fashions (Determine 3).
TimeGPT is a proprietary mannequin with help for exterior (exogenous) variables however not lacking values. Targeted on ease of use, TimeGPT is hosted by a public API that permits organizations to generate forecasts with as little as a single line of code. In benchmarking the mannequin towards 300,000 distinctive collection at totally different ranges of temporal granularity, the mannequin was proven to provide some spectacular outcomes with little or no forecasting latency (Determine 4).
Determine 4. Analysis metrics for TimeGPT and varied different fashions towards 300,000 distinctive collection (from https://arxiv.org/pdf/2310.03589)
Getting Began with Transformer Forecasting on Databricks
With so many mannequin choices and extra nonetheless on the best way, the important thing query for many organizations is, the way to get began in evaluating these fashions utilizing their very own proprietary information? As with all different forecasting strategy, organizations utilizing time collection forecasting fashions should current their historic information to the mannequin to create predictions, and people predictions have to be rigorously evaluated and finally deployed to downstream programs to make them actionable.
Due to Databricks’ scalability and environment friendly use of cloud sources, many organizations have lengthy used it as the premise for his or her forecasting work, producing tens of hundreds of thousands of forecasts on a day by day and even larger frequency to run their enterprise operations. The introduction of a brand new class of forecasting fashions does not change the character of this work, it merely supplies these organizations extra choices for doing it inside this surroundings.
That is to not say that there usually are not some new wrinkles that include these fashions. Constructed on a deep neural community structure, many of those fashions carry out greatest when employed towards a GPU, and within the case of TimeGPT, they might require API calls to an exterior infrastructure as a part of the forecast era course of. However essentially, the sample of housing a company’s historic time collection information, presenting that information to a mannequin and capturing the output to a queriable desk stays unchanged.
To assist organizations perceive how they might use these fashions inside a Databricks surroundings, we have assembled a collection of notebooks demonstrating how forecasts could be generated with every of the 4 fashions described above. Practitioners could freely obtain these notebooks and make use of them inside their Databricks surroundings to achieve familiarity with their use. The code introduced could then be tailored to different, comparable fashions, offering organizations utilizing Databricks as the premise for his or her forecasting efforts extra choices for utilizing generative AI of their useful resource planning processes.
Get began with Databricks for forecasting modeling right now with this collection of notebooks.
Posted by Chris Arriola – Developer Relations Engineer
Google I/O 2024 was full of plenty of updates and bulletins round serving to you be extra productive as a developer. Listed below are the highest 3 bulletins round Jetpack Compose and Kind Components from Google I/O 2024:
#1 New updates in Jetpack Compose
The June 2024 launch of Jetpack Compose is full of new options and enhancements resembling shared aspect transitions, lazy checklist merchandise animations, and efficiency enhancements throughout the board.
With shared aspect transitions, you possibly can create pleasant continuity between screens in your app. This function works along with Navigation Compose and predictive again in order that transitions can occur as customers navigate your app. One other extremely requested function—lazy checklist merchandise animations—can also be now supported for lazy lists giving it the power to animate inserts, deletions, and reordering of things.
Jetpack Compose additionally continues to enhance runtime efficiency with each launch. Our benchmarks present a sooner time to first pixel of 17% in our Jetsnack Compose pattern. Moreover, robust skipping mode graduated from experimental to production-ready standing additional enhancing the efficiency of Compose apps. Merely replace your app to benefit from these advantages.
#2 Scaling throughout screens with new Compose APIs and Instruments
Throughout Google I/O, we introduced new instruments and APIs to make it simpler to construct throughout screens with Compose. The brand new Materials 3 adaptive library introduces new APIs that will let you implement frequent adaptive situations resembling list-detail, and supporting pane. These APIs enable your app to show one or two panes relying on the out there measurement on your app.
We additionally introduced that Compose for TV 1.0.0 is now out there in beta. The newest updates to Compose for TV embody higher efficiency, enter help, and an entire vary of improved elements that look nice out of the field. New on this launch, we’ve added lists, navigation, chips, and settings screens. We’ve additionally added a new TV Materials Catalog app and up to date the developer instruments in Android Studio to incorporate a brand new venture wizard to get a working begin with Compose for TV.
Take a look at case research from SoundCloud and Adidas to see how apps are leveraging Compose to construct their apps and study extra about all of the updates for Compose throughout screens by studying extra right here!
#3 Look 1.1
Jetpack Look is Android’s fashionable advisable framework for constructing widgets. The newest model, Look 1.1, is now secure. Look is constructed on high of Jetpack Compose permitting you to make use of the identical declarative syntax that you just’re used to when constructing widgets.
This launch brings a brand new unit check library, Error UIs, and new elements. Moreover, we’ve launched new Canonical Widget Layouts on GitHub to will let you get began sooner with a set of layouts that align with finest practices and we’ve printed new design steerage printed on the UI design hub — test it out!