Analyzing Classroom Images Locally with R and LLMs
We are almost done with our new book Computational Social Science Cookbook, a collaborative open-access book aimed at education researchers working with, or looking to expand their research toolkits with, computational methods. Among many other things, I led the chapter on using local (or cloud) LLMs to conduct methodological image analyses. The chapter covers something I think is underused in the field: analyzing classroom images with vision-language models in R.
The chapter is practical and self-contained, like the rest of the book, which lets researchers follow the steps and repeat the analysis on their own datasets. If you have R and Ollama installed, you can follow along and run the code. The method is worth a brief argument, because most researchers who haven’t tried image analysis skip it for lack of awareness of how easy it can be and how rich the results can be. This point sits at the heart of the book: “things” beyond what we traditionally consider can be data, and these open new research questions. The barriers are mostly technical, and privacy is the largest concern, one that local models now largely solve.
Images are hard to analyze at scale, and that difficulty has kept them out of most research designs. Manual coding is slow, expensive, and hard to replicate. School photos in educational contexts contain students specifically, and sending them to a commercial API raises real privacy and IRB concerns that most researchers are unwilling to navigate.
This method has direct research applications. A researcher can record classroom interactions and use the resulting visuals to answer questions about instructional format, spatial arrangement, and student engagement, the example used in the book. The example focuses on student engagement, but the method extends to any research question that visual data can answer. For the chapter’s worked example, we used classroom photos pulled from Wikimedia Commons. I ran the workflow across three questions: instructional format, group composition, and student engagement. The results were accurate and easy to verify, and the workflow processed the images far faster than manual coding would allow. The model has limits, and careful qualitative analysis remains necessary alongside it. The workflow is a useful starting point, and a way to get more out of visual data than researchers have in the past. The book also has a full section on using LLMs for qualitative data analysis directly, with a responsible use framework built around correctness, transparency, and reproducibility. More on that here.
This analysis was possible through the {kuzco} package, which wraps Ollama’s local model inference and exposes four functions: classification, object recognition, sentiment estimation, and a free-form custom prompt. About a dozen lines of code takes a folder of classroom photos to structured, analyzable output, credit to Frank Hull, the package’s author, for making this so accessible.
Visual data has been treated as supplementary in educational research mostly because analyzing it at scale was impractical. Local vision-language models now make it practical. For researchers working with classroom images, observational photos, or any kind of visual data, education or not, the chapter is a working starting point in R. The book is open access, so you can read it online for free, and the code is all available on GitHub. I hope this encourages more researchers to consider visual data in their work, and to use local LLMs to analyze it in a way that is ethical, practical, and insightful.
Wang, W., Akcaoglu, M., Rosenberg, J., & Kellogg, S. (2026). Computational Analysis of Educational Data: A Field Guide Using R.