Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #640 user avatar #689

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions memberships/templates/memberships/humans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Tristan Bentham -- Front End Developer
Giulio Giunta -- Infrastructure Engineer Padawan
Sam Winterhalder -- Developer
Ali Gunes -- Developer

# THANKS

Expand Down
8 changes: 8 additions & 0 deletions memberships/user_avatar_component_ai/API_KEY.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
api_key = ""

# Add openai api key
# DO NOT MAKE API KEY PUBLIC
""" This will incur charges (as of writing this the fee should be 1/5th of a penny per image),
It might be possible to get a non-profit grant from openai OR
use new members donations to subsidize the avatar
"""
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions memberships/user_avatar_component_ai/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ai Avatar</title>
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<div class="card">
<img class="card-image" src="img_avatar.png" alt="Avatar">
<h3 style="text-align: center;">Your Avatar</h3>
<div class="container">
</div>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions memberships/user_avatar_component_ai/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# pip install pillow
# pip install openai

import openai
from API_KEY import api_key
import requests
from PIL import Image
from io import BytesIO

openai.api_key = api_key


def avatar_gen():
response = openai.Image.create(
prompt="the bust of a cool robot character from the shoulders up, facing forward",
n=1,
size="1024x1024",
)
image_url = response["data"][0]["url"]

# Download the image
img_data = requests.get(image_url).content
img = Image.open(BytesIO(img_data))

# Save the image as "img_avatar.png"
img.save("img_avatar.png", "PNG")


avatar_gen()
29 changes: 29 additions & 0 deletions memberships/user_avatar_component_ai/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.card {
/* Add shadows to create the "card" effect */
border-radius: 10px;
height: auto;
width: 300px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: 0.3s;
}

/* On mouse-over, add a deeper shadow */
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}

/* Add some padding inside the card container */
.container {
padding: 2px 16px;
}

#avatar {
/* Add styling for the avatar image */
width: 100%; /* To ensure it fills the card */
}

.card-image {
width:100%;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
openai==0.27.0
asgiref~=3.3
backports.functools-lru-cache>=1.6.4
beautifulsoup4==4.9.3
Expand Down
Loading