Flashing lights ward off livestock-hunting pumas in northern Chile

first_img Popular in the CommunitySponsoredSponsoredOrangutan found tortured and decapitated prompts Indonesia probeEMGIES17 Jan, 2018We will never know the full extent of what this poor Orangutan went through before he died, the same must be done to this evil perpetrator(s) they don’t deserve the air that they breathe this has truly upset me and I wonder for the future for these wonderful creatures. So called ‘Mankind’ has a lot to answer for we are the only ones ruining this world I prefer animals to humans any day of the week.What makes community ecotourism succeed? In Madagascar, location, location, locationScissors1dOther countries should also learn and try to incorporateWhy you should care about the current wave of mass extinctions (commentary)Processor1 DecAfter all, there is no infinite anything in the whole galaxy!Infinite stupidity, right here on earth.The wildlife trade threatens people and animals alike (commentary)Anchor3dUnfortunately I feel The Chinese have no compassion for any living animal. They are a cruel country that as we knowneatbeverything that moves and do not humanily kill these poor animals and insects. They have no health and safety on their markets and they then contract these diseases. Maybe its karma maybe they should look at the way they live and stop using animals for all there so called remedies. DisgustingConservationists welcome China’s wildlife trade banThobolo27 JanChina has consistently been the worlds worst, “ Face of Evil “ in regards our planets flora and fauna survival. In some ways, this is nature trying to fight back. This ban is great, but the rest of the world just cannot allow it to be temporary, because history has demonstrated that once this coronavirus passes, they will in all likelihood, simply revert to been the planets worst Ecco Terrorists. Let’s simply not allow this to happen! How and why they have been able to degrade this planets iconic species, rape the planets rivers, oceans and forests, with apparent impunity, is just mind boggling! Please no more.Probing rural poachers in Africa: Why do they poach?Carrot3dOne day I feel like animals will be more scarce, and I agree with one of my friends, they said that poaching will take over the world, but I also hope notUpset about Amazon fires last year? Focus on deforestation this year (commentary)Bullhorn4dLies and more leisSponsoredSponsoredCoke is again the biggest culprit behind plastic waste in the PhilippinesGrapes7 NovOnce again the article blames companies for the actions of individuals. It is individuals that buy these products, it is individuals that dispose of them improperly. If we want to change it, we have to change, not just create bad guys to blame.Brazilian response to Bolsonaro policies and Amazon fires growsCar4 SepThank you for this excellent report. I feel overwhelmed by the ecocidal intent of the Bolsonaro government in the name of ‘developing’ their ‘God-given’ resources.U.S. allocates first of $30M in grants for forest conservation in SumatraPlanet4dcarrot hella thick ;)Melting Arctic sea ice may be altering winds, weather at equator: studyleftylarry30 JanThe Arctic sea ice seems to be recovering this winter as per the last 10-12 years, good news.Malaysia has the world’s highest deforestation rate, reveals Google forest mapBone27 Sep, 2018Who you’re trying to fool with selective data revelation?You can’t hide the truth if you show historical deforestation for all countries, especially in Europe from 1800s to this day. WorldBank has a good wholesome data on this.Mass tree planting along India’s Cauvery River has scientists worriedSurendra Nekkanti23 JanHi Mongabay. Good effort trying to be objective in this article. I would like to give a constructive feedback which could help in clearing things up.1. It is mentioned that planting trees in village common lands will have negative affects socially and ecologically. There is no need to even have to agree or disagree with it, because, you also mentioned the fact that Cauvery Calling aims to plant trees only in the private lands of the farmers. So, plantation in the common lands doesn’t come into the picture.2.I don’t see that the ecologists are totally against this project, but just they they have some concerns, mainly in terms of what species of trees will be planted. And because there was no direct communication between the ecologists and Isha Foundation, it was not possible for them to address the concerns. As you seem to have spoken with an Isha spokesperson, if you could connect the concerned parties, it would be great, because I see that the ecologists are genuinely interested in making sure things are done the right way.May we all come together and make things happen.Rare Amazon bush dogs caught on camera in BoliviaCarrot1 Feba very good iniciative to be fallowed by the ranchers all overSponsored A new paper reports that Foxlights, a brand of portable, intermittently flashing lights, kept pumas away from herds of alpacas and llamas during a recent calving season in northern Chile.Herds without the lights nearby lost seven animals during the four-month study period.The research used a “crossover” design, in which the herds without the lights at the beginning of the experiment had them installed halfway through, removing the possibility that the herds were protected by their locations and not the lights themselves. Pulsating lights placed around llama and alpaca herds warded off puma attacks during a recent experiment in Chile, suggesting the method might help avert conflict between herders and dwindling populations of the predator.“The implications are huge,” Omar Ohrens, a postdoctoral scholar in environmental studies at the University of Wisconsin, Madison, and lead author of a study on the findings, said in an interview.The landscape of the Andean Plateau in Chile, with the village of Chulluncane in the foreground. Image by Omar Ohrens.In the study by Ohrens and his colleagues published online Jan. 3 in the journal Frontiers in Ecology and the Environment, pumas left herds alone that had Foxlights set up close to the llamas and alpacas’ sleeping areas during a recent four-month calving season. During the same period, cats killed seven animals from herds that did not have the lights, which blink in a random pattern designed to mimic a person walking with a flashlight and other human activity.The puma (Puma concolor) is a critical part of the ecology of the high plains of the Andean Plateau, also called the Altiplano, of northern Chile. Such large predators regulate the number of herbivores on the landscape, keeping the entire ecosystem in balance.But when mountain lions pick off livestock, it threatens the livelihoods of the people who depend on that resource. In a 2016 study, Ohrens and his colleagues reported that pastoralists in this part of Chile estimate they lose 10 percent of their animals each year to pumas.A puma track spotted near the study site. Image by Omar Ohrens.The pumas, too, are at risk following these incidents, as herders look to eliminate the threat. But research has shown that killing a predator suspected of targeting livestock doesn’t always work, Ohrens said. What’s more, his earlier surveys of the Aymara llama and alpaca herders of the Altiplano revealed that most people didn’t want to kill pumas. That led Ohrens to find a way to identify and test a potential, non-lethal solution to this problem.In the planning stages of this study, he asked the herders themselves to choose from a variety of potential non-lethal deterrents, and they settled on Foxlights. Developed in Australia to keep young lambs safe from foxes, Foxlights also fit the grasslands of northern Chile. The wide-open plains of the Altiplano allow for the lights to be seen from as far away as 1.6 kilometers (1 mile), according to the manufacturer. And the sunlight that bathes the plateau, which sits between 3,000 and 5,500 meters (9,800 and 18,000 feet) above sea level, can recharge the lights’ batteries during the day.Researchers set up a camera trap near the study site. Image by Omar Ohrens.During the calving season in late 2016 and early 2017, Ohrens and his teammates compared the incidence of livestock kills in herds with lights installed nearby to deaths in herds without them.To make sure that they weren’t just witnessing a single puma zero in on herds without lights — an unlikely, but possible, situation given the large home ranges of pumas, the authors write — they set up camera traps around the herds of the 11 farmers who were part of the study. The images confirmed that at least three different cats were in the area.In a twist, Ohrens found that the lights did not spook off Andean foxes (Lycalopex culpaeus) going after young lambs. That didn’t come as a shock to Ohrens, who has worked in this part of his native Chile for seven years.Villablanca Lagoon and Sillajuay Mountain in the Andean Plateau. Image by Omar Ohrens.“What I’ve seen is that Andean foxes are not very scared of humans — they can get pretty close and even take food from people’s hands,” he said in a statement. “So they’re not going to be scared by lights that simulate human activity.”To further bolster the study’s rigor, the team also moved the lights partway through the experiment from the herds that had them at the beginning of the study to the ones that didn’t. They got similar results, demonstrating that the location of the herds didn’t determine whether the lights were effective.“That’s why this study is so important,” Adrian Treves, a co-author of the study and professor of environmental studies at the University of Wisconsin, said in the statement. “Omar’s study shows that non-lethal methods have been proven effective in multiple settings with different livestock and carnivores.”Banner image of study participants setting up a Foxlight next to a livestock sleeping site by Omar Ohrens. John Cannon is a Mongabay staff writer based in the Middle East. Find him on Twitter: @johnccannonCorrection: An earlier version of this article misstated the study site location. It took place in northern, not southern, Chile.Ohrens, O., Bonacic, C., & Treves, A. (2019). Non-lethal defense of livestock against predators: flashing lights deter puma attacks in Chile. Frontiers in Ecology and the Environment.Ohrens, O., Treves, A., & Bonacic, C. (2016). Relationship between rural depopulation and puma-human conflict in the high Andes of Chile. Environmental Conservation, 43(1), 24-33.FEEDBACK: Use this form to send a message to the author of this post. If you want to post a public comment, you can do that at the bottom of the page. Animal Behavior, Animals, Big Cats, Camera Trapping, Carnivores, Cats, Conservation, Conservation Solutions, Ecology, Environment, Grasslands, Human-wildlife Conflict, Hunting, Indigenous Peoples, Livestock, low-tech, Mammals, Mountains, Predators, Research, Technology, Top Predators, Wildlife, Wildlife Conservation, Wildtech center_img Article published by John Cannonlast_img read more

