8

Machine Learning and React Native - DZone Web Dev

 2 years ago
source link: https://dzone.com/articles/machine-learning-and-react-native-feasible-for-web
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Machine Learning and React Native: Feasible for Web Development?

Machine Learning isn't just meant for big machines with lots of GPUs. What if you can execute ML models on your phone! And with React Native it's not all that hard!

Sep. 23, 21 · Web Dev Zone · Code Snippet

Join the DZone community and get the full member experience.

Join For Free

Unless you have been living under a rock, there is no way you have not heard of at least artificial intelligence. Of course, this is because of the potent tool it has proven to be over the past decade. This popularity, then, led to the emergence of machine learning as well as deep learning. Now, they are both technically subsets of artificial intelligence, but the plethora of their advantages have ensured they were each able to establish their distinct identities in the market. Now, machine learning serves to help systems use input data to improve themselves. 

Meanwhile, deep learning, which involves the use of algorithms based on the human brain’s structure and function, is enabling the achievement of unparalleled results in computer vision, ML, etc.

This leads us to the question, what tools can one use to put these avant-garde technologies to work for them? Of course, the market has plenty of options to offer as well, with each promising to enable the development of some of the finest tools and solutions are driven by machine learning and deep learning. Machine Learning as you might be aware might sound like it is just meant for big machines with lots of GPUs. But what if you can execute ML models on your phone! And with React Native it's not all that hard! But can we use ML in react native? 

Yet, there is one name that has consistently fared as the top choice for developers and companies working to embrace these technologies: React Native. This is not surprising at all though, especially when you consider just how much React Native can help in this regard. From the design model in Python and loading pre-trained models to building the tailored React Native component to leveraging the neural network for presentation, the process may seem complex on the outset, but can be simpler and much more rewarding than imagined.

Of course, one needs other tools to develop neural networks. TensorFlow is widely accepted to be among the top options in the market. The React Native TensorFlow open-source library includes two APIs: one for direct TensorFlow interaction and one image recognition API. 

Here is how one can use the image recognition API. 

    1. Make an rn-cli.config.js file in the project’s root, then add the TensorFlow model as well as the Label file.

module.exports = {   getAssetExts() {     return ['pb', 'txt']   } }

    2. TensorFlow and Label model file: Next step is to add the TensorFlow model file to the assets. After that, add the label file to the assets.

tensorflow_inception_graph.pb 

tensorflow_labels.txt 

    3. Time to kick off the tfImageRecognition API class: Use the model and the label to put the tfImageRecognition API to work.

const tfImageRecognition = new tfImageRecognition({   model: require('./assets/tensorflow_inception_graph.pb'),   labels: require('./assets/tensorflow_labels.txt'), }); 

    4. Call the recognize function: 

const results = await ifImageRecognition.recognize({   image: require('./assets/panda.jpg'), }); 

There is no doubt that as time progresses, we will find more intricate and better uses for the trio of artificial intelligence, machine learning, and deep learning. As the world comes to rely on this set of technologies in a variety of aspects, we will also need other tools and solutions to access these technologies and properly put them to work for us. 

Conclusion

As the above discussion demonstrates, the aforementioned framework is very well among the top choices for developers working on integrating machine learning and deep learning with React Native apps. Anyone seeking to put these technologies to work for them would do well to consider React Native as their choice of tool. 

Do you have alternate views on this topic on how to make this happen? Let me know your thoughts.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK