Introducci贸n y Fundamentos del NLP
Procesamiento de Lenguaje Natural
Configuraci贸n del Entorno y Exploraci贸n de Datos
Preprocesamiento Inicial
Quiz: Introducci贸n y Fundamentos del NLP
T茅cnicas Tradicionales de NLP para Documentos Empresariales
Tokenizaci贸n, Stemming y Lematizaci贸n
Visualizaci贸n y generaci贸n de nubes de palabras
Representaci贸n Vectorial: Bag-of-Words y TF-IDF
Extracci贸n de T茅rminos Clave y Modelado de Temas
Clasificaci贸n Tradicional para An谩lisis de Sentimientos y Categor铆as
Quiz: T茅cnicas Tradicionales de NLP para Documentos Empresariales
Introducci贸n y Profundizaci贸n en Transformers para Aplicaciones Empresariales
Fundamentos de Transformers y su Relevancia en NLP
Tokenizaci贸n Avanzada con Transformers y Hugging Face
Uso de Modelos Preentrenados de Transformers para Clasificaci贸n
Reconocimiento de Entidades (NER) en Documentos Corporativos con Transformers
Fine-Tuning de Transformers para Datos Empresariales
Quiz: Introducci贸n y Profundizaci贸n en Transformers para Aplicaciones Empresariales
Proyecto Final y Estrategia Comercial B2B
Desarrollo y Prototipado de la Aplicaci贸n Empresarialparte 1
Desarrollo y Prototipado de la Aplicaci贸n Empresarialparte 2
Despliegue del proyecto en Hugging Face
You don't have access to this class
Keep learning! Join and start boosting your career
Creating graphical interfaces for artificial intelligence products may seem like a complex task that requires advanced frontend development skills. However, with tools such as Gradio, it is possible to transform AI functionalities into interactive visual applications with just a few lines of code. This library allows us to focus on what is really important: the logic of our models, while the visual components are generated automatically.
Gradio is a library that allows us to create graphical interfaces for artificial intelligence applications quickly and easily. Its main advantage is that it provides us with pre-designed components such as buttons, text fields and viewers, without the need to worry about design details such as colors, borders or styles.
To start using Gradio, we must first install it:
# Installing Gradiopip install gradio.
Once installed, we can import it into our code:
import gradio as gr
Gradio offers several components that we can use to build our interface:
These components are organized by blocks, which allow us to structure our application in a logical and visually appealing way.
The basic structure of a Gradio application is based on blocks containing different components. Let's see how we can create an application for analyzing Mercado Libre reviews:
# interface creationwith gr.Blocks(theme="citrus") as demo: gr.Markdown("## Analysis application")
with gr.Tabs(): with gr.TabItem("Text analysis"): gr.Markdown("### Enter a text review") input_text = gr.Textbox(label="Review text", placeholder="Write the review here") sentiment_output = gr.JSON(label="Sentiment") entities_output = gr.JSON(label="Entities") analyze_button = gr.Button("Analyze text")
analyze_button.click( fn=analyze_text, inputs=input_text, outputs=[sentiment_output, entities_output] )
with gr.TabItem("CSV parse"): file_input = gr.File(label="Load CSV") sentiment_csv_output = gr.JSON(label="Sentiment parse") entities_csv_output = gr.JSON(label="Entity parse") wordcloud_output = gr.Image(label="Word cloud") analyze_csv_button = gr.Button("Analyze CSV")
analyze_csv_button.click( fn=analyze_csv, inputs=file_input, outputs=[sentiment_csv_output, entities_csv_output, wordcloud_output] )
In this example, we have created an application with two tabs:
Gradio offers different themes to customize the look and feel of our application. In the example, we use the "citrus" theme that provides yellow colors that match Mercado Libre's visual identity:
with gr.Blocks(theme="citrus") as demo: # Application content.
Other available themes include variants with pink, light blue and green colors, allowing us to adapt the interface to different aesthetic needs.
The real magic of Gradio is in how it connects the visual components with our processing functions. This is achieved through the click()
method of the buttons:
analyze_button.click( fn=analyze_text, inputs=input_text, outputs=[sentiment_output, entities_output])
This code indicates that when the analyze_button
is clicked, the analyze_text
function will be executed, taking as input the value of input_text
and displaying the results in sentiment_output
and entities_output
.
It is important to note that a single function can generate multiple outputs, as we see in the example where analyze_text
returns both sentiment and entities analysis.
Once our interface is configured, we can launch it with:
demo.launch(debug=True).
The debug=True
parameter is especially useful during development, as it allows us to see additional errors and messages in the console.
When we execute this code, Gradio provides us with a temporary URL that will be available for 72 hours, allowing us to access our application from any device, as long as our program is still running.
If clicking on the URL does not bring up the graphical interface, a common solution is to stop the process and relaunch the application with demo.launch().
The application can be used directly from the development environment (such as Google Colab) or in full screen by accessing the link provided. However, it is important to remember that if we close the notebook or stop the execution, the URL will stop working.
Gradio allows us to quickly transform our AI functionalities into interactive visual products, facilitating the demonstration and use of our models. Have you used Gradio for any project? Share your experience in the comments and tell us what kind of interfaces you have created with this tool.
Contributions 0
Questions 0
Want to see more contributions, questions and answers from the community?