World Cup 2018 quotes quiz: who said what in Russia?

first_img Share via Email Not so good Juan Carlos Osorio Who said … Toby Alderweireld World Cup 2018 Who said … Julen Lopetegui The sacked Spain manager insists he did nothing wrong by accepting the Real Madrid job just days before Spain’s opening World Cup match against Portugal. Share on Pinterest Fernando Hierro Diego Maradona Well, who else? Diego watched Argentina v Iceland while chuffing on a big fat cigar. This behaviour was mild compared to his antics when Argentina beat Nigeria, though. Martin Keown Stanislav Cherchesov Mark Lawrenson Pretty decent Juan Antonio Pizzi Diego Maradona Argentina might have been knocked out but Diego still had plenty to say about England’s penalty shootout victory over Colombia. You got… Who said… Harry Kane Perfection Submit answers Gareth Southgate Jordan Pickford Juan Carlos Osorio Carlos Queiroz The Iran coach said his team’s work ethic, not individual ability, had helped them to complete a smash-and-grab win over Morocco in their World Cup opener. Nice work Topics Joachim Löw Ivan Perisic Share on Twitter René Higuita Lovely stuff Tite Who said … Share on Facebook Jorge Sampaoli Harry Maguire The Leicester defender talks about his large head after powering home a header during England’s 2-0 defeat of Sweden in the last eight. Aliou Cissé Dejan Lovren The Liverpool centre-back left humility in the dressing-room as he made this bold claim after Croatia beat England in the semi-final. Juan Carlos Osorio The Mexico coach spoke for many observers when summing up Neymar’s theatrics in Russia. Share on WhatsApp World Cup Carlos Valderrama features Share via Email Nice work Kylian Mbappé Pretty decent Lovely stuff Stanislav Cherchesov The Russia manager references the 19th-century playwright to sum up how he believes his team willl play against Croatia in the quarter-final. Who said … Oh dear Who said… Harry Kane Kyle Walker Danny Murphy Ally McCoist The former Scotland striker and ITV co-commentator gives Jon Champion a history lesson during Brazil v Mexico’s last 16 clash. Roy Keane Roberto Martínez Not so good Oh dear Challenge your friends Who said… Luka Modric The Croatia captain and player of the tournament believes his side deserved to win the World Cup, not France. Phil Neville Roy Keane Who said … Vladimir Putin Share on LinkedIn Harry Maguire Share on Facebook Share on Twitter Denis Cheryshev Gareth Southgate Who said… Who said … Share on Messenger Reuse this contentlast_img read more

