Community Engagement

Ruby, Red Pandas, and You

Ruby, Red Pandas, and You

by Sean Marcia

In the talk "Ruby, Red Pandas, and You" presented at RubyConf 2016, Sean Marcia discusses the plight of red pandas and how technology, specifically Ruby and machine learning, can aid in their conservation. The presentation delves into the following key points:

  • Introduction to Red Pandas: Marcia describes red pandas as adorable yet endangered creatures, highlighting their unique classification as carnivores despite a bamboo-heavy diet and their declining population due to poaching and habitat loss.
  • Research on Red Pandas: He introduces Elizabeth Freeman from George Mason University, who studies red panda nesting behaviors. The challenges of monitoring these animals in captivity and the high mortality rate of cubs born there are emphasized.
  • Use of Technology: The talk details Marcia's previous experience monitoring beehives and how it led him to apply similar techniques to red panda research. By implementing machine learning and neural networks, he addresses the inefficiencies of manual video analysis—where researchers watch extensive footage to record panda activities.
  • Machine Learning Application: Marcia outlines his process of converting video footage into still images for easier analysis using TensorFlow. He trained a classifier to detect red pandas, ultimately improving efficiency and allowing researchers to focus on more critical aspects of panda care and conservation.
  • Community Engagement: Highlighting Ruby for Good, Marcia emphasizes the importance of community involvement in such projects, encouraging attendees to contribute to meaningful efforts that make a difference.
  • Concluding Thoughts: He stresses the value of kindness and collaboration in programming and motivates the audience to engage in conservation projects, reminding them that every small effort counts.

Marcia's session not only informs about the challenges faced by red pandas but also offers an inspiring example of using programming skills for wildlife conservation, illustrating how technology can play a significant role in addressing environmental challenges.

