Update README.md
Browse files
README.md
CHANGED
|
@@ -1,73 +1,106 @@
|
|
| 1 |
-
|
| 2 |
-
---
|
| 3 |
-
tags:
|
| 4 |
-
- bertopic
|
| 5 |
-
library_name: bertopic
|
| 6 |
-
---
|
| 7 |
-
|
| 8 |
-
# ISSR_Visual_Model
|
| 9 |
-
|
| 10 |
-
This is a [BERTopic](https://github.com/MaartenGr/BERTopic) model.
|
| 11 |
-
BERTopic is a flexible and modular topic modeling framework that allows for the generation of easily interpretable topics from large datasets.
|
| 12 |
-
|
| 13 |
-
## Usage
|
| 14 |
-
|
| 15 |
-
To use this model, please install BERTopic:
|
| 16 |
-
|
| 17 |
-
```
|
| 18 |
-
pip install -U bertopic
|
| 19 |
-
```
|
| 20 |
-
|
| 21 |
-
You can use the model as follows:
|
| 22 |
-
|
| 23 |
-
```python
|
| 24 |
-
from bertopic import BERTopic
|
| 25 |
-
topic_model = BERTopic.load("D0men1c0/ISSR_Visual_Model")
|
| 26 |
-
|
| 27 |
-
topic_model.get_topic_info()
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
tags:
|
| 4 |
+
- bertopic
|
| 5 |
+
library_name: bertopic
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# ISSR_Visual_Model
|
| 9 |
+
|
| 10 |
+
This is a [BERTopic](https://github.com/MaartenGr/BERTopic) model.
|
| 11 |
+
BERTopic is a flexible and modular topic modeling framework that allows for the generation of easily interpretable topics from large datasets.
|
| 12 |
+
|
| 13 |
+
## Usage
|
| 14 |
+
|
| 15 |
+
To use this model, please install BERTopic:
|
| 16 |
+
|
| 17 |
+
```
|
| 18 |
+
pip install -U bertopic
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
You can use the model as follows:
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
from bertopic import BERTopic
|
| 25 |
+
topic_model = BERTopic.load("D0men1c0/ISSR_Visual_Model")
|
| 26 |
+
|
| 27 |
+
topic_model.get_topic_info()
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
You can make predictions as follows:
|
| 31 |
+
```python
|
| 32 |
+
|
| 33 |
+
val_labels = [...] # list of caption
|
| 34 |
+
val_images = [...] # list of images
|
| 35 |
+
|
| 36 |
+
topic, _ = topic_model.transform(val_labels, images=val_images)
|
| 37 |
+
all_topic_info = [topic_model.get_topic_info(t) for t in topic]
|
| 38 |
+
all_prediction_info = pd.concat(all_topic_info, ignore_index=True)
|
| 39 |
+
|
| 40 |
+
# Visualize predictions:
|
| 41 |
+
sample_images = 100
|
| 42 |
+
n_images = min(sample_images, len(val_images))
|
| 43 |
+
n_cols = 4
|
| 44 |
+
n_rows = math.ceil(n_images / n_cols)
|
| 45 |
+
|
| 46 |
+
fig, axes = plt.subplots(n_rows, n_cols, figsize=(15, n_rows * 3))
|
| 47 |
+
axes = axes.flatten()
|
| 48 |
+
|
| 49 |
+
for i, (path, (_, row)) in enumerate(zip(val_images[:n_images], all_prediction_info.iterrows())):
|
| 50 |
+
ax = axes[i]
|
| 51 |
+
ax.imshow(Image.open(path))
|
| 52 |
+
ax.axis('off')
|
| 53 |
+
ax.set_title(f"Topic {row['Topic']}: {row['KeyBERTInspired'][0]}")
|
| 54 |
+
|
| 55 |
+
# Hide unused axes
|
| 56 |
+
for j in range(n_images, len(axes)):
|
| 57 |
+
axes[j].axis('off')
|
| 58 |
+
|
| 59 |
+
plt.tight_layout()
|
| 60 |
+
plt.show()
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Topic overview
|
| 64 |
+
|
| 65 |
+
* Number of topics: 5
|
| 66 |
+
* Number of training documents: 3727
|
| 67 |
+
|
| 68 |
+
<details>
|
| 69 |
+
<summary>Click here for an overview of all topics.</summary>
|
| 70 |
+
|
| 71 |
+
| Topic ID | Topic Keywords | Topic Frequency | Label |
|
| 72 |
+
|----------|----------------|-----------------|-------|
|
| 73 |
+
| -1 | drug - people - gun - - | 93 | -1_drug_people_gun_ |
|
| 74 |
+
| 0 | gun - people - drug - - | 134 | 0_gun_people_drug_ |
|
| 75 |
+
| 1 | drug - gun - - - | 2701 | 1_drug_gun__ |
|
| 76 |
+
| 2 | people - gun - - - | 429 | 2_people_gun__ |
|
| 77 |
+
| 3 | people - gun - drug - - | 370 | 3_people_gun_drug_ |
|
| 78 |
+
|
| 79 |
+
</details>
|
| 80 |
+
|
| 81 |
+
## Training hyperparameters
|
| 82 |
+
|
| 83 |
+
* calculate_probabilities: False
|
| 84 |
+
* language: None
|
| 85 |
+
* low_memory: False
|
| 86 |
+
* min_topic_size: 50
|
| 87 |
+
* n_gram_range: (1, 3)
|
| 88 |
+
* nr_topics: None
|
| 89 |
+
* seed_topic_list: None
|
| 90 |
+
* top_n_words: 5
|
| 91 |
+
* verbose: True
|
| 92 |
+
* zeroshot_min_similarity: 0.7
|
| 93 |
+
* zeroshot_topic_list: None
|
| 94 |
+
|
| 95 |
+
## Framework versions
|
| 96 |
+
|
| 97 |
+
* Numpy: 1.26.4
|
| 98 |
+
* HDBSCAN: 0.8.36
|
| 99 |
+
* UMAP: 0.5.6
|
| 100 |
+
* Pandas: 2.2.2
|
| 101 |
+
* Scikit-Learn: 1.4.1.post1
|
| 102 |
+
* Sentence-transformers: 3.0.1
|
| 103 |
+
* Transformers: 4.39.3
|
| 104 |
+
* Numba: 0.60.0
|
| 105 |
+
* Plotly: 5.22.0
|
| 106 |
+
* Python: 3.12.4
|