THE TORONTO SYMPHONY AND ROYAL CONSERVATORY OFFER BACH BEETHOVEN AND BEYOND IN

first_img LEAVE A REPLY Cancel replyLog in to leave a comment Twitter Advertisement The classical music world loves anniversaries, so we can anticipate getting up close and personal with Ludwig van Beethoven in 2020.That’s the word from the Toronto Symphony Orchestra and the Royal Conservatory of Music, which unwrapped their 2019-20 seasons this week. Beethoven’s name features prominently in both, from the best known works to some obscure ones. That’s what you get for turning 250.There’s much more than Beethoven, of course. Both organizations announced offerings that satisfy cravings for music beyond the classical canon. Advertisement Login/Register With: Gustavo Gimeno will conduct Chinese piano sensation Yuja Wang in an all-Brahms program with the TSO in April 2020. (JULIA WESELY) Facebook Advertisementlast_img read more

UFC legend Georges StPierre drops by Sheshatshiu for a visit and some

first_imgAPTN National NewsStudents don’t usually go to school on the weekend.But the Sheshatshiu Innu First Nation in Labrador had a special visitor on Sunday.UFC legend Georges St-Pierre dropped by with some advice on bullying and showed the school wrestling team a few moves.APTN’s Ossie Michelin has the headlock on this story.last_img

