Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -110,7 +110,10 @@ def generate_charts(ner_output_ext: dict) -> Tuple[go.Figure, np.ndarray]:
|
|
110 |
|
111 |
return fig1, wordcloud_image
|
112 |
|
113 |
-
def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.ndarray:
|
|
|
|
|
|
|
114 |
token_texts = []
|
115 |
token_scores = []
|
116 |
token_types = []
|
@@ -131,7 +134,7 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
|
|
131 |
entity_type = next((t for t, w in zip(token_types, token_texts) if w == word), None)
|
132 |
return color_map.get(entity_type, "#FFFFFF")
|
133 |
|
134 |
-
wordcloud = WordCloud(width=800, height=400, background_color='#121212', color_func=color_func).generate_from_frequencies(word_freq)
|
135 |
|
136 |
# Convert to image array
|
137 |
plt.figure(figsize=(10, 5))
|
|
|
110 |
|
111 |
return fig1, wordcloud_image
|
112 |
|
113 |
+
def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str], image_path: str) -> np.ndarray:
|
114 |
+
|
115 |
+
mask_image = np.array(Image.open(image_path))
|
116 |
+
|
117 |
token_texts = []
|
118 |
token_scores = []
|
119 |
token_types = []
|
|
|
134 |
entity_type = next((t for t, w in zip(token_types, token_texts) if w == word), None)
|
135 |
return color_map.get(entity_type, "#FFFFFF")
|
136 |
|
137 |
+
wordcloud = WordCloud(width=800, height=400, background_color='#121212', mask=mask_image, color_func=color_func).generate_from_frequencies(word_freq)
|
138 |
|
139 |
# Convert to image array
|
140 |
plt.figure(figsize=(10, 5))
|