predictive hack
Mastering Sentence Transformers For Sentence Similarity – Predictive Hacks
Sentence transformers is a Python framework for state-of-the-art vector representations of sentences. Having the sentences in space we can compute the distance between them and by doing that, we can find the most similar sentences based on their semantic meaning. As an example, let's say that we have these two sentences: The closest sentence is the "Coffee makes mornings better." Even if they don't use the same words, their vector representations will be close to each other. To get the similarity of two sentence vectors, we are using the cosine similarity(1 – cosine distance).
Transfer Learning on Images with Tensorflow 2 – Predictive Hacks
In this tutorial, we will provide you an example of how you can build a powerful neural network model to classify images of cats and dogs using transfer learning by considering as base model a pre-trained model trained on ImageNet and then we will train additional new layers for our cats and dogs classification model. We will work with a sample of 600 images from the Dogs vs Cats dataset, which was used for a 2013 Kaggle competition. Our base model will be the pre-trained MobileNet V2 model. We will remove the final layer of the network and replace it with new, untrained classifier layers for our task. We will create a new model that has the same input tensor as the MobileNetV2 model, and uses the output tensor from the layer with name global_average_pooling2d_6 as the model output.
Example of Celebrity Rekognition with AWS – Predictive Hacks
Amazon Rekognition gives us the chance to recognize celebrities in images and videos. For our example, I will choose the images of Antentokounmpo Brothers and we will see if the Rekognition can recognize them. You can try this image in the AWS Console. Let's see what we get: As we can see, it managed to detect Giannis and Thanasis Antentokounmpo! We can get call the API via Python and boto3 and we can get all the info from the API response which is in json format.
How to use Google Translate using Python – Predictive Hacks
All of us are aware of Google Translate. Today, we will provide examples of how we can use the googletrans which is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate . The first thing that we need to do is to install the googletrans library. I suggest to use the conda install command.
Simple Example of Speech To Text – Predictive Hacks
Speech recognition (or Speech To Text) is still far from perfect. However, the SpeechRecognition library provides an easy way to interact with many speech-to-text APIs. In this post, we will show how to use the Python SpeechRecognition library to easily start converting the spoken language in our audio files to text. SpeechRecognition is a library for performing speech recognition, with support for several engines and APIs, online and offline. For our example we will use the recognize_google, however there are also some other choices like recognize_bing(), recognize_wit().
Basic Examples of Anaconda Environments – Predictive Hacks
This post is a gentle introduction about Anaconda Environments which is like the "Docker" of the Machine Learning projects. It is very important when we are working on a project to be reproducible and for that reason, we want to be able to share our working environment with our colleagues, or each project to be in a different environment. Notice that conda supports Python, R, Scala and Julia but we will focus on Python in this post. The open-source Anaconda Distribution is the easiest way to perform Python/R data science and machine learning on Linux, Windows, and Mac OS X. With over 15 million users worldwide, it is the industry standard for developing, testing, and training on a single machine.
Face Detection in OpenCV – Predictive Hacks
We will discuss about how we can apply Face Detection using OpenCV. We go straightforward with a practical reproducible example. The logic it the following: We get the image from the URL (or from the hard disk). We convert it to an numpy array and then to a gray scale. Then by applying the proper CascadeClassifier we get the bounding boxes of the faces.
Basic Example of Neural Style Transfer – Predictive Hacks
This post is a practical example of Neural Style Transfer based on the paper A Neural Algorithm of Artistic Style (Gatys et al.). For this example we will use the pretained Arbitrary Image Stylization module which is available in TensorFlow Hub. We will work with Python and tensorflow 2.x. Neural style transfer is an optimization technique used to take two images--a content image and a style reference image (such as an artwork by a famous painter)--and blend them together so the output image looks like the content image, but "painted" in the style of the style reference image. This is implemented by optimizing the output image to match the content statistics of the content image and the style statistics of the style reference image.