Home Blog Page 3852

Methods to Construct a Barcode Generator Utilizing SwiftUI


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.

swiftui-barcode-generator

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:

VStack(alignment: .main) {

    Textual content("Barcode Generator")
        .font(.system(measurement: 60, weight: .black, design: .rounded))

    Textual content("Please key in your barcode information within the textual content subject")
        .font(.headline)
        .padding(.backside, 20)

    TextField("", textual content: $inputText)
        .padding()
        .font(.title)
        .background(Coloration(.systemGray6))

    Spacer()

    VStack(spacing: 0) {
        barcodeGenerator.generateBarcode(textual content: inputText)
            .resizable()
            .scaledToFit()

        Textual content(inputText.isEmpty ? "Unknown information" : inputText)
    }

}
.padding()

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.

swiftui-barcode-generator-code-128

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 studies third quarter outcomes

0


Staying Secure with Chrome Extensions


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 aren’t from the Chrome Internet Retailer
  • 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:

  1. An automatic evaluate: Every extension will get examined by our machine-learning techniques to identify attainable violations or suspicious habits.
  2. 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.

  1. Uninstall extensions that you just not use.
  2. 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.
  3. 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.
  4. Restrict the websites an extension has permission to work on.

Allow Enhanced Safety

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

0


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).

Evaluation metrics for Chronos and  various other forecasting models applied to 27 benchmarking data sets

Determine 1. Analysis metrics for Chronos and  varied different forecasting fashions utilized to 27 benchmarking information units (from https://github.com/amazon-science/chronos-forecasting)

TimesFM

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).

Evaluation metrics for TimesFM and various other models against the Monash Forecasting Archive dataset

Determine 2. Analysis metrics for TimesFM and varied different fashions towards the Monash Forecasting Archive dataset (from https://analysis.google/weblog/a-decoder-only-foundation-model-for-time-series-forecasting/)

Moirai

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).

Evaluation metrics for Moirai and various other models against the Monash Time Series Forecasting Benchmark

Determine 3. Analysis metrics for Moirai and varied different fashions towards the Monash Time Sequence Forecasting Benchmark (from https://weblog.salesforceairesearch.com/moirai/)

TimeGPT

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).

Evaluation metrics for TimeGPT and various other models against 300,000 unique series

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.

High 3 Updates with Compose throughout Kind Components at Google I/O ’24



High 3 Updates with Compose throughout Kind Components at Google I/O ’24

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.

Learn What’s new in Jetpack Compose at I/O ‘24 for extra info.

#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.

Watch Constructing UI with the Materials 3 adaptive library and Constructing adaptive Android apps to study extra. For those who desire to learn, you possibly can try About adaptive layouts in our documentation.

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.

Lastly, Compose for Put on OS has added options resembling SwipeToReveal, an expandableItem, and a variety of WearPreview supporting annotations. Throughout Google I/O 2024, Compose for Put on OS graduated visible enhancements and fixes from beta to secure. Be taught extra about all of the updates to Put on OS by testing the technical session.

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!

To study extra about utilizing Look, try Construct lovely Android widgets with Jetpack Look. Or if you need one thing extra hands-on, try the codelab Create a widget with Look.

You may study extra in regards to the newest updates to Compose and Kind Components by testing the Compose Throughout Screens and the What’s new in Jetpack Compose at I/O ‘24 weblog posts or watching the highlight playlist!