Wilmington Ski Snowboard Club Enrollment Now Open

first_imgWILMINGTON, MA — The Wilmington Ski and Snowboard Club has been an enjoyable experience for approximately 40 years to the students of Wilmington in grades 4 through 12. The mountain provides a great opportunity for skiers/riders, both beginner and experienced, to take lessons and learn throughout a 6 week group package program. The six week club will run in the months of January & February on Tuesday and Wednesday nights!2019 DatesWest, North & High School (Grades 4 & 5, 9-12)Tuesdays: January 8, 15, 22, 29; February 5, 12Middle School (Grades 6-8)Wednesdays: January 2, 9, 16, 23, 30; February 63 Steps For Enrolling Your Athlete In Ski Club!Pre-register by clicking HERE to get started.Continue to the forms page to fill out the 2019 registration form and mail to the WHS Athletic Office.Finally, click HERE to sign the Nashoba Valley Ski Area’s online Release of Liability.Learn more about the Wilmington Ski & Snowboard Club HERE. Learn more about the Nashoba Valley Ski Area HERE. Like Wilmington Apple on Facebook. Follow Wilmington Apple on Twitter. Follow Wilmington Apple on Instagram. Subscribe to Wilmington Apple’s daily email newsletter HERE. Got a comment, question, photo, press release, or news tip? Email wilmingtonapple@gmail.com.Share this:TwitterFacebookLike this:Like Loading… RelatedWilmington Ski & Snowboard Club 2016 Enrollment Now OpenIn “Education”Wilmington Ski & Snowboard Club Enrollment Now OpenIn “Sports”Wilmington Ski & Snowboard Club Enrollment Now OpenIn “Community”last_img read more

Liberia declared Ebolafree but WHO says the job is not done

first_imgClose Liberia was declared free of the Ebola virus by global health experts on 14 January, a milestone that signalled an end to an epidemic in West Africa that has killed more than 11,300 people. But the World Health Organization (WHO) warned there could still be flare-ups of the disease in the region, which has suffered the worlds deadliest outbreak over the past two years, as survivors can carry the virus for many months and could pass it on.Health specialists cautioned against complacency, saying the world was still underprepared for any future outbreaks of the disease.Today WHO declares the end of the most recent outbreak of Ebola virus disease in Liberia, the outbreak that was associated with the flare-up of cases in mid-November, said Rick Brennan, Emergency Risk Management and Humanitarian Response for WHO. Its also the first time that all three countries in West Africa, Guinea, Sierra Leone and Liberia, have stopped all known chains of transmission of the disease since the outbreak started in 2014.But the WHO official warned that: We have to say that the job is still not done. Thats because there is still ongoing risk of re-emergence of the disease, because of persistence of the virus in a proportion of survivors.Liberia was the last affected country to get the all-clear, with no cases of Ebola for 42 days, twice the length of the viruss incubation period – the time elapsed between transmission of the disease and the appearance of symptoms. The other affected countries, Guinea and Sierra Leone, were declared Ebola-free late in 2015.There were cases in seven other countries including Nigeria, the United States and Spain, but almost all the deaths were in the West African nations. It is the first time since the start of the EVD (Ebola Virus Disease) epidemic in West Africa almost two years ago that the three hardest-hit countries, Guinea, Liberia and Sierra Leone, are at zero cases for at least 42 days, said WHOs Liberia representative Alex Gasasira.last_img read more

Cumilla road crash kills two

