sbroy10 commited on
Commit
64c8d69
1 Parent(s): f4a79ff

Create new file

Browse files
Files changed (1) hide show
  1. app.py +148 -0
app.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from wordcloud import WordCloud, get_single_color_func
2
+ from stop_words import get_stop_words
3
+ import numpy as np
4
+ from PIL import Image
5
+ import matplotlib.pyplot as plt
6
+ from collections import Counter
7
+ import gradio as gr
8
+
9
+
10
+ def create_wc(text, lang, custom_sw, input_img, color_rgb):
11
+ STOPWORDS = set(get_stop_words(lang))
12
+ STOPWORDS.update(custom_sw.replace(" ", "").split(","))
13
+ mask = np.array(input_img)
14
+ wordcloud = WordCloud(background_color="rgba(0, 0, 0, 0)", mode="RGBA",mask=mask, width=1000, height=1500, stopwords=STOPWORDS).generate(text.lower())
15
+ # wordcloud.recolor(colormap=colormap)
16
+ wordcloud.recolor(color_func=get_single_color_func(f'rgb({color_rgb})'))
17
+
18
+ return wordcloud
19
+
20
+ text_example = """
21
+ How do you think life originated on
22
+ earth and what insights does that give us about life
23
+
24
+ if we go back to the origin of earth and
25
+ you think about maybe 4.7 4.6 4.5 billion years ago planet was quite hot
26
+ there was a limited number of minerals there was some carbon some water and i
27
+ think that maybe it's a really simple set of chemistry that we we really don't understand
28
+ so that means you've got a finite number of elements that are going to react very simply with one another
29
+ and out of that mess comes a cell so literally sand turns into cells and it seems to happen quick
30
+ so what i think i can say with some degree of i think not certainty but curiosity
31
+ genuine curiosity is that life happened fast yeah so when we say fast
32
+ this is a pretty surprising fact and maybe you can actually correct me and elaborate but it seems like most
33
+ like 70 or 80 percent of the time that earth has been around there's been life on it like some very significant
34
+ percentage so when you say fast like the slow part is from single cell
35
+ or from bacteria to some more complicated organism it seems like most of the time that earth has been around
36
+ it's been single cell or like very basic organisms like a couple billion years but yeah you're
37
+ right that that's really i recently kind of revisited our history and saw this
38
+ and i was just looking at the timeline wait a minute like how did life just spring
39
+ up so quickly like really quickly that makes me think that it really wanted to like
40
+ put another way it's very easy for life to spring yeah i agree i think it's much
41
+ more inevitable and i think um i try to kind of not provoke but try and push
42
+ chemists to think about because chemists are part are central to this problem right of understanding the origin of life on
43
+ earth at least because we're made of made of chemistry but i wonder if the origin of life
44
+ on a planet or so the emergence of life on the planet is as common as the formation of a star
45
+ and if you start framing it in that way it allows you to then look at the universe slightly differently because
46
+ um and we can get into this i think in quite some detail but i think i to to come back to your question i have
47
+ little idea of how life got started but i know it was simple and i know that the process of selection
48
+ had to occur before the biology was established so that selection
49
+ built the framework from which life kind of grew in complexity and
50
+ capability and functionality and autonomy and i think these are all really important words that we can
51
+ unpack over the next while can you say all the words again so he says selection
52
+ so natural selection eight the original a b testing and so and then complexity
53
+ and then or the degree of autonomy and sophistication because i think that people misunderstand what life is um
54
+ some people say that life is a cell and some people that say that life is a a virus or life is a you know an on off
55
+ switch i don't think it's that life is the universe developing a memory
56
+ and the laws of physics and the way well there are no laws of physics physics is just memory free stuff
57
+ right there's only a finite number of ways you can arrange the fundamental particles to
58
+ do the things life is the universe developing
59
+ a memory so it's like sewing a piece of art slowly
60
+ and then you can look back at it so
61
+ so there's a stickiness to life it's like universe doing stuff and when you say memory it's like
62
+ there's a stickiness to a bunch of the stuff that's building together yeah so like you can in a stable way like uh
63
+ trace back the complexity and that tells a coherent story yeah and
64
+ i think yeah okay that's by the way very poetic and beautiful
65
+
66
+ life is the universe developing a memory [Music] okay and then there's autonomy you said
67
+ complexity we'll talk about but it's a really interesting idea that selection preceded biology
68
+ yeah i think yes so what first of all what is chemistry like does sand still count as chemistry
69
+ sure i mean as a chemist they can't carry a chemist if i'm allowed a card i don't know i don't know what i am most
70
+ days what is the card made of what's the chemical composition of the card
71
+ yeah so um what is chemistry well chemistry is the thing that happens when you bring electrons together and you form bonds
72
+ so bonds well i say to people when they talk about life elsewhere and i just say well there's bonds
73
+ there's hope because bonds allow you to get heterogeneity they allow you to record those memories or at least on
74
+ earth um you could imagine uh you know a stannis left lemtrey world
75
+ where you might have life emerging or intelligence emerging before life that may be something to on like solaris or
76
+ something but you know to get to selection if you can form if atoms can
77
+ combine and form bonds those bonds uh those atoms can bond to different elements and those and those
78
+ molecules will have different identities and interact with each other differently and then you can start to have some degree
79
+ of causation or interaction and then selection and then put and then existence
80
+ and then you you you go you go up the kind of the path of complexity and so at
81
+ least on earth as we know it there are there is a sufficient pool of available chemicals to start create
82
+ searching that combinatorial space of bonds so okay this is a really interesting
83
+ question let's let's lay it out so bonds almost like cards we say there's bonds
84
+ there is uh life there's intelligence there's consciousness and what you just made me
85
+ realize is um
86
+ those can emerge or let's put bonds aside uh those can emerge in any order
87
+ that's that's really brilliant so intelligence can come before life it's
88
+ like pan psychists believe that consciousness com i guess comes before
89
+ life and before intelligence so consciousness like permeates all matter it's some kind of fabric of
90
+ reality okay so like within this framework you can kind of arrange everything but you need to have the
91
+ bonds um that's precedes everything else oh and the other thing is selection
92
+ so like the mechanism of selection that could uh proceed see couldn't that proceed
93
+ bonds to whatever the house election so i would say that there is an elegant order to it that bonds
94
+ allow selection allows the emergence of life allows the emergence of multicellularity and then
95
+ more information processing building state machines all the way up however you could imagine a situation if you had
96
+ um i don't know a neutron star or a sun or a ferromagnetic loops interacting with one another
97
+ and these oscillators building state machines and these state machines reading something out in the environment
98
+ over time these state machines would be able to literally record what happened in the past and sense what's going on in the
99
+ present and imagine the future however i don't think it's ever going to be with
100
+ within a human comprehension that type of life um i wouldn't count it out because um
101
+ you know whenever you i know in science whenever i say something's impossible i then wake up the next day and say no that's actually wrong i mean there are
102
+ there are some limits of course um i don't see myself traveling fast and light any time soon but eric weinstein
103
+ says that's possible so he will say europe sure but i'm an experimentalist as well so one of my i have two super
104
+ powers and my stupidity and i don't mean that is a you know i'm like absolutely completely
105
+ witless but i mean my ability to kind of just start again and ask the question and then do it with an experiment i
106
+ always wanted to be a theoretician growing up but i just didn't have the just didn't have the intellectual capability but i i was able to think of
107
+ experiments in my head i could then do in my lab or in that you know when i was a with a child
108
+ outside and then those experiments in my head and then outside reinforce one another so i think that's a very good
109
+ way of kind of grounding the science right well that's the nice way to think about theoreticians is they're just
110
+ people who run experiments in their head i mean that's exactly what einstein did right and but you were also capable of
111
+ doing that in the head in your head inside your head and in the real world and the connection between the two
112
+ is when you first discovered your superpower stupidity i like it okay what's your second superpower oh your accent or
113
+ it's that well i don't know i'm my i like i am genuinely curious so my curious so i have a you know like
114
+ everybody ego problems but my curiosity is bigger than my ego so as long as that happens i i can i can that's awesome
115
+ that is so powerful you're just dropping some powerful lines so curiosity is bigger than ego that's something i
116
+ have to think about because you always struggle about the role of ego in life and um
117
+ that's that's so nice to think about don't think about the size of ego the absolute size of ego think about the
118
+ relative size of ego to the other the other horses pulling at you and if the
119
+ curiosity one is bigger then uh ego will do just fine and make you uh fun to talk
120
+ to anyway so those are the two superpowers how do those connect to natural selection or in selection and
121
+ bonds and i forgot already life and consciousness so that we're going back to selection in
122
+ the universe and origin of life on earth i mean um selection has a for i'm
123
+ convinced that selection is a force in the universe not me not a fundamental force but a but a directing but it is a
124
+ directing force because existence although um existence appears to be the default
125
+ um the existence of what why does um we can get to this later i think but
126
+ it's amazing that the discreet things exist and you know you see this cup it's not
127
+ the you know sexiest cup in the world but it's pretty functional this cup um
128
+ the complexity of this cup isn't just in the object it is literally the lineage of people making cups and recognizing
129
+ that seeing that in their head making an abstraction of a cup and then making a different one so
130
+ i wonder how many billions of cups have you know come before this one and
131
+ that's the process of selection and existence and the only reason the cup is still used is quite useful i like the handle you know it's convenient so i
132
+ don't die i keep hydration um and so i think we are missing something fundamental in the universe about
133
+ selection and i think what biology is is a is a selection amplifier
134
+ and that the this is where autonomy comes in and actually i think that how humanity is going to humans and
135
+ and autonomous robots or whatever we're going to call them in the future we'll we'll supercharge that even further so
136
+ selection is happening in the universe but if you look in the asteroid belt selection if objects are being kicked in
137
+ and out the asteroid belt um those trajectories are quite complex you don't really look at that as productive
138
+ selection because it's not doing anything to improve its function but is it the asteroid belt has existed for some time
139
+ """
140
+
141
+ iface = gr.Interface(create_wc,
142
+ ["text", gr.inputs.Dropdown(["en", "es"]) ,"text", "image", "text"],
143
+ "pil",
144
+ examples = [[text_example, "en", "um, i, i'm, we're, like, really, no, say, yeah, just, think, can", "roundrectangle.png", "128,0,0"]],
145
+ title="Visual Cluster Word Cloud Builder",
146
+ description="Create a word cluster visualization from a body or corpus of text. Word frequency makes the word size larger, and the image supplied can act as a mask to shape the visualization how you like. The custom stop word field allows you to enter a comma separated list of words you would like to exclude from the visualization.")
147
+
148
+ iface.launch()