New Cover: Cienfue – Macho de Monte Suite (Short Intro)

Advertisements

Face recognition of celebrities with Amazon Rekognition

As stated on the Amazon Web Services website, Amazon Rekognition is a service that enables you to add image analysis to your applications. With Rekognition, you can detect objects, scenes, and faces in images. Among the most important features offered by Amazon Rekognition are:

 

  • Objects and Scene Detection
  • Moderation of Images
  • Facial Analysis
  • Facial Recognition
  • Celebrity Recognition

 

In this technical example, we’re going to use the Java SDK to show how to develop a simple and useful application that recognizes celebrities faces in order to demonstrate the capabilities of the service.

 

AWS Rekognition results (1)

 

We picked various pictures of recognized celebrities like Cristiano Ronaldo, Celine Dion and Sting, obtaining favorable results as showed in the infographic.

For the technical side, we will focus on the most important steps and will omit the less-specific parts (you can get all the code at Github)

 
1) Create an Amazon Rekognition client using the AmazonRekognitionClientBuilder including the Region to be used and a RecognizeCelebritiesRequest containing the representation in bytes of the picture.

 
AmazonRekognition amazonRekognition = AmazonRekognitionClientBuilder .standard() .withRegion(Regions.US_WEST_2) .build();  

  RecognizeCelebritiesRequest request = new RecognizeCelebritiesRequest()    .withImage(new Image().withBytes(imageBytes));

 

2) Create a RecognizeCelebritiesResult object that will contain the obtained results:

 
RecognizeCelebritiesResult result = amazonRekognition.recognizeCelebrities(request);

 
3) Display the recognized celebrity information

 

List celebs=result.getCelebrityFaces();   

System.out.println(celebs.size() + ” celebrity(s) were recognized.\n”);   

List metadata = new ArrayList();       

