Spaces:
Sleeping
Sleeping
File size: 3,481 Bytes
8fae864 7b1f0c9 d2b9280 7b1f0c9 8fae864 7b1f0c9 74093c1 7b1f0c9 74093c1 7b1f0c9 74093c1 f231473 74093c1 f231473 74093c1 7b1f0c9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ---
title: Protest Segments
emoji: 🔍
colorFrom: yellow
colorTo: gray
sdk: docker
suggested_hardware: t4-small
pinned: false
license: apache-2.0
---
<div>
<div align="center">
<img src="docs/method.jpg" alt="logo" width="500" height="auto" />
</div>
<div align="left">
<h1>Protest Segments</h1>
<p>
Protest segments is a two-level classification method that detects the
segments present in images and aggregates them into feature vectors, which are
then used in the second level by a standard machine learning classifiers to
discriminate between images. It was introduced in the paper "Improving Computer
Vision Interpretability: Transparent Two-level Classification for Complex Scenes"
and demonstrated in this repository.
</p>
<h4>
<a target="_blank" href="https://doi.org/10.1017/pan.2024.18">Paper</a>
<span> · </span>
<a target="_blank" href="https://github.com/ciass-konstanz/protest-segments/">Code</a>
<span> · </span>
<a target="_blank" href="https://huggingface.co/spaces/ciass/protest-segments">Demo</a>
<span> · </span>
<a target="_blank" href="https://doi.org/10.7910/DVN/TFTEF2">Data</a>
</h4>
</div>
</div>
<!-- Getting Started -->
## Getting Started
If you just want to try out our method with a couple of your images, we recommend you to
view [the demo](https://huggingface.co/spaces/ciass/protest-segments). The demo allows
you to upload an image, define a vocabulary of objects, an aggregation, and returns
the segmented image and the respective feature vector.
Even if you want to generate these vectors for a larger number of images, you don't have
to go through the following installation on your personal computer. Instead, you can use
the [demo via API](https://huggingface.co/spaces/ciass/protest-segments?view=api), for
which you only need to install the Gradio client for Python and follow the below Python
code snippet to obtain the vector for a sample image.
⚠️ If you want to use the same segmentation models as in the paper, then you have to
duplicate this space in a space environment with GPU accelerator.
Install the Gradio client for Python.
```bash
pip install gradio_client
```
Execute the below Python code snippet to obtain the feature vector for a sample image.
```python
from gradio_client import Client, file
client = Client("https://ciass-protest-segments.hf.space/")
result = client.predict(
image=file("https://raw.githubusercontent.com/ciass-konstanz/protest-segments/main/docs/demo.jpg"),
vocabulary="COCO",
feature_aggregation="count",
api_name="/predict"
)
print(result)
```
<!-- License -->
## License
The project's code is distributed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0),
while its data and model weights are distributed under the [CC-BY-4.0 License](http://creativecommons.org/licenses/by/4.0).
<!-- Citation -->
## Citation
If you find this project and its materials useful, please cite our paper.
```
@article{
scholz2025improving,
title={Improving Computer Vision Interpretability: Transparent Two-Level Classification for Complex Scenes},
volume={33},
DOI={10.1017/pan.2024.18},
number={2},
journal={Political Analysis},
author={Scholz, Stefan and Weidmann, Nils B. and Steinert-Threlkeld, Zachary C. and Keremoğlu, Eda and Goldlücke, Bastian},
year={2025},
pages={107–121}
}
```
|