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