Inspiration
Hailing from Florida, Georgia, and Texas, we have recently become aware of the poor fairness quality of redistricting in our home states (https://gerrymander.princeton.edu/redistricting-report-card/). While lots of people know gerrymandering is an issue, few are aware of what a gerrymandered district actually looks like, or have the tools to hold their representatives accountable for dubiously drawn boundaries in a streamlined and accessible way. That's where gerr.ai comes in!
What it does
gerr.ai enables the average person to be able to see gerrymandering with unprecedented ease. A slick UI allows the user to draw out the shape of a congressional district, potentially tracing on an existing map by uploading it beforehand. Then, computer vision algorithms are used to fill their boundaries, creating a "district" and calculating a variety of geometric "compactness scores" that -- according to the literature -- provide valuable information on the fairness of a redistricting. Passing both the processed image and the compactness scores into a state-of-the-art GPT large language model, we reveal an in-depth natural language analysis of the district's merits and dangers, with an emphasis on instruction for the layperson. gerr.ai puts the power in your hands to understand the shortcomings of the legal system, and for that reason it is an essential and powerful tool!
How we built it
To build gerr.ai, we tapped into our members' unique skillsets. Lailah and Hang's frontend experience allowed them to create a clear and usable UI in React Typescript, with an emphasis on readability. Semantic UI was useful for creating the sketch widget, loading icon, and other unique features. Meanwhile, Esteban's backend experience made it easy to create a simultaneous Flask server with endpoints connecting the upload of the image to the output of the text response. Finally, Dylan's machine learning background was essential to processing the raw data of the sketch into a filled district and identifying its contours using OpenCV. The processed image was then fed into a variety of compactness score functions using more OpenCV methods, and all the data was amalgamated into a single prompt used for the OpenAI GPT-3.5 Turbo Completion endpoint. By combining slick frontend, effective backend, and clever machine learning techniques, we built a multifaceted app with the potential to provide valuable political information to the general public.
Challenges we ran into
While building gerr.ai, we ran into several challenges on the various levels of the project. We are pretty new to React styling, so getting the colors and sizes on the frontend to look right was difficult and required a lot of iteration. Plus, the backend produced several bugs related to the transfer of image data between the two servers, which none of us had experience with -- we ultimately found out how to use Blobs and made the system work. Lastly, the machine learning to analyze images offered challenges unique to this project. The sketch widget has a transparent background, so modifying it for use with OpenCV was difficult, and so was understanding and implementing all the various compactness scores that are used in the literature.
Accomplishments that we're proud of
We're very proud of completing our initial goal of an app that converts district sketches to valuable and actionable data about the likelihood of gerrymandering -- we believe this is a novel idea that could help a lot of people! On a more specific level, we are proud of combining many technologies we hadn't used before and an interesting and creative way. We hadn't used OpenCV this extensively before, nor had we built this complex a React app, so it was awesome to see it all come together over the course of one long and very hectic night! And in the process, we learned a lot about the fascinating mathematical problem of identifying and combating gerrymandering, which we are proud of -- and excited to learn more in the future.
What we learned
As mentioned above, this project was a great chance to learn about the fascinating problems of redistricting analysis. It also gave us a chance to learn more about the OpenCV API that fuels a lot of computer vision projects, and understand how to combine disparate elements into a larger project. We're very grateful to DevFest for providing us this unique opportunity to work on an app we're passionate about with the full resources and support of Columbia ADI!
What's next for Gerr.ai
gerr.ai is awesome, but it's far from done. Our ultimate goal is to have not just compactness scores fueling the LLM response, but also an actual machine learning classifier outputting the likelihood of the district being gerrymandered. We started work on this model, but unfortunately it was too difficult to train due to limited hacking time and limited access to district shapefiles with "gerrymandering" labels (since it's not exactly a numerical value). The next step would be finding a way to operationalize this model, then training it and integrating it with the rest of the backend. We also hope to provide more avenues for the user to input data besides a geometric sketch. For instance, it would be awesome if users could use the background map upload as a data source for population sizes and demographics, an important alternate factor in redistricting analysis. It would of course be challenging to map an image of a map with real-world census data, but with enough time, we think it could be doable.
Log in or sign up for Devpost to join the conversation.