You've got this amazing machine learning model you created, and you want to share it and let your colleagues and users experiment with it on the web.
How do you get started? Learning Flask or Django?
Great frameworks, but you might consider Gradio, which is a rapid development UI framework for ML models.
On this episode, we have Freddie Bolton to introduce us all to Gradio.
This is Talk Python to Me, episode 430, recorded August 10th, 2023.
Welcome to Talk Python to Me, a weekly podcast on Python.
This is your host, Michael Kennedy.
Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython, both on fosstodon.org.
Be careful with impersonating accounts on other instances. There are many.
Keep up with the show and listen to over seven years of past episodes at talkpython.fm.
We've started streaming most of our episodes live on YouTube.
Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.
This episode is brought to you by JetBrains, who encourage you to get work done with PyCharm.
Download your free trial of PyCharm Professional at talkpython.fm/done dash with dash PyCharm.
And it's brought to you by Sentry.
Don't let those errors go unnoticed.
Use Sentry.
Get started at talkpython.fm/sentry.
Brady, welcome to Talk Python to Me.
Thanks for having me, Michael.
Yeah, it's great to have you here.
I think people are going to learn a lot about some machine learning on this episode.
And you've got this really cool visual way, this visual tool of working with machine learning projects.
And oftentimes people ask me, I'm not really a web developer, but I have some machine learning stuff or I'm a data scientist and I want to share with people.
How do I do that?
So your project might be a good answer to that for some folks, right?
Yeah, absolutely.
I think, yeah, Gradio is built for that use case.
I think you can build like lots of complex stuff with Gradio, web apps and stuff, but you could, it's optimized for the ML use case.
Like how do you get like an ML workflow, like on the web and share it with people as quickly as possible?
That's kind of what Gradio is built for.
I've got it running my computer.
How do I take it from a notebook to something that other people who are not programmers can use, right?
Yeah, exactly.
That's kind of it.
And it's with Gradio, it's one line.
You can get a shareable link directly from your Colab notebook, Jupyter notebook, SageMaker, local, whatever.
Yeah, so it's really easy to share with people.
Excellent.
All right, before we dive into that, let's start with you.
A quick story, quick introduction about you and how you got into programming Python.
Yeah, absolutely.
So all the way from the beginning, I graduated with a degree in statistics and my first job was working as a data scientist in Chicago.
And that was doing more like bread and butter data science-y stuff.
Like you pull data from like database and like you train a model and then you like try to communicate the results with someone.
And then at the time, yeah, I mean, it wasn't that long ago, but to me, it feels like it was like a millennia ago.
Technologically speaking, it's so different.
Yeah.
Yeah, it was like a really long time ago.
Yeah.
But then basically like what happens or what happened to me a lot was just like, okay, like we need to like, we're training this model.
Like how do we share, like share with the relevant like stakeholders, right?
There's like a PM or like someone that's interested in this.
Like how do you, how do we, how do you make them care?
And then there really wasn't a good answer.
Like you would have to like, you'd like compute like some metrics and then try to explain what they mean.
And you like draw like a bar plot or something.
And it just wasn't really that useful.
And I think it really was, to be fair, it was like a skill gap.
I didn't even know how to build like an interactive website to share with people.
Because at the end of the day, what really, what people really care about or how to make someone really care about it is they can play with it.
Right.
Because if you show them these plots and these metrics, it's like a machine learning model is like very abstract.
Right.
It's like just this thing that's somewhere else.
And then this is like the output of it, but it's not really even like the actual output.
It's just like some sort of summary statistics of it.
Right.
But if you give someone like this is what the model is and you can let them like manually play with the inputs and see how the outputs change.
They get a sense of, well, like what the model is and how it works and stuff like that.
Right.
And I think that's where I learned about this problem and why this problem is important.
And then ever since then, I've been sort of devoting to devoting myself to working on like open source tools to like make data science like more efficient.
And like my, my, the latest product that I worked on is called Gradio, which kind of does this.
It basically lets you turn a machine learning function into a web app in one line of code.
And from there you can jump off and build like as complex of a web app as you want.
But from the beginning, you can get up and running with just like basically two lines of code.
So yeah.
Excellent.
A little bit about me.
You talked about let people play with the machine learning model and you change the inputs and stuff.
It just completely changes the round trip speed because the alternative might be, I'll make, I'll get you a PDF and you can read the report.
And then what if we change this?
All right.
At tomorrow's meeting, I'll bring the new PDF.
Just empower people and give them these tools.
And yet at the same time, data scientists are not web developers, certainly not in the super dynamic front end Ajax callback way of programming.
Right.
That's a different skill to be sure.
And so it's not like their data science skills by default make them able to build these.
And even if you could, is it a good use of your time?
Right.
Yeah, absolutely.
And yeah, so it's like the PDF report is definitely like one, one way of doing it.
The other way that we tried to do sometimes is we'll just hand it off to someone and we'll, we'll have them build the web.
But then that just takes longer.
You have to like explain everything to them.
Right.
I think like the, make it really impactful as if the person who made the model can they themselves, they can just create the web app, the demo, like immediately.
A lot of these, a lot of data scientists are in Python, right?
So that kind of means you need like a Python based tool to get you up and running really quickly.
And a lot of them, yeah, like you said, don't know about web programming.
So you've got to like abstract that away as much as you can, like as much as it makes sense.
So that they're not like daunted or it's not like, okay, now I'm like, I'm really good at PyTorch and training or like all these things.
And like now I need to learn about whatever, like servers and all that stuff.
It's like, it's like almost a different skill set for a lot of people.
It really is.
And the handed off to somebody else, it's also, it's slow, but also it only works for certain situations, right?
Like a lot of data scientists, I suspect don't have a whole software team supporting them as they need, right?
They're the sole person at their company.
So you said you had gone into statistics and found your way over to this side of that world.
You feel like it's a golden age for statisticians now, because when I went to college, it's like, well, you could be an actuary or you could work at an insurance company.
Or maybe some other company might be interested in hiring somebody who does stats.
You could work at the U.S. Bureau of Statistics.
Yeah, exactly.
And that was, and now with the kind of blending into data science, there's just so in demand.
So when it was like, the world is so open for that now.
It definitely became a much sexier career.
And I think I got lucky that I got into it like right before, right as it was starting to take off.
Like at that point, like data science wasn't really like a term yet.
I'm not that old, but yeah, at that time it wasn't really.
There were like, I think at that point, like they were called, it's like research scientists was more like the term, right?
Which still sounds a little bit dry, but then it got rebranded as data science.
Yeah.
I mean, I think it's a, I mean, I would say it's always a good time to study statistics.
I think like a lot of people, if someone were to come back to me and say, I have no idea what I want to major in, but I have some aptitude for math.
I would say like major in statistics.
I think it's like really useful.
It has like a lot of applications.
But I think now also in terms of tech, I feel like definitely like it's sort of like the, it's the era of the Renaissance person, right?
Like you have to know a little bit of everything now.
Like, right.
Cause it's like stats, programming, math.
Like all these things are starting to like blend it, blend together.
And yeah, I think it's like a lot of people I really respect pulled from all these disciplines, like seamlessly.
Right.
And I think it's, yeah, I think that's kind of where we are now.
Yeah.
It's a super fun time.
If you're excited about always learning new things and sort of bettering yourself and bringing in this thing and mixing it that way.
If you'd rather just be done learning, maybe not so much.
Absolutely.
Can't just show up for 20 years.
It'd be okay.
I guess if you were like maintaining COBOL to code, it would be okay.
But not in the machine learning space and machine learning also is just crazy.
We've got large language models just running loose everywhere now.
What do you think about all that?
It's definitely like a very exciting time to be alive.
I think it's pretty crazy that when I got started in ML six years ago, it was, it definitely was like very niche.
Right.
And like the tools that people use and like the language about it definitely did not penetrate the mainstream.
But now it seems like, like the technologies and the algorithms, the models, the datasets are all things that people talk about now.
Right.
And I think we've all had an older relative ask us about ChatGPT or like the latest trend or stable diffusion with the image, the AI image generation.
I think it has penetrated every part of this.
I think like part of the reason why that is, is one, because like one, like the technology is like way more impressive now.
Right.
Like these algorithms are able to do things that were unimaginable, like 2017, right.
When I graduated college.
But also it's just, these models are much easier to share and use now.
Right.
And I think part of the reason why ChatGPT is so, we took off so quickly, which is like the interface is so intuitive.
It is.
We've been chatting with each other for like decades, like over the internet.
Right.
And the user interface is so simple and it works.
So fits our mental model so quickly or so easily.
But, you know, under the hood, it's like this incredibly complex process.
Right.
Yeah.
Right.
And I think that's like where tools like radio come into play.
Right.
It's just, there's a bunch of like incredible, like amazing research happening, but unless other people can use it, play with it, evaluate it, like it's almost as if it doesn't exist.
Right.
And I think radio really helps you create like a demo, an app that other people can use and play with and evaluate your model.
And then, and then just like that, anyone can use it.
Right.
Like, you don't, you no longer have to be like a technical person and you don't have to like type on some script or something and then go to a website.
Right.
You can just go to a website, right.
You can just send someone a link and then they can play with the state of the art.
It's pretty, pretty cool.
Can you control a combo box and a button?
Yeah.
Something like that.
Right.
Yeah.
Then you're qualified.
It's wild.
One of the things that surprises me is for such insane technology that leverages so many servers to chat to PT and friends, the user interface for it is so mundane.
I don't mean that as a derogatory term, but it's just like, well, you just talk to it in this text box and it just talks.
There's not like a crazy new UI where you put on 3D glasses.
It's just a chat box.
But what it does is incredible.
Similar for mid journey and other things.
You just slash imagine, just chat with it.
But so there's this sort of weird paradox of this incredible, simple way to interact with it.
And yet what it does is, I guess it's a natural way to interact with it, which is what's surprising.
Yeah.
Part of the reason, I think it's just like the natural language interface.
I think a lot of people resonate with that.
I think you don't have to explain that.
Right.
Like you just type something and then it'll respond.
Right.
Like it won't error.
Right.
And I think even like stuff that isn't just purely chat based, I think like stable diffusion, like the web UI.
Right.
I think it's, it has a lot of controls.
Right.
But at the end of the day, it's like a Photoshop-esque interface.
Right.
Where it's like someone who's used to that kind of software, like it's what they expect, right?
You like upload an image and then you like, you can like get a tool to blur something out and then you can intaint it or outpaint it and stuff like that.
So I forget who said it, but I think someone, someone said that MLs, it's not really like the product.
It's like the, like in the background, right?
Like the most successful ML products, they don't really feel like they're ML.
Right.
It's like the MLs, like abstracted away and it just makes your experience like that much better.
Right.
And I think that's what all these different tools are showing.
Amazing.
All right.
So let's talk about Gradio and I'm going to ask you just something a little bit funky to kick this off, but let's talk about what just what other apps are like Gradio.
So things that come to mind for me are like StreamYard, for example.
Streamlit?
Sorry, that's what I mean.
Yeah.
Stream, I'm reading the words of our app that we're using.
Streamlit, not StreamYard.
Streamlit and other, just give people a sense of what are the categories of apps that's in the same space so they can get a mental model for what
Gradio is.
For sure.
Yeah.
So I think like Streamlit is a good comparison.
Like Plotly, Dash, I think is also in the same ecosystem.
Shiny, if I think.
Yeah.
I think like the first programming language.
Yeah.
I just had Joe on to talk about Shiny for Python.
Yeah.
Recently, yeah.
They're all definitely in the same ecosystem.
If you go to the Gradio homepage, Gradio.app, you can see some of the apps that you can build with Gradio really quickly.
Absolutely.
Yeah.
But that doesn't necessarily limit.
Like what you see on the landing page is not all that you can build with Gradio.
I think those are just like the eye-catching quick examples just because, like I said, like Gradio is built to get these kind of examples up and running really quickly.
But you can do like lots of complex stuff with Gradio.
Excellent.
Yeah.
So let's dive into it.
So you've already given a bit of an introduction for us.
Maybe we could work, just start by discussing how you might take, you've got some different types of problems you can solve on your homepage.
And it shows you the code, the entire code.
Yeah.
Then the UI that comes out of it.
So maybe you could just talk us through the sketch recognition.
It's one of the types of UIs you could build here.
So with the sketch recognition, you just, when you draw, it's definitely a bird I drew there.
Or a mountain.
I'm not sure.
How do you think about Gradio?
So Gradio is a Python library, right?
Python is the main language used to interface or to build Gradio apps.
Pip install Gradio.
Yeah.
You pip install Gradio, right?
And then what does Gradio do?
At the highest level, Gradio turns a Python function, any Python function into a interactive web app, right?
So when you think of function, right?
Function has inputs and outputs.
So these inputs correspond, these inputs and outputs correspond to things that will be drawn on the page, right?
And Gradio comes with a standard set of inputs, right?
There's like text boxes, drop downs, number fields, data frames, plots, anything like that.
But also like drawing tools like a sketch pad.
And then the output, it can be any of these other components, but it could also be like a label, right?
To show like a machine learning prediction.
So all you need to do is take, write a plain Python function that takes in a drawing and returns a set of probabilities or competences.
And then Gradio can wrap that in one line of code and turn it into an interactive web app.
Like we see here, if you're on the YouTube stream, you can see what Michael is doing.
There's like a sketch pad area and then he can scribble on it and then immediately he'll get a prediction out.
Yeah.
Let's see if I can draw an owl, maybe.
Right.
So it's like updating.
Let's see how I do.
I don't know.
Yeah.
Syringe.
We've got to make the model better, right?
It could be a cat.
It definitely could be a cat.
I can see cat.
I can see.
I think I've got to make my drawing better.
But so the idea is you have a regular function that takes the inputs and outputs.
There's no UI whatsoever.
And there's also no reactive programming.
You're not like hooking events where I redraw and it just reruns, right?
That's not part of my code I write as a Python person.
Right.
And then you just say gr.interface, give it the function.
And then you say the inputs are, in this case, you say it's just a sketch pad.
And so I get this UI that I can draw on that I've been attempting to draw an owl on.
It's probably missing the eyes.
I think it's the eyes that are missing.
The latter.
It's not about testing the underlying model, is it?
And then you say the outputs in our label.
Now, a lot of UIs, people might think of label is just a non-interactive piece of text.
But here, there's more of a machine learning label, right?
You've got like a cool horizontal bar graph that has percentages and talks about its guesses.
So it's like a machine learning labeled response report.
A machine learning person would, when they see label, they think that,
they don't think of the standard web, like just like a text box, right?
Yeah.
Like label four type of thing in HTML.
Yeah.
Right.
So that's one of the things that, or one of the ways that kind of Gradio is built for that
kind of audience, right?
It's like the high-level perimedal, match that mental model.
This portion of Talk Python to Me is brought to you by JetBrains and PyCharm.
Are you a data scientist or a web developer looking to take your projects to the next level?
Well, I have the perfect tool for you, PyCharm.
PyCharm is a powerful integrated development environment that empowers developers and data
scientists like us to write clean and efficient code with ease.
Whether you're analyzing complex data sets or building dynamic web applications, PyCharm has
got you covered.
With its intuitive interface and robust features, you can boost your productivity and bring your
ideas to life faster than ever before.
For data scientists, PyCharm offers seamless integration with popular libraries like NumPy,
Pandas, and Matplotlib.
You can explore, visualize, and manipulate data effortlessly, unlocking valuable insights with
just a few lines of code.
And for us web developers, PyCharm provides a rich set of tools to streamline your workflow.
From intelligent code completion to advanced debugging capabilities, PyCharm helps you write
clean, scalable code that powers stunning web applications.
Plus, PyCharm's support for popular frameworks like Django, FastAPI, and React make it a breeze
to build and deploy your web projects.
It's time to say goodbye to tedious configuration and hello to rapid development.
But wait, there's more.
With PyCharm, you get even more advanced features like remote development, database integration,
and version control, ensuring your projects stay organized and secure.
So whether you're diving into data science or shaping the future of the web, PyCharm is
your go-to tool.
Join me and try PyCharm today.
Just visit talkpython.fm/done-with-pycharm, links in your show notes, and experience the
power of PyCharm firsthand for three months free.
PyCharm.
It's how I get work done.
One thing you mentioned earlier is that there's no explicit reactivity that you as a programmer
have to write.
That's definitely true in the gr.interface case.
gr.interface abstracts all that away from you.
But Gradio also offers...
So this is your simple case.
Like, I just want...
Just run this function with these inputs and outputs, and I want a real basic variant.
Okay?
Gradio also offers like a lower-level API where you can explicitly control the layout, right?
So right now, everything is like side-by-side.
You can put them horizontally across columns, rows.
You can add components, right?
And then you can also be more explicit in saying, okay, when this input changes, run this function,
and then that will populate this and stuff like that.
And you can change these things together.
So...
It makes sense.
Maybe it's expensive to...
It's expensive to generate some portion.
You want to cache it as much as possible.
Yeah.
You just want to have like more control over like exactly what happens when things change,
right?
You could...
Gradio gives you that control.
But for a lot of use cases, you can get...
You can get really far with gr.interface.
And then the other companion piece, which isn't on the landing page because we just released
it maybe two weeks ago, it's gr.chat interface, right?
So you could build like a...
Oh, interesting.
To an LLM or something.
Yeah, you could build a chat UI for...
Yeah, like an LLM just in one line of code.
And I think I can try to maybe find an example of that real quick.
Yeah.
While you're looking, do you offer any guidance or any opinionated stuff on which LLM to choose?
Or do you just say, it's just a chat interface and you write the code to make it happen?
You just write the code to...
Yeah, just given the message, what should the response be?
And then that's the interface.
Yeah.
And then...
There's some interesting options.
People might want to pick.
Obviously, you could pick OpenAI and use their API, but there's things like private GPT, which
allows you to ask questions about your documents, but 100% private, right?
You could just give it hundreds of docs and say, learn these and we're going to talk to you
about it.
Or something along those lines.
There's Langchain, right?
Yeah.
Which is a pretty interesting option for building these things.
Llama.
Like the new Llama 2.
Yeah.
The Llama 2.
Yeah.
So I think in the chat, I just posted like a radio Llama 2 UI that we can show.
It's on Hugging Face.
So I think we can talk about the hosting on Hugging Face as well.
Okay.
Yeah.
So this is the chat UI.
So if you were to scroll down a little bit...
UI says chat bot, you can type a message.
Yeah.
I'll ask it what the podcast says.
Hey, I'm here to help you.
HugPython is a podcast and community dedicated to helping developers improve their skills,
interviews, and experts in the field.
That's you, Freddie.
Resources.
Yeah.
What do you want to know?
Under the hood, this is using Llama 2, 70 billion.
Nice.
I can ask you what the latest episode is.
So it gives me a sense how far back it goes.
That's about two years old.
So okay.
Interesting.
Very good.
Yeah.
Makes sense.
Oh, wait.
No, this is...
I'm not so sure about that.
That's accurate.
Yeah.
I think there's a little bit of a mismatch, but this is really cool.
So you basically plug in whatever LLM you want to into this and they put the...
Or you put the Llama 2.
If you scroll up a little bit in the website, if you...
Like you see those like three bars?
Yeah.
The hamburger deal.
Oh, no.
Sorry.
That's not it.
Other hamburger.
Where is it?
There are three dots maybe?
Oh, I guess maybe because you don't have an account.
You can't see the file.
Oh, yeah.
If you go to files there, if you go to files, I'm going to app.py.
This is the source code of the...
Oh, interesting.
Okay.
If you scroll down, the helper text, and then this is the actual prediction function.
It's about 20 lines of code.
But if you scroll down, you see the chat interface code.
With GR blocks as demo?
Okay.
The tab, a batch.
Okay.
The important thing is that your chat interface is just like a one-line way to create a chatbot.
It works similarly to the interface case.
There's just a function.
In this case, it's an LLM, so it handles like the responding to each user message.
And then you just call that, and then you can call launch, and then you get a UI.
Nice.
You get like a chatbot-esque UI.
And in this case, it's 100 lines of code.
But, you know, yeah, pretty simple.
That is simple.
And one of the things that's pretty cool here is section.
You hook it to the type you set up is a streaming type versus the place I type is a batch.
And then the function you give it is a generator with yield keyword.
So it just, as you go through it, it makes choices and sends them back.
Pretty advanced interaction for the UI to be running like that.
That's cool.
In order to get streaming, there's no special syntax.
You can just use the normal Python yield, and then Gradio knows how to feed that iteratively.
Feed that to the front end, and then you get like this responsive streaming UI.
That's a really good call out.
It's just like the, and Gradio tries to use like the core Python syntax and the core Python data types as much as possible.
Just to make it easy for people to get up and running.
I just blew through this really quickly here.
But basically, from what I can tell, is the amount of code here to actually implement this,
that is not just the details of giving this text, make the LLM do the thing.
Five lines of code.
Yeah, definitely true.
That should make people pretty excited about, hey, I can write five lines of code,
especially with an example to work from.
Exactly, yeah.
So, yeah, definitely we need to get chat interface up in the landing page.
But, yeah, I think it's super easy to get complex demos running.
I think it's just a handful of lines of code.
We mentioned Shiny a little bit.
Boomyar asks, how does it compare to Shiny?
How familiar with Shiny can you?
I'm not super familiar.
I'm ominously not familiar.
I'm familiar with Shiny, but not well enough to compare it directly to Gradio either.
I mean, they live in the same general world of trying to create a UI that you don't have to write web apps for.
But I don't think they're totally the same, but they're similar.
Okay.
So, we talked about setting up pip install.
That's easy.
You say you can choose from a variety of interface types.
These are the widgets that you're talking about, right?
You could, like, in terms of the inputs and the outputs, we call them components.
But, yeah, there's...
If you go to the docs page, we have about 30-something components.
Wow, okay.
Yeah, so code, buttons, data frames, plots, files, pretty much, like, you name it.
And we're adding components all the time.
And we're also...
One of the things that we're going to work on is letting the community create their own components.
So, if you have your own particular demo, your own particular web app, and you want this new component that we don't support, like, how do you...
We're working to make it easy for you to do that without having to merge something into Gradio upstream, right?
And then other people can play with it.
So, we're working on that as well.
But for the time being, it's, yeah, about these, like, 30-something components.
And then, yeah, you can mix and match them however you want.
You've got quite a bit of them.
Many of them, I suspect, people would imagine.
So, you've got button.
Yeah.
Let's see.
You've got data frame, which is pretty cool.
And then gallery image.
The plots.
The plots, like the line plot, scatter plot.
Those are all pretty cool.
But you've also got things like audio.
What's the story with audio?
This is how you...
Yeah, you can upload, like, an MP3 or a WAV file directly.
Okay.
Maybe for a transcript.
Or a sentiment analysis or something?
Exactly.
Like, whisper.
Essentially, audio to transcription.
Or also just synthetic audio, right?
So, there's, like, Bark.
And there's all these, like, machine learning demos.
They go text-to-speech, basically.
And they're really advanced.
So, if you wanted to display that, right?
Like, you ingest text, come out with audio.
Like, you could use, like, an audio output component.
And then you get, yeah, you get, like, a...
You can play the audio directly in the browser.
It's just like an audio tag in HTML.
Obviously, it does more from the UI, I'm sure.
But it's to not just...
I guess you would just do file if you really wanted to drop it in MP3.
But if you wanted to generate audio and let people see the results, then this audio thing
would be the way to go.
Yeah.
And then you could also...
The audio could also be, like, the input, right?
You could just drag it, drop it, you know.
If you click on that box, it'll let you upload an audio if you have it.
And then you could...
Interesting.
You could play it, right?
I'm sure I have some audio.
Yeah.
I know that I have some.
But let's see if I can find something to upload here.
Here, I'll upload a sponsor.
Here, this is super short.
So, I can upload.
Yeah, look at that.
And it just becomes a player.
Excellent.
You can play it and then you can also edit it as well.
So, you see that little pencil?
Uh-huh.
And you could, like, trim it.
You could do, like, trim it to make it shorter.
Okay.
Yeah.
Very nice.
Yeah.
Lots of cool components like that that we have.
Yeah.
All the standard form stuff, like sliders and drop-downs and, yeah.
Highlighted text.
And, yeah, so the standard, like, form stuff.
But then there's also complex...
Not complex, but more maybe domain-specific ML stuff.
So, highlighted text, for example.
Like, really big and, like, part of speech tagging, like NLP.
Right?
So, you can get, like, highlighted.
It's, like, depending on the tag that you apply to each word in the text, you get, like, different coloring and stuff like that.
Yeah.
So, it's for MLP, like, Model 3D.
So, there's a lot of ML demos that come out that you can generate Model 3D assets directly.
So, this lets you display them, as well.
So, yeah.
So, everywhere...
We have everything from the most kind of basic, general, like, web app stuff.
Domain-specific machine learning...
Yeah.
...components as well.
Yeah.
Let's see what else jumps out here.
We have video as well, which is pretty cool.
JSON.
Yeah.
There's a lot of what you can type in.
JSON, I guess it probably validates it and auto-formats it, something, rather than just plain text.
Yeah.
When you return the JSON, it highlights it for you.
You can copy it directly as well, so...
Okay.
So, when we were talking about the Gradio.interface, it had, well, here's an input and here's an output.
Floral?
So, could you have, if I say, there's a sketch pad and a text box?
Yeah.
As the input, and then the outputs are, I don't know, three other things?
Yeah.
That's a really good observation.
Yeah.
So, you can have more than one input, more than one output, for sure, right?
So, if you go to the, I think, the time series forecasting demo, I think that one has two inputs, right?
That's also on the homepage.
Yeah.
Also on the homepage, right?
So, you can pick...
I see.
It's like a toy example, like forecasting.
If I installs, but you could pick...
Here has two inputs, right?
Like, the time horizon and the library itself.
Both of them are dropdowns, right?
And then when either updates, the plot updates, right?
So, there's also, like, how you can do plotting in Gradio.
And then, also, this is interesting.
This demo is built with the lower-level API.
You could build it with interface if you wanted to.
Just as an example, it's built with the lower-level API.
Yeah.
So, I guess there's probably a library and time span, two arguments to the function that
you write.
And then, just as you interact with these widgets, it just recalls it with whatever the values are.
Exactly.
And then, the function itself returns a plot.
So, in this case, it's a plotly plot, right?
So, by default, we ship with support for mapplotlib, plotly, bokeh, and altair.
So, if I would create, like, a mapplotlib object, do all the stuff to it that I would do in a notebook,
instead of calling show, I just return it from my function, and then it becomes part of the UI?
Yep.
Okay.
Yeah, that seems pretty straightforward.
Yeah.
This one happens to be done with profit, a time series library.
Yeah, you've got integration with a bunch of cool machine learning libraries here as well.
Yeah, so, the cool thing is, pretty much, if you can write a Python function for it, like, it'll work with Gradio.
It really doesn't need to be, like, us as the development team don't really need to build that many integrations
to get anything that you're working with to work with Gradio.
Pretty much, if you can call a Reddip Python function to do it, and we have supported output types and stuff like that,
you can display it with Gradio.
Nice.
Yeah.
So, yeah, there's a couple of demos, for example, like, connecting to, like, databases and stuff.
You can connect to S3 if you wanted to, right?
Like, you're not...
Oh, interesting.
I don't know exactly where they are now, but yeah.
It's got to be one.
Yeah.
This looks like it might be one, potentially.
Yeah.
I'll click, I'll find some S3 stuff.
Here's, there's got to be someone here somewhere.
Yeah, very cool.
So, one of the things people may be wondering, and the fact that I don't see a pricing up at the top,
it might be a big hint here.
What's the business model?
What's the story with this?
Is this just straight open source?
Is it open core?
What's the story around your project here?
Gradio is completely open source, and you can host it anywhere, so you're not tied into
any platform.
Gradio did get acquired by Hugging Face maybe, like, almost two years ago, right?
So, Gradio integrates really tightly with the Hugging Face ecosystem, but...
Okay, I see.
Those integrations are normally free, right?
So, for example, you could host Gradio demos on...
On Hugging Face spaces or something?
Yeah.
On Hugging Face spaces, right?
And then if your demo needs special, like, hardware or stuff like that, like, you could pay
Hugging Face to provision that for you.
Sure.
But you're not paying for the Gradio.
You could use whatever you want on Hugging Face spaces now, right?
It doesn't have the Gradio.
Yeah, yeah.
So it's freely available.
So it's completely open source with kind of a Gradio as a service via Hugging Face.
Hugging Face.
Hugging Face, yeah.
Yeah.
On their spaces.
Say that fast a bunch of times.
So, yeah, really cool.
One of the things people might not know if they haven't heard of Gradio before is you go to
your GitHub repo for it.
Almost 21,000 GitHub stars.
A serious bit of attention that it's gotten.
We've seen a lot of growth in the last, yeah, about year and a half, like, ever since the
Hugging Face acquisition.
That's really helped us put the library in front of a new audience.
Yeah.
The recent advances in ML, like, a lot of people want to build demos for ML models now, right?
So I think that's definitely helping Gradio as well.
Yeah.
Trying to give people a sense of scale.
This is, like, third of FastAPI, third of Fast.
It's, like, that's a lot of people using this.
So the reason I'm bringing that up is it's not some brand new thing that you came up with
that maybe people could try, but it's got a lot of users, right?
Month to month, we're seeing, like, hundreds of thousands of people building these Gradio
demos repeatedly.
So, yeah, definitely a lot of growth.
And, yeah, Gradio is about five years old now, so it's not.
Awesome.
Congrats.
That's really cool.
That's nothing new.
Yeah, 3.9, almost 4 million monthly downloads.
That's a decent chunk.
This portion of Talk Python to Me is brought to you by Sentry.
You know that Sentry captures the errors that would otherwise go unnoticed.
Of course, they have incredible support for basically any Python framework.
They have direct integrations with Flask, Django, FastAPI, and even things like AWS Lambda and
Celery.
But did you know they also have native integrations with mobile app frameworks?
Whether you're building an Android or iOS app, or both, you can gain complete visibility
into your application's correctness, both on the mobile side and server side.
We just completely rewrote Talk Python's mobile apps for taking our courses, and we massively
benefited from having Sentry integration right from the start.
We used Flutter for our native mobile framework, and with Sentry, it was literally just two lines
of code to start capturing errors as soon as they happen.
Of course, we don't love errors, but we do love making our users happy.
Solving problems as soon as possible with Sentry on the mobile Flutter code and the Python server
side code together made understanding error reports a breeze.
So whether you're building Python server side apps, or mobile apps, or both, give Sentry a
try to get a complete view of your app's correctness.
Thank you to Sentry for sponsoring the show and helping us ship more reliable mobile apps
to all of you.
What do we think about, I don't want to do an imaging one.
You can do other demos you've got here, you've got time series forecasting, we talked about that
as the multiple inputs.
Yeah.
XGBoost with explainability.
Want to tell us about this a little bit?
Yeah.
This one also, I think, has like, this one has 12 inputs, right?
And the idea is it's one of these like kind of Kaggle-esque things where you like predict
income based on a slew of predictors, right?
And then the cool thing is that this isn't explicitly built into Gradio, or yeah, this isn't explicitly
built into Gradio, but you could hook into SHAP really easily, right?
So if you hit explain, it'll try to explain the prediction of the model and display it in a
plot for you.
Wow.
Okay.
Right.
So for those of you who don't know, SHAP is like this algorithm for explaining the predictions
of any machine learning model.
I see.
It's hooking into XGBoost, right?
But there isn't like an explicit, in this demo, there isn't like an explicit Gradio feature
that's being used.
It's just calling SHAP directly from this Python function and then displaying the results as
a plot.
The thing it does is it's got a bunch of different sliders and dropdowns.
It says given an age, your education level, years of school, whether you're married or not,
all those male, female, how many hours a week you work, and then it predicts, what is
this?
Yeah.
Predicts your yearly income.
And then the thing you're talking about is with that model, you can ask it, okay, well,
of all these different things we could put into it, what features, what aspects of that
are more important and what are less important, right?
Right.
Okay.
The use case is like, let's say like you are a data scientist that was charged with building
this kind of model.
The first question after someone seeing the prediction is someone might have is like, why?
Like, why is it predicting this?
Right.
And then you ideally want to be able to explain exactly what element of the predictors contributed
to the prediction the most.
And there's a lot of tools that you can use for that.
Right.
Shab is, I think, the most well-known to my understanding.
And then, yeah.
And then you can just with Gradio really easily just call that algorithm and then just display
it in a plot.
Right.
And then in this example, like one of the inputs is like the capital gain.
So like how much you make on your investments.
Right.
So, and I think in this particular case, like the capital gain is like really big.
Right.
So obviously because the capital gain is so big in this particular case, we predict that
the income will be really big.
Right.
Because capital gain is pretty much synonymous with income really.
So yeah.
Yeah.
So that's what this is showing.
Yeah.
And I suspect this is important for a lot of reasons.
If you're building this for your company or for some kind of project, people want to know,
well, we have all these different inputs.
what ones actually matter to making a prediction.
Maybe only the top three are the ones that really matter.
And you can throw out things like marital status.
Like it actually doesn't make much of a difference.
Right.
Or if you're a policy person and you're this model actually matches real data, you could
say, well, we're trying to improve the policy for a certain group of people.
We could focus on any of these aspects, which one or two would make the biggest return for
our effort to make a change.
Right.
There's a lot of cool stuff that comes out of this, I think.
And then you as a developer,
I think it's like the data scientist.
Right.
It's really easy to make this kind of thing.
Right.
This is like a GR.interface, I believe.
Right.
So this is just one line of code to build this.
So yeah, that's OK.
Not GR.interfaces.
The other API that we can talk about now is called blocks.
Yeah.
Tell us about that.
It's it's cool.
Yeah.
The way that it works is that you declaratively define your UI.
Right.
So it's like this input is going to go in this column and say, well, this input is like
a dropdown, for example.
Right.
So in this example, there's lots of dropdown components, lots of sliders for the age and
stuff like that.
And then you define all these components and then you can define the reactivity separately.
So if you were to scroll down, there should be like a button dot click.
Right.
So whenever the predict button gets clicked.
Yeah.
So you call this function with these inputs and then return this one thing.
Yeah.
So that's like the model.
Right.
Like right now, it looks like a lot of code just because there's a lot of like inputs and
stuff.
But at the end of the day, it's like pretty simple.
You're just defining a UI and then you define like what happens when and then Gradio handles
the rest.
Yeah.
It's pretty straightforward.
So people listen.
Basically, the UI for the more advanced version is you use context managers, create width blocks.
So then you'd say, here's something that goes across and with another row, put some columns
in there with another row.
And then that's how you build it up.
So it's pretty straightforward.
What it reminds me of a little bit is it reminds me a little of Flutter.
Are you familiar with how Flutter looks?
No.
And the code it's, I don't know if I can find a quick example.
How about an example Flutter?
Come on.
It's really sort of hierarchical.
So that the thing that I think is interesting is the code hierarchy matches the sort of UI hierarchy,
right?
So it's a code driven UI where as it gets more indented, that talks about, okay, well,
that's a row or then you pop off and stuff.
And they've got, it's real similar in that sense that all right there in the code, there's
not a designer or a markup language or something like that.
But yeah, pretty cool.
Yeah.
So like the UI is all declarative, right?
So yeah, like you said, you just say this is this row.
And then, yeah, there's ways to control like the relative width of each of these columns,
for example.
So if you wanted that, you could.
And then.
Another thing I saw, I can't remember which demo it is, so I'm not going to pull it up,
but I saw that there's a way to pass like CSS and styling over as well.
Is that right?
That was maybe the very first thing.
There's a Python API for like defining the theme, right?
So like every UI element has certain CSS variables and you can control their value via like the
values of this Python class that you then pass to your Gradio instance.
But at the same time, there's like a top level CSS parameter that you could do whatever you
want in that case.
You don't have to use like the Python API.
If you don't want to, if there's something different that you want to change, you can change
the CSS variables.
You're saying I could do something in Python.
I could say, well, the style is button order width is three and the color of the borders
is blue.
But if I just want to have arbitrary CSS, I can just go, here's your arbitrary CSS string.
Go with that.
You could pass it a file and then it'll, we'll read that file and use that CSS in the demo.
Yeah.
And then with that, you can also add IDs to each of the UI elements and then you could
write your CSS to target the IDs that you add, right?
So let's say you only wanted to modify like one button.
You could do it that way.
Right.
You just want to control one of the plots or something.
I guess if you're writing arbitrary code to return things like matplotlib plots, do things
like the XKCD matplotlib.
Oh yeah, for sure.
Right?
Like you could control.
Yeah.
Joking, but it's also awesome.
There's an XKCD Gradio theme, right?
So let me show you this.
There is?
Yes.
Okay.
That takes it to another level.
That's pretty excellent.
That's the cool thing about the theming is that it's shareable, right?
So someone built this XKCD theme.
Wow.
It's amazing.
Anyone can use this in their Gradio demo, right?
All you have to do is pass theme equals gstaff slash XKCD.
And then your demo will look like the XKCD theme.
It's so good.
I love it.
Oh my gosh.
This is.
Yeah.
Completely community driven.
Yeah.
Well done to whoever did this one.
That's really cool.
It goes beyond the plot, right?
You can for sure return a plot in the XKCD theme, but you could also have the whole demo in the
XKCD theme.
I often pull this example up, this theme, this XKCD thing for Matplotlib because it's fun.
But also I think there's genuine value in putting together something that looks like this.
Because if you show this to decision makers, bosses, managers, types, and they see that they look
at something that looks like it's working and they're like, oh, well, we're done then.
No, we have two months more work.
We're not done.
But I click the button and it's giving me answers.
We're really not done.
But it's not scalable.
It's not this.
It's not that, right?
It's only an estimate.
Just an XKCD front end on it.
You're like, look, you see it's not done.
It's just, it's got squiggly lines.
It's hand-drawn.
It's clearly a prototype.
Like, oh yeah, okay.
But I could see where this is going.
I think actually, psychologically, it may have a big impact, even though it's silly.
Yeah, it's a super interesting point.
I never thought about it that way.
But yeah, I mean, I think it definitely gives it a little bit more sketch vibe.
Like this is like in the...
Yeah, like a wireframe vibe.
Yeah.
Yeah, wireframe, like straight from the workshop.
Exactly.
Yeah.
That's what I was thinking because I presented projects to various stakeholders when I used
to do that kind of stuff.
And they'd be like, oh, well, that looks like it's done.
No, we're going to need some time because it's really not done.
I know it looks good, but it's not.
Yeah, yeah, yeah.
You made it look too good, basically.
Yeah, exactly.
That was a serious mistake.
Okay.
So we got a little bit more time to talk about a couple of things.
I want to talk about how people actually share this.
Like we're still talking about a thing I pip install locally and it has a UI, but what do
I do?
I still don't want to set up a Linux machine and Nginx and domains and all that.
So what are the options?
But before we get to that, tell us a bit about the internals.
Like when you guys work on Gradio and I pip install it, like what's running?
What is this project?
The backend is a FastAPI server.
So what Gradio will do, it'll spin up a server for you.
And then that server will serve like the front end assets.
The front end is built in Svelte.
Interesting.
Okay.
Basically, whenever you, whenever these reactivity events happen, what that'll happen is that,
or what will happen is that the front end will just call the backend API and then run your
function and then make sure that all the necessary processing that needs to happen to get your
data ready happens.
But at the end of the day, it's kind of a simple model in that sense, right?
Obviously there's some more complications with like the streaming, for example.
That's like a whole kind of different code path almost.
But at the end of the day, it's like a REST server that's talking with a JavaScript client.
So it's like the standard developer tools story for Python people is it's not, some of it
is Python, but you probably end up writing a lot of JavaScript or TypeScript to build this
tool for other people.
Right.
So they don't have to.
I'm not a huge Svelte expert.
I like, thankfully there's some of the people I work with are like really good at the really
knowledgeable and that stuff.
And yeah, like the front end code, I think it's, I think there's more Svelte code than
Python code.
Actually, I'm curious to put the.
What's the code breakdown?
Let's break it down.
Yeah.
65% Python, 16% Svelte, 13% TypeScript.
Well, so I think the reason might be that we have a lot of like demos and stuff.
Yeah.
I think there might be some stuff like that.
Yeah.
The demos are in there.
Yeah.
There's a lot of demos.
You know what feature GitHub needs?
As you navigate the source tree, right?
When I click on like client or demo or Gradio, it would be awesome if those stats would also
be repeated.
But just for that section of code, wouldn't that be great?
Like how much of the demos are Python?
I don't know.
Maybe I just want to know that, but that'd be cool.
Anyway.
Yeah.
So I suspect that is, there's probably a lot of code and you've got a lot of notebooks
and stuff in there too.
That probably puts a big change on it there.
A lot of the code is actually, yeah.
Yeah.
JavaScript Svelte.
Right.
It's the take one for the team.
So the rest of us don't have to write JavaScript.
Exactly.
Yeah.
Cool.
Interesting.
Very nice.
And it says it can be embedded in a notebook, which is interesting, or it can be presented
as a webpage.
Tell us about this part.
If you were to run this on any notebook, like Google Colab, for example, I think this might
be an example.
Right.
So if you call like the way that Gradio works, right?
Once you create your Gradio interface or blocks, once you call launch, that's how you start
up the server.
That's like you kick off the whole process of serving this.
That'll create the server locally.
Right.
So no data is like leaving your machine.
Right.
And then if you click, if you call launch on like a Jupyter notebook, Colab, SageMaker,
like the UI will display like in the notebook.
Right.
And then you could, if you're doing locally as well, you can go to the local host URL and
go to the server that way.
And then the really cool thing is that, yeah, there you go.
There's a UI.
That's what we mean that it's embedded locally.
It feels good.
Like a little bit like the iWidgets sort of thing.
It's similar to that, right?
Like it'll display right underneath the cell.
Right.
And then if you run the cell again, like you'll get like a new, like a new server basically.
Right.
So you can, you can iteratively build these things.
Right.
Is it running FastAPI somewhere in the background when you do that?
Yeah.
Crazy.
Yeah.
It's pretty, pretty nuts.
Turtles all the way down.
Yeah.
And then what we mean that they can be embedded in a notebook.
And then you could also like host it anywhere.
Right.
So you could, if your machine is exposed to the internet, right?
You have a fixed IP address.
You could just give people that URL.
You could also share it another way.
Right.
So every radio interface is like a launch method.
That's what kicks off the server.
And that takes a parameter called share.
Right.
So if you hit share equals through true, that'll create like a temporary link for 72 hours.
So you could share with someone.
Right.
So you don't have to, you could host it right on your laptop if you wanted to, as long as your
laptop.
As long as you leave it on.
Yeah.
As long as you leave it on, it's like not sleeping and stuff.
Like people can access your, if you go back to that collab notebook, I think we might be
able to like demo that.
Oh, interesting.
If I just say here and say share equals true and rerun it.
Equals true.
Let's see what we're getting.
So you see greater dot live.
Right.
So if you click that.
Totally works.
Yeah.
You can select that to whoever you want and they can just use this.
Right.
So that, yeah.
No install needed.
Right.
If you're sharing this with your collaborator, your PM, your manager, your friend or whatever,
you could just give them this link.
Right.
So you don't have to do anything.
I guess it's probably worth emphasizing.
You should never try to host like production.
So over this, it sounds like, cause it's only for a limited time and it's gonna, it's just
a gooey looking URL.
But so often you'll be in meetings over zoom or something else.
And they'll be like, Hey, what have you done?
Can you show me?
And then you're like, all right, well, let me do screen sharing.
Oh, I don't have, I'm not a host.
Can you make me a host now?
Can I, you're sharing, can I share?
And then finally you get it up and it's blocky and they're like, Oh, zoom in.
It's too small.
I'm on my phone.
This way you just take that and you give it to them in the meeting.
Right.
And they, they have a full fidelity thing they can play with, which is awesome.
They have the demo itself that's running on your machine.
Right.
So they don't have to.
Yeah.
Like no, you don't have to install anything.
Right.
Just go to your point, your browser at this URL.
And yeah, it'll work for that quick demo.
Yeah, exactly.
Use case as well.
Yeah.
Definitely don't use it for production.
Yeah.
If you wanted to use reproduction, I think like the easiest, the absolutely easiest way to use
hugging face spaces.
So if you go to hugging face spaces, it's basically like a drag and drop, right?
Like all you have to do is just drag your radio script into like their UI and then that'll
upload it.
And then radio will already be installed and then the server will, will start.
And then you have, you have your permanent hosting.
And then it's also like a, it has like a Git interface, right?
So like your demo has several files, like directory.
There's some assets, some images that you need that you want to upload as well.
Like you could just get pushed to your hugging face space and then you'll, you can do it like
that as well.
Okay.
So you add it as an origin or something and then just push to it.
Yeah.
I could try to show it.
I don't know if you can have a, can I share my screen?
I wonder.
Yeah, sure.
Click at the bottom and share.
It's easier if you share an app.
Yeah.
If I go to my hugging face account and go here and then new space, and then this is
talk Python demo, then MIT.
Oh yeah.
We can do whatever we want with this.
Right.
So you could, right.
You could host stream, like radio, Docker.
Yeah.
Anything you want.
Right.
So for free, very generous free tier, you have two CPUs.
That is a generous free tier.
Two CPU, 16 gigs.
Yeah, that is good.
The only caveat is that this will go to sleep after 72 hours if no one uses it.
Right.
So, but you could also upgrade.
You have a machine learning model, you need a GPU, you pay for the GPU per hour.
And then yeah, you can set public or private and then you just create space.
And then yeah, this is how the Git interface works.
Right.
So you could just get clone this and then add your code and then just get pushed.
Or you could just copy this.
Chop, copy the code and just paste it into a file.
Yeah.
Add file, create new file.
It does feel a very Git, right?
Even has the similar look and feel of like when you go to Git and you say add new file.
Yeah.
True.
A perfect commit message.
No, no comment.
Just blank.
I love it.
Yeah.
And then.
So over here, they run in Docker containers or Kubernetes or something like that.
The Docker container.
So what this is doing, it's that it's, it has like a pre-configured Gradio Docker image,
right?
That comes with, there we go.
It already built.
But it comes with Gradio and like a bunch of standard like data science libraries.
And then you write them in.
It'll, and then it adds your code to the container and then it starts a container.
Right.
But you could also just use your own Docker file if you wanted to.
Okay.
You could host whatever you want.
Right.
So here.
Yeah.
You got to put your name in a present.
Wow.
Look at that.
Hello, Michael.
Yeah.
In the time that we've been talking about this, you've created a space and created a
new UI and hosted it.
That's pretty ridiculous.
Yeah.
And then you could just share this.
Share the URL or whatever.
Yeah.
You can just share the URL there.
And then they have like a machine learning app that they can share to be used with, with,
they can share with anyone and it'll stay up.
It's just Git, right?
So if you have Git locally, if you know how to use Git, you can very seamlessly use, push
to the Hugging Face platform.
There's no special magic.
What if I'm not a hugger?
What if I, for some reason, don't want to use Hugging Face, can I post this behind Nginx
or somewhere if I like infrastructure, or I'd like to do my infrastructure as a service?
Just that app.py file.
Python.app.py from your cloud.
And then just make sure that the URL is, the port is accessible for the internet.
And then you just give that to everyone.
Or front that with Nginx and put some.
Yeah, exactly.
Let's encrypt and then just point it over to that URL and let it go.
It'd be pretty straightforward.
You could host it wherever you want.
It's just, it's all open source tech under the hood, right?
It's just FastAPI built and then some Python libraries, right?
There's no, there's no lock in anywhere, right?
Yeah, cool.
So it's probably running UVicorn, I would guess, as the server, which is production-ish.
I guess if you did like really large scale, you might want to do Genicorn with the UVicorn
workers or other than just UVicorn itself, but you know, for the failover and whatnot.
But that sounds like, if these words sound familiar to you, it should sound really familiar.
If they don't, then don't worry about it.
Exactly.
That's the standard Python web infrastructure stack type of stuff.
Right.
And in that model, it's completely free, right?
It's open source.
I can do, I can just run it there, right?
Yeah.
Just run it wherever you want.
Very nice.
Well, Freddie, let's wrap up our conversation, get a little short on time with just where
things are going.
We'll talk about where we are, where it came from, where are we going?
Thanks for that.
So I think where we are, so I think we're trying to get Gradio into like as many platforms as
possible, right?
So, and like as many kind of like deployment modes as possible.
So one of the cool projects that we're working on is Gradio Wasm, right?
So like running Gradio entirely in the browser.
Wow.
Okay.
So yeah, so that's, it's not ready, it's not released yet, but it's something that we're
actively working on, right?
So you can, yeah, so if you want to just build your machine learning demo, running everything
directly in the browser, right?
There's like the ML for the web space is growing a lot.
It's advancing really quickly.
Like we're getting ready.
We're getting ready for that.
So what's that look like in terms of foundations?
Is that Iodide?
Is that PyScript?
Is that something else?
It's using Pyodide right now.
Okay.
Yeah.
So yeah, that's how.
Yeah.
That's a pretty good choice because one of the selling points of Pyodide, not just that
it has Python in the browser, but that it has the ability, it has a bunch of the machine
learning libraries either available or compiled over to Wasm WebAssembly.
And so you can actually do machine learning stuff, not just like, hi, my name is plus name.
You know what I mean?
That's one of the cool projects we're working on this year.
The other cool project that we're working on is, yeah, like the custom components, right?
So let's say that you wanted to build your own custom machine learning demo, your own custom
web app, right?
But you need something that we don't have.
Giving you the API to build that component locally and then just hook it into the app without
having to like merge anything into Gradio upstream.
We're working on that actively.
So that'll be really exciting.
And then, yeah, really excited just because it'll enable like a lot of people like in the
creative community to collaborate with each other and build like really impressive stuff.
Yeah.
Kind of like on their own, right?
Like they don't need like, they don't need like the core development team necessarily.
Sure.
Like pytest plugins rather than trying to change pytest.
So that, yeah, really excited about that.
And then, yeah, the other cool stuff is that we're, one thing that we didn't talk about that
I would want to talk about if we have time is that all these demos that we've built
are sort of available via API, right?
So if you click on any of these demos, like if you click on that first one, if you scroll
to the bottom and you see it says use via API, right?
So this gives you like a little code snippet as to how you can call this demo from Python
or JavaScript.
Okay.
What does that mean, right?
That means that basically all these ML apps that are available on Huggy Face or just anywhere
on the internet, like they now become like building blocks that you can use in your
own workflow, right?
So, and actually this demo itself, I'm familiar with it.
It's actually really cool because it's calling two other Gradio demos via API, right?
So this is an example of someone building their Gradio app by calling other Gradio apps.
Wow.
Okay.
We're creating this ecosystem where...
It's like Gradio microservices.
Exactly.
Right.
So it's like all these Gradio apps are building blocks that you can then connect together via
API.
And that's really cool, right?
Because like it basically means that machine learning is available.
Like you don't need to use a GUI to get state-of-the-art machine learning, right?
You could like use an API and that means that you could put these models like pretty much
anywhere, right?
So like one of the cool things that we launched two weeks ago, I believe, or like a week and
a half ago is that you can deploy like a Gradio chatbot to Discord, like just one line of code,
right?
So if you, let's say if you have a Gradio app that talks with open AI, like GPT-3 or Llama
or any of these like open source LLMs, if you can build a Gradio app for it, you can like
seamlessly hook it into your Discord server, right?
So that's all built via this like API functionality, right?
So this is something like, I'm personally like super excited about it.
Like we want to push this further just because it's like Gradios that you like Gradio historically
has been built for the UI, but it can also be used to get these machine learning models into
more places.
One of the things that I'm really excited about in the coming years, making this a little
bit more, a little bit more visible and getting.
Yeah.
You could integrate some really cool LLMs and other types of chat into your Discord.
I imagine you could probably do it with a Slack as well.
And if somebody asks in your company, how do I, whatever you could think of go, Hey,
I've already, I'm private GPT.
I've already ingested all of our docs.
You want me to take a shot at answering that?
Like, sure.
Why not?
That's one of the pet projects I want to do is just do that for the Gradio Discord,
right?
So there's like a Gradio Discord where you could chat with the Gradio community and there's
like people ask questions in it, but it'd be really cool if we had a Gradio chat bot that
like knew a lot about Gradio that then you could just ask.
Exactly.
Chatbot slash Gradio chat.
Like, like how do I, whatever, how do I display a plot?
Right.
And then it'll tell you, just return a matplotlib from your function.
People could think, well, why don't I just use ChatGPT or something?
But these are the things you teach it like deeply about, you give it all the docs and you
say, study this.
And then I want to ask you about it.
Right.
And a lot of times the docs and other things go beyond the token level that the standard
models can take.
Like I've tried to get ChatGPT to tell me about transcripts on Talk Python and it can't even
adjust like one transcript before it runs out of space.
Like I can't quite load all that.
Well, that's, I wanted to ask you about all of them.
You can't even do one.
So this is not working for me.
Yeah.
So you could fine tune like an open source LLM and then host it wherever you want.
Right.
So.
Yes, exactly.
More control.
Yeah.
That's cool.
So you could teach all about Gradio.
Real quick question.
Mr.
Magnetic in the audience asks, what about a hugging face desktop app instead of the browser app?
Yeah.
So that's something that there's an open issue for that.
It's something that we've been kicking around as well.
It's just like, how do we get like a Gradio desktop app as well?
So yes, stay tuned.
I think let me try to find that issue and then comment on the YouTube.
But yeah, I would love your thoughts on that.
If anyone has thoughts on that.
But yeah, we, it's something we're thinking about.
It's not, I don't think it'll happen maybe in the next like month or two, but maybe before
the end of the year or next year, it could happen.
Excellent.
All right.
Well, I think that pretty well covers it.
It's a super exciting project.
So good luck with it.
I mean, already you've had a lot of luck with it.
So you don't need my wishes, but further good luck on that.
And yeah, before we get out of here, let me ask you a final question here.
If you're always asked, like to ask the guests or like some cool IPI project they've run across.
It's been really awesome.
Maybe not super popular, but has made a difference or you've, wow.
How did I not know about this?
Any come to mind for you?
Python project?
Yeah.
Something I can pip install like FastAPI, but not FastAPI.
Cause everyone knows that.
I think when I was just starting out, I think I, I was like a really big noob and like I always
ran into like environment issues.
And then a friend of mine showed me about like pip depth tree.
It shows you exactly like why things get installed.
And that's a good one.
Yeah.
I think it's really, I think it's really magical, honestly.
Yeah.
I think it's really helpful just to like figure out like, especially like when someone files
an issue and like they, we don't know what's wrong with them.
Like sometimes I'll just like, where did this thing even come from?
And then just use like pip depth tree.
I think that's, it's really cool.
And it's like really simple.
But yeah, I think it definitely has saved me a couple hours of time.
So.
It's cool.
I've used it for my own stuff.
I hadn't thought about using it for tech support, but yeah, of course, because then
people run into problems because their environments are screwed up and they say they have a thing
or they don't, or they say they have a version of a thing, but they don't.
And with this, you can just say, run this one command and it'll give you like a really
cool, they have all these things installed and this is installed because it's required.
Yeah, exactly.
It's really nice.
Yeah.
Cool.
Excellent recommendation.
All right.
Final call to action.
People want to get started with Gradio.
What do you tell them?
Hit install Gradio and then go to gradioapp.com and then get see the demos there.
In our website, there's a link to our discord server.
So yeah, join the discord and say hi.
And then yeah, there's lots of people there.
We're willing to help.
And then yeah, never hesitate to file an issue.
What's really cool about this is like seeing that the demos that people build and like
people build stuff that I frankly push the limits of what I thought people could build
with Gradio.
And it's really cool seeing that.
Yeah, that's awesome.
Don't be afraid to, or don't hesitate to build really cool stuff with Gradio and think, well,
we're really good about amplifying that.
So if you have something really cool, just like tag the Gradio Twitter account or reach
out to us on discord or something.
We'll amplify it for you.
Cool.
Well, excellent project.
And thank you for being on the show.
Thank you for having me, Michael.
I had a lot of fun.
Yeah, same.
This has been another episode of Talk Python to Me.
Thank you to our sponsors.
Be sure to check out what they're offering.
It really helps support the show.
The folks over at JetBrains encourage you to get work done with PyCharm.
PyCharm Professional understands complex projects across multiple languages and technologies.
So you can stay productive while you're writing Python code and other code like HTML or SQL.
Download your free trial at talkpython.fm/done with PyCharm.
Take some stress out of your life.
Get notified immediately about errors and performance issues in your web or mobile applications with
Sentry.
Just visit talkpython.fm/sentry and get started for free.
And be sure to use the promo code talkpython, all one word.
Want to level up your Python?
We have one of the largest catalogs of Python video courses over at Talk Python.
Our content ranges from true beginners to deeply advanced topics like memory and async.
And best of all, there's not a subscription in sight.
Check it out for yourself at training.talkpython.fm.
Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, the Google Play feed at /play,
and the direct RSS feed at /rss on talkpython.fm.
We're live streaming most of our recordings these days.
If you want to be part of the show and have your comments featured on the air,
be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
music
Thank you.