first_img3 killed in a clashTwo people were killed and three others injured in a road accident at Kursap on Dhaka-Chattogram highway in Debidwar upazila of Cumilla on Tuesday morning, reports UNB.Inspector Monirul Islam, in-charge of Eliotganj highway police outpost, said a Cumilla-bound microbus was hit by a speeding vehicle from behind around 7:30am, leaving the two dead on the spot and three others injured.The injured were taken to Comilla Medical College Hospital, he said, adding the deceased could not be identified immediately.All the victims were travelling by the microbus.last_img read more

Kol to experience chill again Darjeeling sees sun snow

first_imgKolkata: Despite the temperature going up for the past few days, the Kolkata weather office informed that the city will experience the chill once again from Wednesday. Due to the Western disturbances, the cold air flow was obstructed which will resume again.According to the Alipore weather office, the sky will be clear from Wednesday and as a result the north-westerly will flow over the South Bengal districts. Temperature will go down and will hover around 15 degree Celsius for a few days, which is normal at this time of the year. Also Read – Speeding Jaguar crashes into Mercedes car in Kolkata, 2 pedestrians killedMeanwhile, Darjeeling town experienced rain, hail, sleet, light snow with intermittent sunshine on Tuesday. Not that anybody was complaining as locals and tourists alike went about enjoying all of this in a single day. At around 10:30 am with overcast skies there was a spell of sleet and very light snow. This was followed by hail and rain. Finally, it was sleet again till 2:30 pm followed by sunshine for a brief period. “I haven’t ever experienced such different weather conditions in a single day. It was magnificent. As soon as it started to snow we rushed to the Chowrasta. It was a lovely experience for us,” stated Rajesh Sharma, a tourist from Kanpur. Also Read – Bose & Gandhi: More similar than apart, says Sugata BoseThe day temperature hovered around 3.5 degree Celsius. Tourists and local residents thronged the Darjeeling Chowrasta with busy shutterbugs making the most of the weather. The upper reaches including Sadakphu, Phalut along with neighbouring Sikkim also witnessed snowfall. On December 28, 2018, it had snowed in Darjeeling town after a long gap of 10 years. “The snow in the upper reaches along with rain and hail in other parts was caused by western disturbances. There is a trough in the mid-tropospheric westerly at about 85 degree E 25 degree N. However, it is gradually shifting away,” stated Gopinath Raha, in-charge of the MeT office in Gangtok, Sikkim.last_img read more

Can VoIP Cut Your Mobile Costs

first_img This story appears in the March 2011 issue of . Subscribe » February 22, 2011 This hands-on workshop will give you the tools to authentically connect with an increasingly skeptical online audience. Free Workshop | August 28: Get Better Engagement and Build Trust With Customers Now 3 min read How to get started with mobile VoIPHow to get started with mobile VoIPAs an example, let’s use Skype on the iPhone:1. Download the Skype app from the iPhone store.2. Sign up for Skype service for free calling over 3G or Wi-Fi to other Skype users on a mobile device or connected PC.3. Buy Skype “credits” to call non-Skype users, paying just cents per minute (depending on where you’re calling).4. Use Skype seamlessly on the iPhone: Receive calls in the background like a regular phone call, and while on a Skype call do other tasks–like check your e-mail or your calendar–without hanging up.For businesses looking to save money on telecom costs, Voice over Internet Protocol (VoIP) technology has been a go-to method for some time. But can it help you cut your mobile bills as well? The answer isn’t as straightforward.For many tech watchers, the big story in mobile VoIP was AT&T and Apple’s concession last summer, after months of stalling, to allow popular VoIP service Skype on the iPhone. Why the delay? AT&T didn’t want VoIP dialing to cut into its voice-service revenues, and Apple–well, it seems Apple was just being its usual controlling self.Today, mobile users not only can use Skype apps on the iPhone, but also on Android, BlackBerry and Nokia devices. Skype even has a version of the app for Verizon users that sends the calls over its regular voice network. Skype isn’t alone in mobile VoIP, either. Rivals like Fring, Truphone, Nimbuzz and Vonage offer similar capabilities. Just download the app to your phone and go. Still toe-dipping in mobile VoIP is Google, which could change the voice game altogether when it finally takes the plunge.Is mobile VoIP free? It depends on how you look at it. Most carriers still require users to have a voice minutes plan. If that’s true in your case, go for the minimum. Then use your mobile VoIP app for free app-to-app calling. Your only cost for that is your data usage (technically free with an unlimited data plan; trickier if you pay by the byte). Want to call out to regular phone numbers? No big deal. Most mobile VoIP services charge a pittance for the capability. Fring, for instance, was recently charging 0.9 cents (yep, less than a penny) per minute; Skype offers unlimited calls in the U.S. and Canada starting at just $2.99 per month. If you can master the math and don’t mind dialing-by-app rather than hard key, the savings can add up quickly. Enroll Now for Freelast_img read more

