top of page

Generative AI Virtual Background Creator

In this project, I wrote a Python script which uses OpenAI's API to generate a virtual background for a user tailored to their color palette (skin, clothes, jewelry, etc.) captured in a frame. This rids of the monotonous, uninteresting virtual backgrounds of the WFH environment! 

Skills & Tools: Python, Artificial Intelligence, Generative AI, Color Theory, NumPy, ColorThief, OpenAI, Prompt Writing

Project Overview

I wanted to test out the powers of generative AI with this project, while also applying them to my interests in artistic design! When run, the script opens the camera app on the user's device. When ready, the user presses the space bar, followed by the ESC key, to close the app and activate the heart of the program. Using imports from rembg and color thief, the program visually isolates the user's own person from their background. The palette of this isolated image is defined by identifying the 5 most dominant colors in the frame. Using their respective RGB values, each color's complement is identified, in addition to the two analogous colors for the frame's dominant color. The RGB values are then converted into natural language via the CSS color registry. Using predefined natural language prompts set by the user, the script utilizes the integrated OpenAI API to generate different backgrounds in accordance to the original, complementary, and analogous color schemes. For example, "a realistic nature scene with the following colors: {cname1} and {cname2}" would generate a photo of a nature scene containing the two most dominant photos captured in the frame. The script also outputs a list of each complementary, analogous, and original set of colors. When using their own API key, users are free to download the images and use them as a virtual background! Say goodbye to the days of ugly, standard virtual meeting backgrounds, or that even uglier blurred one! 

Example Input & Output

Screenshot 2023-07-26 at 10.03.29 PM.png

(above) example frame isolation of user.

Screenshot 2023-07-26 at 9.57.42 PM.png
Screenshot 2023-07-26 at 9.58.25 PM.png
Screenshot 2023-07-26 at 9.59.13 PM.png

(above) example pallet generated from frame above.

(above) Color ID output: "The analogous colors are burlywood and palevioletred. The complementary colors are sandybrown and darkslategray. The original colors are darkslateblue and tan." The backgrounds show above are examples of the analogous and complementary backgrounds generated from the original pallet from the prompt "an artistic design with the following colors: (analogous 1/complementary 1) and (analogous 2/complementary 2).

Documentation

Screenshot 2023-07-26 at 10.11.23 PM.png
Screenshot 2023-07-26 at 10.11.53 PM.png
Screenshot 2023-07-26 at 10.12.08 PM.png
Screenshot 2023-07-26 at 10.12.24 PM.png
Screenshot 2023-07-26 at 10.12.44 PM.png
Screenshot 2023-07-26 at 10.12.53 PM.png
bottom of page