At 3tone Digital, we’re excited to unveil our latest Python project – the AI Website Critiquer. This innovative tool is for web designers and developers, offering automated, professional feedback on website designs.
Utilizing cutting-edge technology like OpenAI’s GPT-4 Vision model, the Website Critiquer streamlines the critique process, making it faster, more accurate, and highly efficient.
What Does Website Critiquer Do?
The Website Critiquer is a Python script specifically developed to capture screenshots of websites, convert these images into base64 format, and then leverage the power of OpenAI’s GPT-4 Vision model to analyze the images.
This analysis provides detailed, professional feedback to the designer, offering insights that were previously only achievable through manual review.
Breaking Down the Code
Let’s dive into the technical aspects of how the Website Critiquer operates:
- Importing Necessary Libraries: The script kicks off by importing essential Python libraries, including
subprocess
,os
,base64
,time
,errno
,pandas
, andselenium.webdriver
. These libraries lay the foundation for the script’s functionality. - OpenAI Client Initialization: To connect with OpenAI’s services, the script initializes the OpenAI client using
client = OpenAI()
. - Function
encode_image(image_path)
: This vital function takes an image path, reads the image file in binary mode, and returns its base64 encoding. In cases ofIOError
, the function is designed to wait for 0.1 seconds before retrying. - Function
generate_new_line(base64_image)
: This function processes a base64 encoded image and returns a list containing a dictionary. This dictionary forms a new line for the dialogue with the OpenAI model, with the role set to “user” and the content comprising a text prompt for the model and the base64 encoded image.
The Bigger Picture
The Website Critiquer is part of a larger system that reads URLs from a CSV file, navigates to each URL using Selenium WebDriver to capture screenshots, and then utilizes the OpenAI model for analysis.
The feedback generated is stored back into the CSV file, creating a seamless loop of data input and output.
Our goal with the Website Critiquer is to bring a new level of efficiency and precision to website design feedback.
By automating the critique process, we’re enabling designers to rapidly iterate and improve their work, backed by the analytical power of AI.