python generator
Natlog: a Lightweight Logic Programming Language with a Neuro-symbolic Touch
We introduce Natlog, a lightweight Logic Programming language, sharing Prolog's unification-driven execution model, but with a simplified syntax and semantics. Our proof-of-concept Natlog implementation is tightly embedded in the Python-based deep-learning ecosystem with focus on content-driven indexing of ground term datasets. As an overriding of our symbolic indexing algorithm, the same function can be delegated to a neural network, serving ground facts to Natlog's resolution engine. Our open-source implementation is available as a Python package at https://pypi.org/project/natlog/ .
Modular image processing pipeline using OpenCV and Python generators
Next, we define thelist_images function (line 22โ34) which will help us to walk through the input directory structure to grab the image paths. For face detection, we use the Viola-Jones algorithm known as Haar cascade (line 40). It was published in 2001 by Paul Viola and Michael Jones. You can learn more about the algorithm from their original paper Rapid Object Detection using a Boosted Cascade of Simple Features or Wikipedia page. It is quite an old algorithm in the era of deep learning and false-positives prone (reporting a face in the place of the image where no face is present). Even though it is quite easy to use for our demonstrative case. The main processing loop goes as follow: we walk through image files (line 49), read them (line 51) one by one, detect the faces (line 55), save them to the prepared directory (line 59โ72) and saving a summary report (line 78โ82) with faces coordinates.
A single function to streamline image classification with Keras
Therefore, in this article, we focus on how to use a couple of utility methods from the Keras (TensorFlow) API to streamline the training of such models (specifically for a classification task) with a proper data pre-processing. In the end, we aim to write a single utility function, which can take just the name of your folder where training images are stored, and give you back a fully trained CNN model. We use a dataset consisting of 4000 images of flowers for this demo. The dataset can be downloaded from the Kaggle website here. The data collection is based on the data Flickr, Google images, Yandex images.