Update app.py
Browse files
app.py
CHANGED
@@ -120,6 +120,7 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str], file_pat
|
|
120 |
raise FileNotFoundError(f"Mask image file not found: {image_path}")
|
121 |
|
122 |
mask_image = np.array(Image.open(image_path))
|
|
|
123 |
|
124 |
token_texts = []
|
125 |
token_scores = []
|
@@ -139,9 +140,9 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str], file_pat
|
|
139 |
entity_type = next((t for t, w in zip(token_types, token_texts) if w == word), None)
|
140 |
return color_map.get(entity_type, "#FFFFFF")
|
141 |
|
142 |
-
wordcloud = WordCloud(width=
|
143 |
|
144 |
-
plt.figure(figsize=(
|
145 |
plt.imshow(wordcloud, interpolation='bilinear')
|
146 |
plt.axis('off')
|
147 |
plt.tight_layout(pad=0)
|
|
|
120 |
raise FileNotFoundError(f"Mask image file not found: {image_path}")
|
121 |
|
122 |
mask_image = np.array(Image.open(image_path))
|
123 |
+
mask_height, mask_width = mask_image.shape[:2]
|
124 |
|
125 |
token_texts = []
|
126 |
token_scores = []
|
|
|
140 |
entity_type = next((t for t, w in zip(token_types, token_texts) if w == word), None)
|
141 |
return color_map.get(entity_type, "#FFFFFF")
|
142 |
|
143 |
+
wordcloud = WordCloud(width=mask_width, height=mask_height, background_color='#121212', mask=mask_image, color_func=color_func).generate_from_frequencies(word_freq)
|
144 |
|
145 |
+
plt.figure(figsize=(mask_width/100, mask_height/100))
|
146 |
plt.imshow(wordcloud, interpolation='bilinear')
|
147 |
plt.axis('off')
|
148 |
plt.tight_layout(pad=0)
|