Skip to content

Commit 62d8dec

Browse files
committed
Add Files Relating to Color Convexity Paper
- Includes program files needed to run the experiments - Includes documentation which explains how to run the experiments - TODO: Finish up the documentation once issues have been addressed - Includes minimized `.csv` files for easy data processing - Does not include larger model files nor data which is used from other projects - Documentation does include details on how to get all of this data
1 parent d1d807d commit 62d8dec

39 files changed

Lines changed: 267329 additions & 0 deletions

src/examples/colors/README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
## Colors
2+
3+
Based on the paper [TODO]
4+
5+
## Setup
6+
After setting up the `eff_conv` environment, install the proper prerequisites:
7+
```sh
8+
python -m pip install pandas==2.3.0
9+
python -m pip install open3d==0.19.0
10+
python -m pip install matplotlib==3.10.3
11+
python -m pip install scikit-image==0.25.2
12+
python -m pip install statsmodels==0.14.4
13+
```
14+
15+
## How To Run
16+
17+
### Installing The Data
18+
19+
Please install the `model.pkl` following the direction from [here](https://github.com/nogazs/ib-color-naming/tree/master). Place the `model.pkl` file in the `data` folder
20+
21+
Please additionally install the `WCS-Data-20110316.zip` file from the World Color Survey data from [here](https://linguistics.berkeley.edu/wcs/data.html). Make sure the unzipped folder is in `data`. Make sure to also install the mappings (`cnum-vhcm-lab-new.txt`) and place them in the `data` folder as well.
22+
23+
### Creating the WCS and CIELab visualizations
24+
25+
TODO: The stimulus grid needs to be updated
26+
27+
In the `examples` directory, run the following commands to get CIELab visualization (Figure 2 in the paper):
28+
```sh
29+
python -m colors.visualization.cloud color_reg
30+
python -m colors.visualization.cloud color_rot 20
31+
python -m colors.visualization.cloud color_diff 20 diff
32+
```
33+
34+
This will create the files `color_reg.png`, `color_rot.png`, and `color_diff.png` in the `output/color` folder.
35+
36+
37+
### Minimizing Data
38+
39+
The raw model files for each experiement are very large (ranging from 250 MB for artifical models to over 14 GB for the color model). In order to distribute the data and for ease of iteration, we provide minimized `.csv` files containing the relevant data in the GitHub repository. We also include the raw model files we generated [here](https://osf.io/x3dkz/).
40+
41+
If you wish to run this experiment with your own data, after doing the data generation for experiment 1 and 2 you will need to generate the `.csv` files using the following command:
42+
43+
```sh
44+
python -m colors.utils.minimize_models
45+
```
46+
47+
### Experiment 1
48+
49+
#### Data Generation
50+
51+
To generate the color model run the following command in the `examples` directory:
52+
```sh
53+
python -m colors.exp1.generate_color_model
54+
```
55+
56+
#### Data Analysis
57+
58+
Please ensure you have the minimized `.csv` files before doing analysis.
59+
60+
You can generate the plots and correlations using the respective commands:
61+
```sh
62+
# Plots
63+
python -m colors.exp1.generate_color_plot
64+
python -m colors.exp1.gen_whisker_plots
65+
# Correlations
66+
python -m colors.exp1.generate_color_correlation
67+
python -m colors.utils.ols_model color_model
68+
```
69+
70+
TODO: ADD OTHER CORRELATION MODEL AND OTHER ANALYSIS
71+
72+
### Experiments 2 & 3
73+
74+
#### Data Generation
75+
76+
To generate the test models for experiments 2 and 3, you can run the followign command in the `examples` directory:
77+
```sh
78+
python -m colors.exp2_3.generate_models
79+
```
80+
81+
### Data Analysis
82+
83+
Please ensure you have the minimized `.csv` files before doing analysis.
84+
85+
After this you can generate the plots and correlations using the respective commands:
86+
```sh
87+
python -m colors.exp2_3.generate_plots
88+
python -m colors.exp2_3.calculate_correlation
89+
```
90+
91+
TODO: ADD OTHER CORRELATION MODEL AND OTHER ANALYSIS
92+
93+
## Additional Documentation
94+
- `exp1.check_diff`
95+
- Experimental: Used to get the data regarding the differences with nearby neighbors
96+
- `exp1.gen_whisker_plots`
97+
- The script to generate the whisker plots in the paper. The output will be in `output/convexity/whisker.png`
98+
- `exp1.generate_color_correlation`
99+
- The script to generate the color correlation file and table. The correlation file will be in `output/convexity/color_coefficients.csv`
100+
- `exp1.generate_color_model`
101+
- The script to generate the color model. The model file will be in `data/convexity/color_model.pkl`. This script will take a few days to run.
102+
- `exp1.generate_color_plot`
103+
- The script to generate the color plot. The model file will be in `output/output/color.png`.
104+
- `exp2_3.models.*`
105+
- The scaffolding for the various artifical models showcased in the paper.
106+
- `exp2_3.calculate_correlation`
107+
- The script to generate the convexity correlation files and tables. The correlation files will be in `output/convexity/qmw_coefficients.csv` and `output/convexity/quw_coefficients.csv`
108+
- `exp2_3.generate_models`
109+
- The script to generate the artificial model files. The model files will be in `data/convexity/model-*.pkl`
110+
- `exp2_3.generate_plots`
111+
- The script to generate the artificial model plots. The plots will be in `output/convexity/tile_qmw.png` and `output/convexity/tile_quw.png`
112+
- `utils.correlation`
113+
- This contains a function to convert the correlation tables into a formatted LaTeX table
114+
- `utils.migrate`
115+
- This was a script to fix discrepencies between an old format of models and a more organized format
116+
- `utils.minimize_models`
117+
- This minimizes the models in the `data/convexity/` folder into `.csv` files and outputs them in `data/minimized/`
118+
- `utils.ols_model`
119+
- Takes in an argument, that being the name of a minimized `.csv` file without the extension. Creates an OLS model for the given model.
120+
- `visualization.cloud`
121+
- Takes in 1 - 3 arguemnts, the first being the name of the output file and the second (optional) being a rotation value, the final can argument is `diff` and toggles whether or not to show difference point cloud or the regular point cloud.
122+
- `utils.gen_wcs_grid`
123+
- Generates a very simplistic WCS stimulus grid. To change the rotation a constant must be manually edited in the file.
124+
125+
## Notes
126+
127+
If you found this useful please cite the following paper:
128+
[TODO]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
model.pkl
2+
cnum-vhcm-lab-new.txt
3+
WCS-Data-20110316/*
4+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)