Face recognition using siamese networks Tutorial

first_imgA siamese network is a special type of neural network and it is one of the simplest and most popularly used one-shot learning algorithms. One-shot learning is a technique where we learn from only one training example per class. So, a siamese network is predominantly used in applications where we don’t have many data points in each class. For instance, let’s say we want to build a face recognition model for our organization and about 500 people are working in our organization. If we want to build our face recognition model using a Convolutional Neural Network (CNN) from scratch, then we need many images of all of these 500 people for training the network and attaining good accuracy. But apparently, we will not have many images for all of these 500 people and so it is not feasible to build a model using a CNN or any deep learning algorithm unless we have sufficient data points. So, in these kinds of scenarios, we can resort to a sophisticated one-shot learning algorithm such as a siamese network, which can learn from fewer data points. Siamese networks basically consist of two symmetrical neural networks both sharing the same weights and architecture and both joined together at the end using some energy function, E. The objective of our siamese network is to learn whether two input values are similar or dissimilar. We will understand the siamese network by building a face recognition model. The objective of our network is to understand whether two faces are similar or dissimilar. We use the AT&T Database of Faces, which can be downloaded from the Cambridge University Computer Laboratory website. This article is an excerpt from a book written by Sudharsan Ravichandiran titled Hands-On Meta-Learning with Python. In this book, you will learn how to build relation networks and matching networks from scratch. Once you have downloaded and extracted the archive, you can see the folders s1, s2, up to s40, as shown here: Each of these folders has 10 different images of a single person taken from various angles. For instance, let’s open folder s1. As you can see, there are 10 different images of a single person: We open and check folder s13: Siamese networks require input values as a pair along with the label, so we have to create our data in such a way. So, we will take two images randomly from the same folder and mark them as a genuine pair and we will take single images from two different folders and mark them as an imposite pair. A sample is shown in the following screenshot; as you can see, a genuine pair has images of the same person and the imposite pair has images of different people: Once we have our data as pairs along with their labels, we train our siamese network. From the image pair, we feed one image to network A and another image to network B. The role of these two networks is only to extract the feature vectors. So, we use two convolution layers with rectified linear unit (ReLU) activations for extracting the features. Once we have learned the features, we feed the resultant feature vector from both of the networks to the energy function, which measures the similarity; we use Euclidean distance as our energy function. So, we train our network by feeding the image pair to learn the semantic similarity between them. Now, we will see this step by step. For better understanding, you can check the complete code, which is available as a Jupyter Notebook with an explanation from GitHub. First, we will import the required libraries: import reimport numpy as npfrom PIL import Imagefrom sklearn.model_selection import train_test_splitfrom keras import backend as Kfrom keras.layers import Activationfrom keras.layers import Input, Lambda, Dense, Dropout, Convolution2D, MaxPooling2D, Flattenfrom keras.models import Sequential, Modelfrom keras.optimizers import RMSprop Now, we define a function for reading our input image. The read_image function takes as input an image and returns a NumPy array: def read_image(filename, byteorder=’>’): img1 = read_image(‘data/orl_faces/s’ + str(ind1+1) + ‘/’ + str(j + 1) + ‘.pgm’, ‘rw+’) img2 = read_image(‘data/orl_faces/s’ + str(ind2+1) + ‘/’ + str(j + 1) + ‘.pgm’, ‘rw+’) img1 = img1[::size, ::size] img2 = img2[::size, ::size] x_imposite_pair[count, 0, 0, :, :] = img1 x_imposite_pair[count, 1, 0, :, :] = img2 #as we are drawing images from the different directory we assign label as 0. (imposite pair) y_imposite[count] = 0 count += 1 nb_filter = [6, 12] kernel_size = 3 #convolutional layer 2 seq.add(Convolution2D(nb_filter[1], kernel_size, kernel_size, border_mode=’valid’, dim_ordering=’th’)) seq.add(Activation(‘relu’)) seq.add(MaxPooling2D(pool_size=(2, 2), dim_ordering=’th’)) seq.add(Dropout(.25)) #flatten seq.add(Flatten()) seq.add(Dense(128, activation=’relu’)) seq.add(Dropout(0.1)) seq.add(Dense(50, activation=’relu’)) return seq Next, we feed the image pair to the base network, which will return the embeddings, that is, feature vectors: input_dim = x_train.shape[2:]img_a = Input(shape=input_dim)img_b = Input(shape=input_dim)base_network = build_base_network(input_dim)feat_vecs_a = base_network(img_a)feat_vecs_b = base_network(img_b) feat_vecs_a and feat_vecs_b are the feature vectors of our image pair. Next, we feed these feature vectors to the energy function to compute the distance between them, and we use Euclidean distance as our energy function: def euclidean_distance(vects): x, y = vects return K.sqrt(K.sum(K.square(x – y), axis=1, keepdims=True)) def get_data(size, total_sample_size): #read the image image = read_image(‘data/orl_faces/s’ + str(1) + ‘/’ + str(1) + ‘.pgm’, ‘rw+’) #reduce the size image = image[::size, ::size] #get the new size dim1 = image.shape[0] dim2 = image.shape[1] count = 0 seq = Sequential() #convolutional layer 1 seq.add(Convolution2D(nb_filter[0], kernel_size, kernel_size, input_shape=input_shape, border_mode=’valid’, dim_ordering=’th’)) seq.add(Activation(‘relu’)) seq.add(MaxPooling2D(pool_size=(2, 2))) seq.add(Dropout(.25)) #now, concatenate, genuine pairs and imposite pair to get the whole data X = np.concatenate([x_geuine_pair, x_imposite_pair], axis=0)/255 Y = np.concatenate([y_genuine, y_imposite], axis=0) return X, Y Now, we generate our data and check our data size. As you can see, we have 20,000 data points and, out of these, 10,000 are genuine pairs and 10,000 are imposite pairs: X, Y = get_data(size, total_sample_size)X.shape(20000, 2, 1, 56, 46)Y.shape(20000, 1) Next, we split our data for training and testing with 75% training and 25% testing proportions: x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=.25) Now that we have successfully generated our data, we build our siamese network. First, we define the base network, which is basically a convolutional network used for feature extraction. We build two convolutional layers with ReLU activations and max pooling followed by a flat layer: def build_base_network(input_shape): # read the two images img1 = read_image(‘data/orl_faces/s’ + str(i+1) + ‘/’ + str(ind1 + 1) + ‘.pgm’, ‘rw+’) img2 = read_image(‘data/orl_faces/s’ + str(i+1) + ‘/’ + str(ind2 + 1) + ‘.pgm’, ‘rw+’) #then we convert the image to numpy array using np.frombuffer which interprets buffer as one dimensional array return np.frombuffer(buffer, dtype=’u1′ if int(maxval) For an example, let’s open one image: Image.open(“data/orl_faces/s1/1.pgm”) When we feed this image to our read_image function, it will return as a NumPy array: img = read_image(‘data/orl_faces/s1/1.pgm’)img.shape(112, 92) Now, we define another function, get_data, for generating our data. As we know, for the siamese network, data should be in the form of pairs (genuine and imposite) with a binary label. First, we read the (img1, img2) images from the same directory and store them in the x_genuine_pair array and assign y_genuine to 1. Next, we read the (img1, img2) images from the different directory and store them in the x_imposite pair and assign y_imposite to 0. Finally, we concatenate both x_genuine_pair and x_imposite to X and y_genuine and y_imposite to Y: size = 2total_sample_size = 10000 #read images from different directory (imposite pair) while True: ind1 = np.random.randint(40) ind2 = np.random.randint(40) if ind1 != ind2: break #as we are drawing images from the same directory we assign label as 1. (genuine pair) y_genuine[count] = 1 count += 1 count = 0 x_imposite_pair = np.zeros([total_sample_size, 2, 1, dim1, dim2]) y_imposite = np.zeros([total_sample_size, 1]) #read images from same directory (genuine pair) while ind1 == ind2: ind1 = np.random.randint(10) ind2 = np.random.randint(10) #reduce the size img1 = img1[::size, ::size] img2 = img2[::size, ::size] #first we read the image, as a raw file to the buffer with open(filename, ‘rb’) as f: buffer = f.read() #initialize the numpy array with the shape of [total_sample, no_of_pairs, dim1, dim2] x_geuine_pair = np.zeros([total_sample_size, 2, 1, dim1, dim2]) # 2 is for pairs y_genuine = np.zeros([total_sample_size, 1]) #store the images to the initialized numpy array x_geuine_pair[count, 0, 0, :, :] = img1 x_geuine_pair[count, 1, 0, :, :] = img2 for i in range(int(total_sample_size/10)): for j in range(10): for i in range(40): for j in range(int(total_sample_size/40)): ind1 = 0 ind2 = 0 #using regex, we extract the header, width, height and maxval of the image header, width, height, maxval = re.search( b”(^P5\s(?:\s*#.*[\r\n])*” b”(\d+)\s(?:\s*#.*[\r\n])*” b”(\d+)\s(?:\s*#.*[\r\n])*” b”(\d+)\s(?:\s*#.*[\r\n]\s)*)”, buffer).groups() def eucl_dist_output_shape(shapes): shape1, shape2 = shapes return (shape1[0], 1)distance = Lambda(euclidean_distance, output_shape=eucl_dist_output_shape)([feat_vecs_a, feat_vecs_b]) Now, we set the epoch length to 13, and we use the RMS prop for optimization and define our model: epochs = 13rms = RMSprop()model = Model(input=[input_a, input_b], output=distance) Next, we define our loss function as the contrastive_loss function and compile the model: def contrastive_loss(y_true, y_pred): margin = 1 return K.mean(y_true * K.square(y_pred) + (1 – y_true) * K.square(K.maximum(margin – y_pred, 0)))model.compile(loss=contrastive_loss, optimizer=rms) Now, we train our model: img_1 = x_train[:, 0]img_2 = x_train[:, 1] model.fit([img_1, img_2], y_train, validation_split=.25, batch_size=128, verbose=2, nb_epoch=epochs) You can see how the loss decreases over epochs: Train on 11250 samples, validate on 3750 samplesEpoch 1/13 – 60s – loss: 0.2179 – val_loss: 0.2156Epoch 2/13 – 53s – loss: 0.1520 – val_loss: 0.2102Epoch 3/13 – 53s – loss: 0.1190 – val_loss: 0.1545Epoch 4/13 – 55s – loss: 0.0959 – val_loss: 0.1705Epoch 5/13 – 52s – loss: 0.0801 – val_loss: 0.1181Epoch 6/13 – 52s – loss: 0.0684 – val_loss: 0.0821Epoch 7/13 – 52s – loss: 0.0591 – val_loss: 0.0762Epoch 8/13 – 52s – loss: 0.0526 – val_loss: 0.0655Epoch 9/13 – 52s – loss: 0.0475 – val_loss: 0.0662Epoch 10/13 – 52s – loss: 0.0444 – val_loss: 0.0469Epoch 11/13 – 52s – loss: 0.0408 – val_loss: 0.0478Epoch 12/13 – 52s – loss: 0.0381 – val_loss: 0.0498Epoch 13/13 – 54s – loss: 0.0356 – val_loss: 0.0363 Now, we make predictions with test data: pred = model.predict([x_test[:, 0], x_test[:, 1]]) Next, we define a function for computing accuracy: def compute_accuracy(predictions, labels): return labels[predictions.ravel() Now, we compute the accuracy of model: compute_accuracy(pred, y_test)0.9779092702169625 In this tutorial, we have learned to build face recognition models using siamese networks. The architecture of siamese networks, basically consists of two identical neural networks both having the same weights and architecture and the output of these networks is plugged into some energy function to understand the similarity. To learn more about meta-learning with Python, check out the book Hands-On Meta-Learning with Python. Read next What is Meta-Learning? Introducing Open AI’s Reptile: The latest scalable meta-learning Algorithm on the block “Deep meta reinforcement learning will be the future of AI where we will be so close to achieving artificial general intelligence (AGI)”, Sudharsan Ravichandiranlast_img read more