...

/

Building the Complete Pictionary Application

Building the Complete Pictionary Application

Learn how to create a complete pictionary application using Streamlit.

We have made some great progress with our pictionary application. We can now provide the player with a canvas to draw and show the model’s feedback on the drawing. However, most of this is possible due to the amazing widgets provided by Educative. What if we wanted to create our own application instead, like the one shown in the demo?

Our current application lacks a few elements:

  • We need a frontend where the player is given a description of the game, a canvas to draw on, and feedback from Gemini.

  • Since the goal is to make Gemini guess the drawing, we would need to track the time it takes the player to draw well enough for Gemini to guess. Tracking the time taken can be used as a performance measure. The lower, the better.

  • The word given to the player to draw must be random. This will keep the game interesting.

Hello Streamlit

Let’s focus on the frontend, as that will be the base for our application. The AI pictionary demo application shown earlier in the course is created using Streamlit. Streamlit is an open-source Python framework to create visual and interactive applications. It is very beginner-friendly and easy to set up. Streamlit can be installed using pip with the following command:

pip install streamlit

Once installed, it can be imported into Python code. To run a streamlit application, we use the following command:

streamlit run file_name.py

Let’s try some basic "Hello World" code in the widget below. It is set up with the dependencies preinstalled. The command to run the application has also been set up. You can simply use the “Run” button to start the application.

import streamlit as st

# Title for your app
st.title("Hello World!")

# Write a message to the user
st.write("This is my first Streamlit app!")
Hello World with Streamlit

Here’s what is happening in the solution code.

  • Line 1: We ...

Access this course and 1400+ top-rated courses and projects.