hitting openai limits. moving to other models
This commit is contained in:
5407
data/imageable_deduplicate.txt
Normal file
5407
data/imageable_deduplicate.txt
Normal file
File diff suppressed because it is too large
Load Diff
187
data/imageable_gpt_addition001.txt
Normal file
187
data/imageable_gpt_addition001.txt
Normal file
@@ -0,0 +1,187 @@
|
||||
candleholder
|
||||
sandbox
|
||||
scarf
|
||||
sandwich maker
|
||||
pencil sharpener
|
||||
telescope
|
||||
djembe
|
||||
laptop case
|
||||
cuckoo clock
|
||||
saddlebag
|
||||
matchbox
|
||||
marble
|
||||
dreamcatcher
|
||||
djembe
|
||||
paperclip
|
||||
notepad
|
||||
barrel
|
||||
hammock stand
|
||||
solar panel
|
||||
spyglass
|
||||
tote bag
|
||||
trophy
|
||||
typing paper
|
||||
tablecloth
|
||||
goblet
|
||||
castanets
|
||||
vaccine
|
||||
mug
|
||||
napkin ring
|
||||
book cover
|
||||
pocket watch
|
||||
merry-go-round
|
||||
stethoscope
|
||||
hockey stick
|
||||
yarn bowl
|
||||
garden gnome
|
||||
toaster oven
|
||||
garden hose
|
||||
kitchen timer
|
||||
cat tower
|
||||
trophy case
|
||||
calendula
|
||||
snorkel
|
||||
sconce
|
||||
passport holder
|
||||
wallet
|
||||
keychain
|
||||
pencil case
|
||||
ticket stub
|
||||
jigsaw puzzle
|
||||
quicksand model
|
||||
stress ball
|
||||
rolling pin
|
||||
toolbox
|
||||
canvas bag
|
||||
poinsettia
|
||||
spider plant
|
||||
whistle
|
||||
box cutter
|
||||
hologram
|
||||
belly pan
|
||||
compass rose
|
||||
screw
|
||||
cookie cutter
|
||||
pedal board
|
||||
sand kit
|
||||
piano bench
|
||||
merchandise tag
|
||||
post-it notes
|
||||
jacket hanger
|
||||
outdoor umbrella
|
||||
fishing pole
|
||||
sewing kit
|
||||
game board
|
||||
shovel
|
||||
tissue box
|
||||
bike lock
|
||||
harp
|
||||
vitamin organizer
|
||||
rain gauge
|
||||
fingerless gloves
|
||||
iris flowerpot
|
||||
binocular case
|
||||
daffodil bulb
|
||||
cookie box
|
||||
iron key
|
||||
chinaware
|
||||
houndstooth fabric
|
||||
candy jar
|
||||
clock tower
|
||||
potting soil
|
||||
tool belt
|
||||
wind chime
|
||||
whisk
|
||||
tea kettle
|
||||
blowtorch
|
||||
kite
|
||||
ramps
|
||||
bicycle basket
|
||||
Bluetooth speaker
|
||||
potpourri
|
||||
prom ticket
|
||||
violet bloom
|
||||
coin purse
|
||||
kettle
|
||||
beehive
|
||||
wooden block
|
||||
mobile
|
||||
fireplace tool set
|
||||
ballot box
|
||||
training wheels
|
||||
map stand
|
||||
letter opener
|
||||
sand timer
|
||||
zucchini boat
|
||||
bookmark
|
||||
gemstone
|
||||
wool blanket
|
||||
ratchet
|
||||
air pump
|
||||
wheelbarrow
|
||||
hurricane lantern
|
||||
fish bowl
|
||||
campfire
|
||||
alignment tool
|
||||
shadow box
|
||||
surfboard
|
||||
armchair
|
||||
umbrella stand
|
||||
earthenware pot
|
||||
screwdriver set
|
||||
curved ruler
|
||||
file cabinet
|
||||
sous vide
|
||||
tote
|
||||
business card holder
|
||||
phone case
|
||||
basketball hoop
|
||||
basket weave
|
||||
mist net
|
||||
marathon sticker
|
||||
child's chair
|
||||
wing span
|
||||
drain cover
|
||||
flashlight
|
||||
signal mirror
|
||||
battery pack
|
||||
jigsaw
|
||||
slicing knife
|
||||
protractor
|
||||
fleece vest
|
||||
dice
|
||||
sugar bowl
|
||||
hershey's kiss
|
||||
puzzle box
|
||||
dollhouse
|
||||
crocus bulb
|
||||
bike rack
|
||||
fishing tackle
|
||||
ladder
|
||||
chick feeder
|
||||
blood pressure monitor
|
||||
bass drum
|
||||
bracelet
|
||||
harvey balls
|
||||
eyelash curler
|
||||
tea strainer
|
||||
lantern
|
||||
garden stake
|
||||
barbecue grill
|
||||
pan flute
|
||||
reflective vest
|
||||
charming
|
||||
mousepad
|
||||
platter
|
||||
tuning fork
|
||||
filler
|
||||
drinking glass
|
||||
weather vane
|
||||
creamer
|
||||
table lamp
|
||||
fridge magnet
|
||||
tea infuser
|
||||
compass
|
||||
car mat
|
||||
toque
|
||||
hot water bottle
|
||||
87
data/imageable_gpt_addition002.txt
Normal file
87
data/imageable_gpt_addition002.txt
Normal file
@@ -0,0 +1,87 @@
|
||||
cervix
|
||||
cloche
|
||||
yardstick
|
||||
tea set
|
||||
skimmer
|
||||
incubator
|
||||
chalkboard
|
||||
trivet
|
||||
bird feeder
|
||||
telescope stand
|
||||
candle snuffer
|
||||
play-doh
|
||||
sunshade
|
||||
bead organizer
|
||||
pasta maker
|
||||
pencil holder
|
||||
garden trowel
|
||||
backpack
|
||||
toe ring
|
||||
musical box
|
||||
pillowcase
|
||||
computer stand
|
||||
popcorn maker
|
||||
pinwheel
|
||||
tool organizer
|
||||
paint roller
|
||||
hand mirror
|
||||
teakettle
|
||||
skirting board
|
||||
corkboard
|
||||
wristwatch
|
||||
notebook
|
||||
peeler
|
||||
letter tray
|
||||
giraffe figurine
|
||||
potted plant
|
||||
car seat
|
||||
reading lamp
|
||||
necklace stand
|
||||
seashell collection
|
||||
mountain bike
|
||||
sipper bottle
|
||||
sandcastle mold
|
||||
beehive
|
||||
casserole dish
|
||||
tap handle
|
||||
kitchen apron
|
||||
trowel
|
||||
sickle
|
||||
thermostat
|
||||
coyote statue
|
||||
beaded curtain
|
||||
pestle
|
||||
compost bin
|
||||
shaker
|
||||
kitchen scale
|
||||
yarn storage
|
||||
spigot
|
||||
dustpan
|
||||
hand sanitizer
|
||||
clothing rack
|
||||
root vegetable peeler
|
||||
camp chair
|
||||
utter
|
||||
netbook
|
||||
stopwatch
|
||||
t-tool
|
||||
fire pit
|
||||
breadbasket
|
||||
record player
|
||||
ship model
|
||||
tin can
|
||||
ladle
|
||||
ikebana vase
|
||||
floral arrangement
|
||||
purse organizer
|
||||
roadmap
|
||||
pencil sharpener
|
||||
cereal box
|
||||
insect house
|
||||
birdhouse
|
||||
hummingbird feeder
|
||||
coasters
|
||||
bubble wand
|
||||
umbrella
|
||||
swimming goggles
|
||||
canvas tarp
|
||||
1174
data/imageable_gpt_addition003.txt
Normal file
1174
data/imageable_gpt_addition003.txt
Normal file
File diff suppressed because it is too large
Load Diff
5700
data/imageable_gptfilter.txt
Normal file
5700
data/imageable_gptfilter.txt
Normal file
File diff suppressed because it is too large
Load Diff
22
main.py
Normal file
22
main.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from src.image_gen import image_style, icon_gen, Styles
|
||||
from src.llm_description_gen import describe_noun
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("./data/imageable_deduplicate.txt", "r") as fp:
|
||||
nouns = fp.read().split("\n")
|
||||
|
||||
for i in range(55, 100):
|
||||
noun = nouns[i]
|
||||
print(f"image {noun} {i}")
|
||||
description = describe_noun(noun)
|
||||
content = str(description.content).lower()
|
||||
if "invalid" in content:
|
||||
continue
|
||||
|
||||
description_styled = image_style(content, style=Styles.cartoon)
|
||||
output_dir = f"./output/test1/{noun}"
|
||||
icon_gen(description_styled, quality="hd", model="dall-e-3", output=Path(output_dir))
|
||||
with open(Path(output_dir) / "description.txt", "w") as fp:
|
||||
fp.write(description_styled)
|
||||
@@ -15,16 +15,16 @@ client = OpenAI()
|
||||
|
||||
|
||||
def image_style(base_prompt: str, style: Styles) -> str:
|
||||
return f"create {style.name} style of {base_prompt}"
|
||||
return f"create {style.name} style image on a white background: {base_prompt}"
|
||||
|
||||
def icon_gen(prompt: str, quality: Literal["hd", "standard"], output: Path = "./output/"):
|
||||
def icon_gen(prompt: str, quality: Literal["hd", "standard"], model: Literal["dall-e-3", "dall-e-2"], output: Path = "./output/"):
|
||||
# Make sure output directory exists
|
||||
output_path = Path(output) / quality
|
||||
output_path = Path(output) / model / quality
|
||||
output_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Generate the image using the OpenAI client
|
||||
response = client.images.generate(
|
||||
model="dall-e-3",
|
||||
model=model,
|
||||
prompt=prompt,
|
||||
size="1024x1024",
|
||||
quality=quality,
|
||||
@@ -48,5 +48,6 @@ def icon_gen(prompt: str, quality: Literal["hd", "standard"], output: Path = "./
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dog_emoji = image_style("dog in a hat on a beach with a drink", style=Styles.cartoon)
|
||||
icon_gen(dog_emoji, output=Path("../output"), quality="hd")
|
||||
base_prompt = "A playful, cartoon-style dog icon featuring a round, fluffy body in a warm golden-brown color. The dog has oversized, expressive black eyes and a happy, open mouth showing its tongue out. Two large floppy ears hang down on either side of its head, each with a slightly darker brown color on the inside. The tail is wagging and curved upwards, represented by a simple, thick shape in the same golden-brown. The background is a light blue with a subtle oval shape to make the dog stand out boldly. This design uses strong shapes and clear contrasts for easy recognition in a small format."
|
||||
dog_emoji = image_style(base_prompt, style=Styles.cartoon)
|
||||
icon_gen(dog_emoji, model="dall-e-3", output=Path("../output/test"), quality="hd")
|
||||
|
||||
88
src/llm_description_gen.py
Normal file
88
src/llm_description_gen.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from openai import OpenAI
|
||||
client = OpenAI()
|
||||
|
||||
|
||||
def describe_noun(noun: str) -> str:
|
||||
completion = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You will describe an art piece based on a noun provided by the user. "
|
||||
"The description should be suitable for creating a cartoon-like, emoji-style, or minimalist SVG design that functions effectively as an icon. "
|
||||
"Since the icon will be small, focus on bold, simple details that make the image visually distinctive and easy to recognize. "
|
||||
"Emphasize strong shapes, clear contrasts, and vibrant colors to ensure the design is memorable and stands out at a small scale. "
|
||||
"Your response will feed directly into a text-to-image model like DALL·E 3, so provide precise and concrete visual descriptions "
|
||||
"(e.g., 'a bright red apple with a single green leaf and a shiny highlight on one side'). Avoid unnecessary complexity or fine details that may be lost when scaled down. "
|
||||
"If the word provided is not a noun or is inappropriate, respond with 'invalid'"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": noun
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
return completion.choices[0].message
|
||||
|
||||
|
||||
def filter_nouns(noun_list: str) -> str:
|
||||
completion = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You will be given a list of nouns. "
|
||||
"Your job is to remove nouns that are can't be made into an image or are inappropriate. "
|
||||
"Your output must be a list of nouns delimited by newlines."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": noun_list
|
||||
}
|
||||
]
|
||||
)
|
||||
return completion.choices[0].message
|
||||
|
||||
def add_nouns(noun_list: str) -> str:
|
||||
completion = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You will be given a list of nouns. "
|
||||
"Your job is to add as many new nouns as possible. "
|
||||
"The nouns must been objects that can be made into images. "
|
||||
"Nouns must also be appropriate for all ages so nothing graphic or violent. "
|
||||
"The nouns you add must be new nouns. No duplicates. "
|
||||
"Your output must be a list of nouns delimited by newlines with no additional context. "
|
||||
"Your output should only be the new nouns you can think of so your response should not contain any of the input nouns. "
|
||||
"If you can't think of any new nouns reply with 'DONE'. "
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": noun_list
|
||||
}
|
||||
]
|
||||
)
|
||||
return completion.choices[0].message
|
||||
|
||||
|
||||
def deduplicate(nouns_list: list[str]) -> list[str]:
|
||||
return list(set([noun.strip() for noun in nouns_list]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
#completion = describe_noun("blank")
|
||||
with open('../data/imageable_gptfilter.txt', 'r') as fp:
|
||||
nouns = fp.read()
|
||||
|
||||
with open('../data/imageable_deduplicate.txt', 'w') as fp:
|
||||
fp.write("\n".join(deduplicate(nouns.split("\n"))))
|
||||
|
||||
#completion = add_nouns(noun_list=nouns)
|
||||
|
||||
#output_file = '../data/imageable_gpt_addition003.txt'
|
||||
#with open(output_file, 'w') as fp:
|
||||
# fp.write(completion.content)
|
||||
# print(f"written to {output_file}")
|
||||
|
||||
Reference in New Issue
Block a user