AlGe commited on
Commit
ccbf9e7
·
verified ·
1 Parent(s): 2461e4f

Update app.py

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