for (Celebrity celebrity: celebs) {   

// Name       

System.out.println(“Celebrity recognized: ” + celebrity.getName());        metadata.add(“Celebrity recognized: ” + celebrity.getName());               

// Id       

System.out.println(“Celebrity ID: ” + celebrity.getId());       

metadata.add(“Celebrity ID: ” + celebrity.getId());               

// Extra info       

System.out.println(“Further information (if available):”);       

metadata.add(“Further information (if available):”);               

for (String url: celebrity.getUrls()){           

System.out.println(url);         

 metadata.add(url);       

}       

 

Although Amazon Rekognition is relatively new to the market, we were impressed by its capabilities, competitive pricing and features. There’s a great potential for Rekognition to become a standard for image analysis based in Deep Learning algorithms, along with competing services like Clarifai and Google’s Vision API.

The near future looks very promising for software development focused on Artificial Intelligence, a market that will definitely open new horizons for the creation of impressive tools that could have a beneficial impact on our society.

Apache Spark: Fundamentos Teóricos

spark_0

Apache Spark es un Framework de código abierto para sistemas distribuidos originalmente desarrollado en la Universidad de California en el AMPLab de Berkeley. La base de código de Spark fue posteriormente donada a la Apache Software Foundation, quienes han realizado las labores de desarrollo y mantenimiento desde entonces.

Spark provee a los desarrolladores con una API centrada en una estructura de datos llamada RDD (Resilient Distributed Dataset ó Conjunto de Datos Resiliente y Distribuido), el cual es un multiconjunto de datos distribuidos en un clúster de máquinas que es mantenido a través de una arquitectura tolerante a fallas.

Otro hecho importante a mencionar es que Apache Spark fue desarrollado en respuesta a las limitaciones del paradigma MapReduce, el cual forza a una estructura particular de flujo de datos lineal en programas distribuidos. Los programas en MapReduce obtienen la entrada de datos realizando operaciones de lectura en disco, mapean una función en el conjunto de datos, reducen los resultados del “mapping” y almacenan los resultados de la reducción en disco.

mapreduce

Las estructuras RDD funcionan como un conjunto de trabajo para programas distribuidos que ofrecen (deliberadamente) una forma restingida de memoria compartida y distribuida. La disponibilidad de RDDs facilita la implementación de algoritmos iterativos (que visitan el conjunto de datos múltiples veces en un ciclo) y análisis interactivos / exploratorios de datos, como por ejemplo el estilo repetitvo de búsquedas en bases de datos.

La latencia de dichas aplicaciones (en comparación con Apache Hadoop, una implementación muy popular de MapReduce) puede ser reducida en varios órdenes de magnitud. Entre la clase de algoritmos iterativos se encuentran los algoritmos de entrenamiento para sistemas de aprendizaje de máquinas (Machine Learning), uno de los tópicos fundamentales para el desarrollo de Apache Spark.

Apache Spark requiere de un Administrador de Clústeres y un Sistema de Almacenamiento Distribuido. Para la Administración de Clústeres, Spark soporta un clúster nativo Spark en modo standalone, Hadoop YARN ó Apache Mesos.

Para Almacenamiento Distribuido, Spark puede servir de interfaz con una amplia variedad que incluye:

– HDFS (Hadoop Distributed File System)
– MapR File System (MAPR-FS)
– Apache Cassandra
– OpenStack Swift
– Amazon S3
– Kudu
– Soluciones Personalizadas

Spark también provee soporte para un modo local pseudo-distribuido que usualmente es utilizado para desarrollo o Testing, donde el almacenamiento distribuido no es un requerimiento y el Sistema Local de Archivos puede ser usado sin problemas. En dicho escenario, Spark corre en un solo nodo o máquina con un ejecutor por cada CPU Core.

Data Visualization in D3.js for the Venezuelan National Soccer Team

It’s often typical nowadays inside organizations, the extraction of valuable information from big amounts of pooled data inside of their servers. In the past years and even in our days, companies are relying on Excel spreadsheets to analyze the most important bits in a more readable format.

Nonetheless, it’s still hard to understand several lines of text laying inside a table of cells, it’s easier for the human eye, to understand graphic representations of data. Here is where the D3.js magic comes into action.

As its own website defines, D3.js is a JavaScript library for manipulating documents based on data, using HTML, SVG, and CSS.

In this example, I will use statistical data from the Venezuelan National Soccer Team to build a bar chart for the top scorers of all times.

1) First, we define an array of arrays, using the player name as the key and the number of goals as the value. Keep in mind that for this example we are going to use static data, but of course this can be changed in order to make it work dynamically, for example using AJAX to make a data request to our server.

var scorers = [["Juan Arango", 22],
               ["Giancarlo Maldonado", 22],
               ["Salomón Rondón", 14],
               ["Ruberth Morán", 14],
               ["Miku", 11],
               ["José Manuel Rey", 11],
               ["Daniel Arismendi", 9],
               ["Gabriel Urdaneta", 9],
               ["Juan García", 7],
               ["Ricardo David Páez", 7], 
               ["Oswaldo Vizcarrondo", 7]
               ];

2) As a second step, we define the scale. Scales are functions that map from an input domain to an output range, in D3.js we can define it with this line of code:

   var scale = d3.scale.linear().domain( [0 , domain] ).range( [0,600] );

 

Take into account that we have previously defined the domain for the scale:

   var domain = d3.max( scorers , function(d){ return d[1]; });

3)  After this, we select the chart class, and take all the ‘divs’ inside. Then we attach the data to the selected element(s). We also set the width of the ‘div’ using the scale mapping function that we defined previously. Finally, we render the text inside the bar charts (the one that holds the player name and number of goals).

     
        d3.select(".chart")         
	.selectAll("div")
	.data(scorers) 
	.enter().append("div")
	.style("width", function(d) {return scale(d[1]) + "px";}) 
	.html(function(d) { return d[0] + ": " + d[1] + " goals"; });

 

4) Finally, we obtain the bar chart showing the top scorers of the Venezuelan National Team. This way, it’s easier to state that Juan Arango and Giancarlo Maldonado are the maximum scorers of all times with 22 goals playing for the “Vinotinto”, and in a descendent scale, we can watch the rest of the players who have earned a place in the history of Venezuelan soccer.

See the Pen GZEjxZ by Dario Carrasquel (@jeetkunecoder) on CodePen.