innitial commit
Browse files- .gitignore +1 -0
- app.py +42 -0
- circle.jpg +0 -0
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
venv/
|
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from wordcloud import WordCloud, STOPWORDS
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
from collections import Counter
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
|
9 |
+
def white_color_func(word, font_size, position, orientation, random_state=None,
|
10 |
+
**kwargs):
|
11 |
+
return "rgb(0, 0, 0)"
|
12 |
+
|
13 |
+
|
14 |
+
plt.show()
|
15 |
+
|
16 |
+
|
17 |
+
def create_wc(text, custom_sw, input_img):
|
18 |
+
STOPWORDS.update(custom_sw.replace(" ", "").split(","))
|
19 |
+
print(STOPWORDS)
|
20 |
+
mask = np.array(input_img)
|
21 |
+
wordcloud = WordCloud(background_color="rgba(0, 0, 0, 0)", mode="RGBA",mask=mask, width=1000, height=1500, stopwords=STOPWORDS).generate(text.lower())
|
22 |
+
wordcloud.recolor(color_func=white_color_func, random_state=3)
|
23 |
+
return wordcloud
|
24 |
+
|
25 |
+
text_example = """
|
26 |
+
Harry Potter is a series of seven fantasy novels written by British author J. K. Rowling. The novels chronicle the lives of a young wizard, Harry Potter, and his friends Hermione Granger and Ron Weasley, all of whom are students at Hogwarts School of Witchcraft and Wizardry. The main story arc concerns Harry's struggle against Lord Voldemort, a dark wizard who intends to become immortal, overthrow the wizard governing body known as the Ministry of Magic and subjugate all wizards and Muggles (non-magical people).
|
27 |
+
|
28 |
+
The series was originally published in English by Bloomsbury in the United Kingdom and Scholastic Press in the United States. All versions around the world are printed by Grafica Veneta in Italy.[1] A series of many genres, including fantasy, drama, coming of age, and the British school story (which includes elements of mystery, thriller, adventure, horror, and romance), the world of Harry Potter explores numerous themes and includes many cultural meanings and references.[2] According to Rowling, the main theme is death.[3] Other major themes in the series include prejudice, corruption, and madness.[4]
|
29 |
+
|
30 |
+
Since the release of the first novel, Harry Potter and the Philosopher's Stone, on 26 June 1997, the books have found immense popularity, positive reviews, and commercial success worldwide. They have attracted a wide adult audience as well as younger readers and are often considered cornerstones of modern young adult literature.[5] As of February 2018, the books have sold more than 500 million copies worldwide, making them the best-selling book series in history, and have been translated into eighty languages.[6] The last four books consecutively set records as the fastest-selling books in history, with the final instalment selling roughly 2.7 million copies in the United Kingdom and 8.3 million copies in the United States within twenty-four hours of its release.
|
31 |
+
|
32 |
+
The original seven books were adapted into an eight-part namesake film series by Warner Bros. Pictures. In 2016, the total value of the Harry Potter franchise was estimated at $25 billion,[7] making Harry Potter one of the highest-grossing media franchises of all time. Harry Potter and the Cursed Child is a play based on a story co-written by Rowling.
|
33 |
+
|
34 |
+
The success of the books and films has allowed the Harry Potter franchise to expand with numerous derivative works, a travelling exhibition that premiered in Chicago in 2009, a studio tour in London that opened in 2012, a digital platform on which J. K. Rowling updates the series with new information and insight, and a pentalogy of spin-off films premiering in November 2016 with Fantastic Beasts and Where to Find Them, among many other developments. Themed attractions, collectively known as The Wizarding World of Harry Potter, have been built at several Universal Parks & Resorts amusement parks around the world.
|
35 |
+
"""
|
36 |
+
|
37 |
+
iface = gr.Interface(create_wc,
|
38 |
+
["text", "text", "image"],
|
39 |
+
"pil",
|
40 |
+
examples = [[text_example, "harry, potter", "circle.jpg"]])
|
41 |
+
|
42 |
+
iface.launch()
|
circle.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
wordcloud
|
2 |
+
pillow
|
3 |
+
matplotlib
|