# Exploring Aesthetics Through Surprise Gained from Diffusion
CSC2529F: Computational Imaging Final Project

Joshua (Hyun Jo) Jang | hyunjo.jang **at** mail.utoronto **dot** ca

## Code
We have tested proper functionality of the code on Python 3.10.19, macOS 26.1 ARM64 and Windows 11 x86_64.

Please download all files in this repository (especially `test.jpg` and the two `ava_10k_....txt` files) before running any notebooks.

Also, please install all dependencies in requirements.txt (using something like `pip install -r requirements.txt`). Note that Jupyter-related packages are NOT included, please install accordingly.

Our entire project is composed of 3 main steps: Diffusion noise-denoise, original-reconstruction comparison, and results evaluation.

We provide the following scripts and notebooks for each step. Each step can be run independently, as all files required for them are pre-generated:
- Diffusion noise-denoise
    - **denoise.ipynb:** notebook illustrating how we add noise to an input image, and use SD v1-5 to generate a reconstruction. Completely executable out-of-the-box, with around ~2 minutes required for a full run on an Apple M1 Pro GPU. Please use this to confirm the core logic implementation. Outputs are already saved in the file.
    - **batch_denoise.py:** script that adds batch processing and file I/O functionality to the core logic from the notebook, for fast processing of multiple images. Running this script requires downloading the 34GB AVA dataset; please only consider this as a reference.
- Original-reconstruction comparison (surprise score measurement)
    - **comparison.ipynb:** notebook showing how we perform comparisons between an original image and its reconstruction(s), across noise levels, spatial scales, and difference metrics. Again, executable out-of-the-box, and outputs are already saved. Please use this to confirm the core logic implementation.
    - **batch_comparison.py:** script that adds batch comparison functionality across 10K images from the AVA dataset and outputs a results txt. Running this script requires downloading the 34GB AVA dataset; please only consider this as a reference.
- Evaluation
    - **evaluate.ipynb:** notebook that evaluates how each comparison result (surprise score) correlates with human-evaluated aesthetic scores. Quantitative result plots for the paper are generated here.

DISCLAIMER: For the batch processing scripts: batch_denoise.py and batch_comparison.py, ChatGPT-5 was used to implement txt file I/O and driver code.

Additionally **evaluate.ipynb** uses these txt files:
- **ava_10k_index_id_mean.txt:** data file containing the unique image id and mean human-evaluated aesthetic score for each of the 10K randomly sampled images from the AVA dataset.
- **ava_10k_surprise_scores.txt:** data file containing the results of comparing original-reconstruction image pairs in `batch_comparison.py`. A single image from the 10K samples produce 27 (3 noise levels, 3 spatial scales, 3 difference metrics) surprise scores.