00:00:15.090 Awesome! Hey, so I just added a slide here because I was talking to someone maybe about an hour ago, and they hadn’t heard of Matz. I think it’s a little sad about what happened on Tuesday, and so I think talking about Matz briefly will be cathartic. So what Matz is, if you’re not familiar, is kind of like a rendering of Matz’s sentiment. Matz said he created the Ruby language to make developers happy, and this turned into this happy feeling in our community.
00:00:30.000 Back in the early days on the email lists, before it formed into something more structured, if someone was getting out of line, people would say, 'Hey, hey, Matz is nice, and so we are nice!' It feels like one of the best tenets of our community. In my local Ruby group, we made these Matz-on stickers, so if you want one, come up after; I’d love to give you one. But today, I’m going to be talking about Ruby, red pandas, and you.
00:00:52.780 I misjudged how long we’d be here, and I really like this community. I’m Sean, by the way. I love this Ruby community, and I love RubyConf; it’s probably my favorite conference. It’s hard to believe it’s been a year since San Antonio; it feels like it just happened. This has me reflecting on what’s happened in the past year since last November at RubyConf, and obviously, the thing that jumps to my mind is that we had an election. We have a new leader, someone who represents the best about us and what our country can be like. Personally, I’m very proud we elected Justin Trudeau in Canada.
00:01:27.009 A lot of people ask me about this picture. Being from Saskatchewan, Canada, the reason I am so happy in this picture is that it's my life goal to capture a sasquatch. I thought I had captured the rarest of all sasquatches: the albino sasquatch. But it turns out it was just a Yeti. So, about me: I’m Sean. I’m the organizer of Ruby for Good. I love dogs, am figuratively Canadian, work for the government, and I’m not a big fan of public speaking. But my wife gave me some good advice; she said, 'Sean, don’t worry. You’re going to be fine. Just go up there and be your regular charming and handsome self,' and I’m thinking the same thing.
00:02:06.020 So, today I’m going to talk about red pandas. A lot of people know me as the bee person, but let me talk about how I solved this red panda problem. I hope to inspire some of you to get involved in something similar. If you’re familiar with the bee situation, I was helping a professor studying Colony Collapse Disorder to monitor beehives using Ruby and Raspberry PIs. He was hoping to get information on a beehive before it collapsed. Unfortunately, none of the beehives we were monitoring collapsed.
00:02:45.370 What seems good for the bees is to monitor every beehive in the world, and then none will collapse! But he’s from Colombia, and maybe it didn’t translate right. But the bees are in trouble; eight species just moved to the endangered species list, and all this bee stuff seems like a failure. But I think there’s some good that happened. I want to introduce you all to Taylor; when I met her, she was in the ninth grade. I took her for a tour around George Mason University, and she got inspired.
00:03:02.490 She went back to her high school and, with the help of her parents, got a beehive. Now, she has nine beehives and is leading clubs. She just got a $2,500 grant to further her research. I know this because Taylor’s mom contacted me and told me all of this. She’s applying to colleges and writing about her experiences. This wasn’t just about bees; I believe that Taylor is someone who might help solve this problem for the future, which is very optimistic.
00:03:39.400 But I know everyone here is waiting to see cute little pictures of red pandas, so let's talk about red pandas. We’ve all seen pictures, but my first introduction to them was really through an article I read in The New York Times, which discussed the research on them. As it happened, the researcher from that article works at George Mason University, where I work. I went and found her; her name is Elizabeth Freeman. I asked her how I could help with her research.
00:04:07.520 All I could think was that I wanted to see a red panda. So, we spoke, and she told me a lot of really neat things about red pandas. I'm going to share a few now. The most important thing you should know about red pandas is that they are adorable. Red pandas were actually discovered 50 years before giant pandas, and they’re distantly related to raccoons and weasels, not to bears. They broke off onto their own branch approximately 29 million years ago.
00:04:54.600 Interestingly, they are classified as carnivores. Despite their primary diet being bamboo, they have evolved to eat bamboo but retain their carnivorous classification. They primarily live in the Himalayas region, including parts of China, Szechuan, Yunnan, and Bhutan. There are two subspecies of red pandas. They inhabit very specific areas, living at altitudes of about 2,000 to 5,000 meters.
00:05:28.890 Red pandas primarily eat bamboo, but they will eat small animals, birds, and insects when they can. They are incredibly cute and have a really slow metabolism. They have a single-pouch stomach, a short colon, and are slow to mature sexually, taking about twice as long as other animals. Their gestation periods range from 90 to 160 days, and they typically have very small litters of cubs. Unfortunately, they’re listed as endangered, and their population is in decline.
00:06:05.660 Approximately 50% of the population has declined in the last three generations. The total global population is less than 10,000, with estimates in captivity ranging between 18 and 900. Humans are a significant factor in their decline, caused by poaching and habitat destruction, especially in extreme areas where their habitats are being cut down either for space or for hunting.
00:06:40.150 For example, in Yunnan Province, China, there is a cultural practice of giving wedding gifts that include red panda fur. Moreover, over half of the cubs born in captivity die within their first year. Approximately 20% die without any clear reason; the rest may fall victim to poor maternal care, internal cannibalism, pneumonia, or other factors. This highlights the urgent need for research to understand these challenges.
00:07:35.060 I want to highlight Elizabeth’s work; researchers study nesting behaviors using cameras placed in nest boxes, which are designed to mimic where red pandas would live in the wild. They observe how mothers interact with their cubs and what happens after a cub is born. They are also investigating how female cubs learn from their mothers' behaviors.
00:08:23.960 They monitor how mothers and cubs interact. It’s very cute but crucial for their survival. They also study a particular parasite that affects red pandas, working to determine how this parasite enters captive panda populations. They are interested in the vector of this infection to potentially counteract it. This is an important aspect of the research.
00:08:53.070 The research using these cameras has provided significant insights. For example, they have obtained hours of video, but the problem is that for every 12 hours, there's about 3 hours of actual panda footage. Therefore, each human currently watches through 12 hours of footage just to mark down panda activity, which is time-consuming and inefficient.
00:09:58.490 As a software engineer, I was determined to solve this issue efficiently with machine learning. I had to approach this problem methodically, breaking down the enormous task into smaller parts. First, I needed to upload the files onto a server, which I accomplished using the PaperClip gem and the jQuery file upload as they are both user-friendly and effective.
00:11:02.460 The challenge of uploading videos of large sizes was overcome thanks to resuming capabilities of the jQuery gem, which was crucial for users accessing the data remotely. However, I encountered an error with the file upload size limits, which was due to the default Engine X configuration. I resolved this and moved on to identifying pandas on the recordings.
00:11:44.410 I began researching machine learning and neural networks. My friend Josh suggested using a neural network for object detection. At first, I was unsure, so I did more research and discovered that analyzing images instead of video is far simpler. I converted the video streams into images since videos are just sequences of still frames.
00:12:41.130 With the ffmpeg tool, I could easily extract still images from the video. Knowing that I only needed about one image per second made the process manageable. After obtaining the images, my next step was to identify them using a neural network library called TensorFlow, which I found particularly easy to use due to existing examples.
00:13:10.620 Using existing examples with cats and dogs meant I could rapidly adapt the classifier for identifying red pandas. I created a library of images containing both pandas and empty frames, which is important for training the classifier. There was a minor setback: one of the researchers had used colored footage, which meant I had to adjust the classifier for accuracy.
00:14:06.290 However, thanks to TensorFlow, I could easily rebuild my classification library by adding a couple more images. Essentially, when I ran an image through the trained model, it would give a probability score indicating whether the image contained a red panda. If the confidence level was above 60%, I would mark it. Still, I had to keep an eye out for false positives and negatives.
00:15:04.320 I established a simple rule: I wouldn’t mark it as a confirmed 'yes' or a 'no' unless I got three consistent outputs in a row. This method provided a higher level of accuracy. As I compared the machine's results to those from human classifications, I discovered that, in some cases, the machine had outperformed humans, which was an exciting and validating experience.
00:16:04.210 Not only did this project provide a more cost-effective solution, but it also freed up researchers' time for more valuable activities to assist red pandas in their habitats and in captivity. I hope this project interests all of you, and if it does, I encourage you to get involved with Ruby for Good.
00:16:50.190 Ruby for Good's logo symbolizes a world filled with love, embracing ruby language enthusiasts. I want to emphasize that this isn’t just about coding; it's a community event. We come together for a weekend to create workable solutions for nonprofits that usually can’t afford our help. It differs from traditional hackathons; it focuses on creating an inclusive environment while delivering functionality.
00:17:42.930 It’s an event focused on learning, where individuals of all experience levels—from beginner to advanced—can work together, growing and sharing knowledge. Importantly, there's a strong focus on community. I believe it’s more critical now than ever as we navigate our experiences in our country and face challenges.
00:18:12.300 In past years, we’ve supported incredible organizations, including the Humane Society, where we've spent time with adorable animals while contributing our skills. Additionally, at Ruby for Good, the community is genuine; we make lasting connections and collaborate on projects that make a difference. I recall unforgettable moments at the event, including karaoke where people found jobs just through networking spontaneously.
00:19:10.820 At Ruby for Good, relationships flourish, and we foster friendships among attendees, which has led many to return each year, wanting to expand on what they learned. Notably, we've welcomed people who go on to do amazing work, including helping local causes, and that alone showcases the event's impact.
00:20:11.750 I want to encourage you to get involved in these types of projects and emphasize kindness in our community. A remarkable aspect of the programming world is how we come together to support one another, which is precisely what we need in today's uncertain times. As I conclude, I want everyone to remember that not everyone can save the world, but just saving one person—especially yourself—counts.
00:21:02.270 Lastly, here’s a fun photo of a red panda fighting with a pumpkin; spoiler alert—the battle ends in a draw. Remember, it’s okay to laugh and find joy even when things feel tough. Thank you for listening, and I welcome any questions!