Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -188,8 +188,10 @@ def generate_wordcloud(entities: List[Dict], color_map: Dict[str, str]) -> np.nd
|
|
| 188 |
# Convert plt to numpy array
|
| 189 |
plt_image = plt.gcf()
|
| 190 |
plt_image.canvas.draw()
|
| 191 |
-
image_array = np.frombuffer(plt_image.canvas.tostring_rgb(), dtype=np.uint8)
|
| 192 |
-
image_array = image_array.reshape(plt_image.canvas.get_width_height()[::-1] + (3,))
|
|
|
|
|
|
|
| 193 |
plt.close()
|
| 194 |
|
| 195 |
return image_array
|
|
|
|
| 188 |
# Convert plt to numpy array
|
| 189 |
plt_image = plt.gcf()
|
| 190 |
plt_image.canvas.draw()
|
| 191 |
+
#image_array = np.frombuffer(plt_image.canvas.tostring_rgb(), dtype=np.uint8)
|
| 192 |
+
#image_array = image_array.reshape(plt_image.canvas.get_width_height()[::-1] + (3,))
|
| 193 |
+
image_array_rgba = np.asarray(plt_image.canvas.buffer_rgba())
|
| 194 |
+
image_array = image_array_rgba[:, :, :3]
|
| 195 |
plt.close()
|
| 196 |
|
| 197 |
return image_array
|