Spaces:
Runtime error
Runtime error
Commit
·
8b147f3
1
Parent(s):
8f0c3a9
Pet Generator Functioning
Browse files- Dockerfile +3 -1
- __pycache__/card_generator.cpython-310.pyc +0 -0
- __pycache__/item_dict_gen.cpython-310.pyc +0 -0
- __pycache__/user_input.cpython-310.pyc +0 -0
- card_generator.py +17 -34
- item_dict_gen.py +194 -73
- main.py +144 -216
- user_input.py +0 -22
Dockerfile
CHANGED
@@ -158,4 +158,6 @@ USER user
|
|
158 |
# Set the entrypoint
|
159 |
EXPOSE 8000
|
160 |
|
161 |
-
ENTRYPOINT ["python", "main.py"]
|
|
|
|
|
|
158 |
# Set the entrypoint
|
159 |
EXPOSE 8000
|
160 |
|
161 |
+
ENTRYPOINT ["python", "main.py"]
|
162 |
+
|
163 |
+
<lora:CyborgsXL:..3> <lora:RBTS_STYLE:.2> <lora:ral-fluff:1.3> <lora:zhibi:.5>
|
__pycache__/card_generator.cpython-310.pyc
CHANGED
Binary files a/__pycache__/card_generator.cpython-310.pyc and b/__pycache__/card_generator.cpython-310.pyc differ
|
|
__pycache__/item_dict_gen.cpython-310.pyc
CHANGED
Binary files a/__pycache__/item_dict_gen.cpython-310.pyc and b/__pycache__/item_dict_gen.cpython-310.pyc differ
|
|
__pycache__/user_input.cpython-310.pyc
CHANGED
Binary files a/__pycache__/user_input.cpython-310.pyc and b/__pycache__/user_input.cpython-310.pyc differ
|
|
card_generator.py
CHANGED
@@ -23,15 +23,8 @@ test_item = {'Name': 'Pustulent Raspberry', 'Type': 'Fruit', 'Value': '1 cp', 'P
|
|
23 |
# Function that takes in an image url and a dictionary and uses the values to print onto a card.
|
24 |
def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_width, img_height, purchased_item_key = None):
|
25 |
|
26 |
-
<<<<<<< HEAD
|
27 |
# Check for if item has a Rarity string that is in the dictionary of sticker paths
|
28 |
-
|
29 |
-
# Check for if item has a Rarity string that is a in the dictionary of sticket paths
|
30 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
31 |
-
if purchased_item_key:
|
32 |
-
if sticker_path[purchased_item_key]:
|
33 |
-
sticker_path = sticker_path[purchased_item_key]
|
34 |
-
else: sticker_path = sticker_path['Default']
|
35 |
|
36 |
# Load the image to paste
|
37 |
image_to_paste = Image.open(sticker_path)
|
@@ -49,20 +42,19 @@ def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_w
|
|
49 |
# Paste the resized image onto the base image
|
50 |
base_image.paste(image_to_paste_resized, paste_position, image_to_paste_resized)
|
51 |
|
52 |
-
def render_text_on_card(image_path,
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
# Card Properties
|
62 |
image_list = []
|
63 |
-
|
64 |
-
|
65 |
-
output_image_path = f"./{item_name}.png"
|
66 |
print(f"Saving image to {output_image_path}")
|
67 |
font_path = "./fonts/Balgruf.ttf"
|
68 |
italics_font_path = './fonts/BalgrufItalic.ttf'
|
@@ -77,12 +69,7 @@ def render_text_on_card(image_path, item_name,
|
|
77 |
type_center_position = (384, 545)
|
78 |
type_area_width = 600
|
79 |
type_area_height = 45
|
80 |
-
type_text =
|
81 |
-
if len(item_weight) >= 1:
|
82 |
-
type_text = type_text + ' '+ item_weight
|
83 |
-
|
84 |
-
if len(item_damage) >= 1 :
|
85 |
-
type_text = type_text + ' '+ item_damage
|
86 |
|
87 |
# Description box properties
|
88 |
description_position = (105, 630)
|
@@ -101,28 +88,24 @@ def render_text_on_card(image_path, item_name,
|
|
101 |
|
102 |
# open image and render text
|
103 |
image = u.open_image_from_url(image_path)
|
104 |
-
image = rend.render_text_with_dynamic_spacing(image,
|
105 |
image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
|
106 |
-
image = rend.render_text_with_dynamic_spacing(image,
|
107 |
paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
|
108 |
-
image = rend.render_text_with_dynamic_spacing(image, item_value, value_position, value_area_width, value_area_height,font_path,initial_font_size)
|
109 |
-
image = rend.render_text_with_dynamic_spacing(image, item_quote, quote_position, quote_area_width, quote_area_height,italics_font_path,initial_font_size, quote = True)
|
110 |
#Paste Sizzek Sticker
|
111 |
-
paste_image_and_resize(image, sticker_path_dictionary,x_position= 0,y_position=909, img_width= 115, img_height= 115, purchased_item_key=
|
112 |
|
113 |
# Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
|
114 |
image = image.filter(ImageFilter.GaussianBlur(.5))
|
115 |
image_list.append(image)
|
116 |
|
117 |
-
image = image.save(f"./output/{
|
118 |
|
119 |
|
120 |
|
121 |
return image_list
|
122 |
|
123 |
|
124 |
-
#render_text_on_card('./card_templates/Shining Sunset Border.png',test_item )
|
125 |
-
|
126 |
|
127 |
|
128 |
|
|
|
23 |
# Function that takes in an image url and a dictionary and uses the values to print onto a card.
|
24 |
def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_width, img_height, purchased_item_key = None):
|
25 |
|
|
|
26 |
# Check for if item has a Rarity string that is in the dictionary of sticker paths
|
27 |
+
#Sticker = sticker_path['Default']
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# Load the image to paste
|
30 |
image_to_paste = Image.open(sticker_path)
|
|
|
42 |
# Paste the resized image onto the base image
|
43 |
base_image.paste(image_to_paste_resized, paste_position, image_to_paste_resized)
|
44 |
|
45 |
+
def render_text_on_card(image_path, pet_name,
|
46 |
+
pet_species,
|
47 |
+
pet_breed,
|
48 |
+
pet_fur,
|
49 |
+
pet_intelligence,
|
50 |
+
pet_affection,
|
51 |
+
pet_energy,
|
52 |
+
pet_noise,
|
53 |
+
pet_play) :
|
54 |
# Card Properties
|
55 |
image_list = []
|
56 |
+
pet_properties = f"Intelligence : {pet_intelligence} \n Affection : {pet_affection} \n Energy : {pet_energy} \n Noise : {pet_noise} \n Play : {pet_play}"
|
57 |
+
output_image_path = f"./{pet_name}.png"
|
|
|
58 |
print(f"Saving image to {output_image_path}")
|
59 |
font_path = "./fonts/Balgruf.ttf"
|
60 |
italics_font_path = './fonts/BalgrufItalic.ttf'
|
|
|
69 |
type_center_position = (384, 545)
|
70 |
type_area_width = 600
|
71 |
type_area_height = 45
|
72 |
+
type_text = f"{pet_breed} Color and Fur : {pet_fur}"
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Description box properties
|
75 |
description_position = (105, 630)
|
|
|
88 |
|
89 |
# open image and render text
|
90 |
image = u.open_image_from_url(image_path)
|
91 |
+
image = rend.render_text_with_dynamic_spacing(image, pet_name, title_center_position, title_area_width, title_area_height,font_path,initial_font_size)
|
92 |
image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
|
93 |
+
image = rend.render_text_with_dynamic_spacing(image, pet_properties, description_position, description_area_width, description_area_height,font_path,initial_font_size, description = True)
|
94 |
paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
|
|
|
|
|
95 |
#Paste Sizzek Sticker
|
96 |
+
paste_image_and_resize(image, sticker_path_dictionary['Default'],x_position= 0,y_position=909, img_width= 115, img_height= 115, purchased_item_key= None)
|
97 |
|
98 |
# Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
|
99 |
image = image.filter(ImageFilter.GaussianBlur(.5))
|
100 |
image_list.append(image)
|
101 |
|
102 |
+
image = image.save(f"./output/{pet_name}.png")
|
103 |
|
104 |
|
105 |
|
106 |
return image_list
|
107 |
|
108 |
|
|
|
|
|
109 |
|
110 |
|
111 |
|
item_dict_gen.py
CHANGED
@@ -3,7 +3,7 @@ import ast
|
|
3 |
import gc
|
4 |
import torch
|
5 |
|
6 |
-
model_path = "
|
7 |
# Add variable for User Style prompt ie GPT4 User
|
8 |
# Add variable for end of input and response name ie <|end_of_turn|>GPT4 Assistant:
|
9 |
# Make prompt a variable
|
@@ -66,8 +66,8 @@ prompt_instructions = """ **Purpose**: Generate a structured inventory entry for
|
|
66 |
1. Replace `{pet}` with the name of the user pet, DO NOT CHANGE THE USER pet NAME enclosed in single quotes (e.g., `'Magic Wand'`).
|
67 |
2. Ensure your request is formatted as a hashmap.
|
68 |
3. The cybernetic pets are friendly and cute, they are products and toys.
|
69 |
-
4. The
|
70 |
-
5. The
|
71 |
8. Value should be assigned as an integer of copper pieces (cp), silver pieces (sp), electrum pieces (ep), gold pieces (gp), and platinum pieces (pp).
|
72 |
|
73 |
|
@@ -75,112 +75,233 @@ prompt_instructions = """ **Purpose**: Generate a structured inventory entry for
|
|
75 |
- **Dictionary Structure**:
|
76 |
|
77 |
{"{Pet}": {
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
- **Input Placeholder**:
|
91 |
- "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
|
|
|
92 |
|
93 |
**Output Examples**:
|
94 |
1. Mignon the Toy Sized Chihuahua
|
95 |
|
96 |
-
{
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
106 |
}
|
107 |
|
108 |
|
109 |
2. Marmalade the Austrailian Shepherd Herding Dog
|
110 |
|
111 |
-
{
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
120 |
}
|
121 |
|
122 |
3. Holden Clawfield the Pembroke Welsh Corgi Herding Dog
|
123 |
|
124 |
{“Holden Clawfield”:{
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
“
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
133 |
}
|
134 |
|
135 |
4. Tyr the Great Pyr the Great Pyreness Working Dog
|
136 |
|
137 |
{“Tyr the Great Pyr”:{
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
146 |
}
|
147 |
|
148 |
5. Emperor Maximus the Great Dane Working Dog
|
149 |
|
150 |
{“Emperor Maximus”:{
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
“
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
159 |
}
|
160 |
|
161 |
6. Becks the Airedale Terrier Dog
|
162 |
|
163 |
{“Becks”:{
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
“
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
172 |
}
|
173 |
|
174 |
7. Blue Carolina the Plott Hound
|
175 |
|
176 |
{“Blue Carolina”:{
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
"""
|
|
|
3 |
import gc
|
4 |
import torch
|
5 |
|
6 |
+
model_path = "models/starling-lm-7b-alpha.Q8_0.gguf"
|
7 |
# Add variable for User Style prompt ie GPT4 User
|
8 |
# Add variable for end of input and response name ie <|end_of_turn|>GPT4 Assistant:
|
9 |
# Make prompt a variable
|
|
|
66 |
1. Replace `{pet}` with the name of the user pet, DO NOT CHANGE THE USER pet NAME enclosed in single quotes (e.g., `'Magic Wand'`).
|
67 |
2. Ensure your request is formatted as a hashmap.
|
68 |
3. The cybernetic pets are friendly and cute, they are products and toys.
|
69 |
+
4. The descriptions should be brief and puncy, or concise and in the voice of a judge at a high end cat or dog or pet exhibition such as the American Kennel Clube or Cat Fancier and make specific callout of how mild, and well camoflaughed the artificiality of the cybernetic pet is.
|
70 |
+
5. The Image Prompt MUST be inside double quotations ie " ".
|
71 |
8. Value should be assigned as an integer of copper pieces (cp), silver pieces (sp), electrum pieces (ep), gold pieces (gp), and platinum pieces (pp).
|
72 |
|
73 |
|
|
|
75 |
- **Dictionary Structure**:
|
76 |
|
77 |
{"{Pet}": {
|
78 |
+
"Name": '{Pet Name}',
|
79 |
+
"Pet Species": '{pet species}',
|
80 |
+
"Breed": '{pet breed},
|
81 |
+
"Fur" : "The colors and quality of the pet's fur,
|
82 |
+
"Intelligence Level" : "How intelligent the pet is and how it demonstrates it",
|
83 |
+
"Affection Level" : "How affectionate and how the pet shows it,
|
84 |
+
"Energy Level" : "The Energy level",
|
85 |
+
"Noise Level" : "The volume, frequency, triggers, and type",
|
86 |
+
"Play Level" : " The level of play and types enjoyed",
|
87 |
+
"Image Prompt" : "Descriptive imagery for an image generator"
|
88 |
+
}
|
89 |
|
90 |
- **Input Placeholder**:
|
91 |
- "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
|
92 |
+
|
93 |
|
94 |
**Output Examples**:
|
95 |
1. Mignon the Toy Sized Chihuahua
|
96 |
|
97 |
+
{'Mignon': {
|
98 |
+
"Name": "Mignon”
|
99 |
+
"Pet Species": Dog,
|
100 |
+
"Breed" : ”Chihuahua (Toy)”,
|
101 |
+
"Fur" : “Cream, smooth shorthair”,
|
102 |
+
"Intelligence Level" : “Medium-high, tr'inable but stubborn”,
|
103 |
+
"Affection Level" : “High but selective, prefers favorite humans”,
|
104 |
+
"Energy Level" : “High”,
|
105 |
+
"Noise Level" : “Very high, yappy”,
|
106 |
+
"Play Level" : “Low“, Fetch, chase“
|
107 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) Chihuahua, boasting a luscious cream coat and an attitude that's equal parts feisty and affectionate. Note the subtle glow behind her eyes, a hint of advanced biometrics enhancing her already keen senses."
|
108 |
}
|
109 |
|
110 |
|
111 |
2. Marmalade the Austrailian Shepherd Herding Dog
|
112 |
|
113 |
+
{'Marmalade':{
|
114 |
+
"Name":"Marmalade",
|
115 |
+
"Breed" : ”Australian Shepherd (Herding)”,
|
116 |
+
"Pet Species": Dog,
|
117 |
+
"Fur" : “Blue merle with white markings and tan points, medium double coat”,
|
118 |
+
"Intelligence Level" : “Very high, suitable for jobs”,
|
119 |
+
"Affection Level" : “High”,
|
120 |
+
"Energy Level" : “Very high”,
|
121 |
+
"Noise Level" : “Medium, piercing”,
|
122 |
+
"Play Level" : “Very high, Agility, herding, obedience, frisbee, puzzles”,
|
123 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) an Australian Shepherd of impeccable breeding, showcasing a stunning blue merle coat and the intelligence to match."
|
124 |
}
|
125 |
|
126 |
3. Holden Clawfield the Pembroke Welsh Corgi Herding Dog
|
127 |
|
128 |
{“Holden Clawfield”:{
|
129 |
+
"Name" : "Holden Clawfield",
|
130 |
+
"Breed" : ”Pembroke Welsh Corgi (Herding)”,
|
131 |
+
"Pet Species": Dog,
|
132 |
+
"Fur" : “Fawn with white markings, short double coat”,
|
133 |
+
"Intelligence Level" : “High, trainable',
|
134 |
+
"Affection Level" : “Very high, loves humans and other Pets”,
|
135 |
+
"Energy Level" : “High”,
|
136 |
+
"Noise Level" : “High, piercing”,
|
137 |
+
"Play Level" : “High, Toys, herding, obedience”,
|
138 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) a Pembroke Welsh Corgi of noble bearing, flaunting a rich fawn coat and an endearing personality."
|
139 |
}
|
140 |
|
141 |
4. Tyr the Great Pyr the Great Pyreness Working Dog
|
142 |
|
143 |
{“Tyr the Great Pyr”:{
|
144 |
+
"Name" : "Tyr the Great Pyr",
|
145 |
+
"Breed" : ”Great Pyrenees (Working)”,
|
146 |
+
"Pet Species": Dog,
|
147 |
+
"Fur" : “White, medium double coat”,
|
148 |
+
"Intelligence Level" : “Medium, trainable to a point”,
|
149 |
+
"Affection Level" : “Medium, wary of strangers”,
|
150 |
+
"Energy Level" : “Low, mostly lazy but vigilant”,
|
151 |
+
"Noise Level" : “Medium, will bark to alert”,
|
152 |
+
"Play Level" : “Medium, not motivated by play, Toys, treats”,
|
153 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar)a Great Pyrenees of regal demeanor, White, medium double coat and an air of quiet confidence. Playing with a toy"
|
154 |
}
|
155 |
|
156 |
5. Emperor Maximus the Great Dane Working Dog
|
157 |
|
158 |
{“Emperor Maximus”:{
|
159 |
+
"Name" : "Emperor Maximus",
|
160 |
+
"Breed" : ”Great Dane (Working)”,
|
161 |
+
"Pet Species": Dog,
|
162 |
+
"Fur" : “Black and white with black mask, smooth shorthair”,
|
163 |
+
"Intelligence Level" : “Medium, trainable”,
|
164 |
+
"Affection Level" : “Very high, needy”,
|
165 |
+
"Energy Level" : “Medium, enjoys hiking”,
|
166 |
+
"Noise Level" : “Medium, will bark to alert”,
|
167 |
+
"Play Level" : “Medium, Chase, tug”,
|
168 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) a Great Dane of imposing stature, Black and white with black mask, smooth shorthair and a gentle giant's disposition."
|
169 |
}
|
170 |
|
171 |
6. Becks the Airedale Terrier Dog
|
172 |
|
173 |
{“Becks”:{
|
174 |
+
"Name" : "Becks",
|
175 |
+
"Breed" : ”Airedale Terrier (Terrier)”,
|
176 |
+
"Pet Species": Dog,
|
177 |
+
"Fur" : “Black and tan, medium wiry coat”,
|
178 |
+
"Intelligence Level" : “Medium, respond well to training”,
|
179 |
+
"Affection Level" : “Medium, reserved”,
|
180 |
+
"Energy Level" : “High, alert and active”,
|
181 |
+
"Noise Level" : “Medium, vigilant watchdog”,
|
182 |
+
"Play Level" : “Medium, Fetch, toys, treats”,
|
183 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) an Airedale Terrier of rugged charm, displaying a handsome black and tan coat and a reserved yet."
|
184 |
}
|
185 |
|
186 |
7. Blue Carolina the Plott Hound
|
187 |
|
188 |
{“Blue Carolina”:{
|
189 |
+
"Name": "Blue Carolina"
|
190 |
+
"Breed" : ”Plott Hound (Hound)”,
|
191 |
+
"Pet Species": Dog,
|
192 |
+
"Fur" : “Chocolate brindle, smooth shorthair”,
|
193 |
+
"Intelligence Level" : “High, driven and trainable”,
|
194 |
+
"Affection Level" : “High, very sweet”,
|
195 |
+
"Energy Level" : “High, alert and active”,
|
196 |
+
"Noise Level" : “Medium, will bark to alert”,
|
197 |
+
"Play Level" : “Medium, more active than playful, Toys, frisbee, chase”,
|
198 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot dog) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) Blue Carolina, a Plott Hound of athletic build, showcasing a rich chocolate brindle coat and a high-energy personality.
|
199 |
+
}
|
200 |
+
|
201 |
+
8. Sekhmet the Sphynx Cat
|
202 |
+
{“Sekhmet”:{
|
203 |
+
"Name" : "Sekhmet",
|
204 |
+
"Breed" : “Sphynx”,
|
205 |
+
"Pet Species" : "Cat",
|
206 |
+
"Fur" : “Hairless, light brown”,
|
207 |
+
"Intelligence Level" : “High, trainable',
|
208 |
+
"Affection Level" : “High but selective, prefers favorite human”,
|
209 |
+
"Energy Level" : “Low, reserved”,
|
210 |
+
"Noise Level" : “Low, mostly quiet”,
|
211 |
+
"Play Level" : “Low, lazy, Cuddling, lap time, shoulder perching”,
|
212 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar)Sphynx Cat, Hairless, light brown Cuddling, lap time, shoulder perching."
|
213 |
+
}
|
214 |
+
|
215 |
+
9. Smith the American Shorthair Cat
|
216 |
+
|
217 |
+
{“Smith”:{
|
218 |
+
"Name" : "Smith",
|
219 |
+
"Breed" : “American Shorthair”,
|
220 |
+
"Pet Species" : "Cat",
|
221 |
+
"Fur" : “Black”,
|
222 |
+
"Intelligence Level" : “Medium, somewhat trainable”,
|
223 |
+
"Affection Level" : “High, loves humans and other Pets”,
|
224 |
+
"Energy Level" : “Medium”,
|
225 |
+
"Noise Level" : “Low, infrequent meows”,
|
226 |
+
"Play Level" : “Medium, Belly rubs, hunting, toys”,
|
227 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur)(Glowing pet collar) American Shorthair Black Fur playing with a toy"
|
228 |
+
}
|
229 |
+
|
230 |
+
10. Catherine of Atagon and Her Royal Highness Elizabth I
|
231 |
+
|
232 |
+
{“Catherine of Aragon and Her Royal Highness Elizabeth I”:{
|
233 |
+
"Name" : "Catherine of Aragon and Her Royal Highness Elizabeth I",
|
234 |
+
"Breed" : “British Shorthair”,
|
235 |
+
"Pet Species" : "Cat",
|
236 |
+
"Fur" : “Brown and black tortoise shell, black and silver tabby”,
|
237 |
+
"Intelligence Level" : “Medium, not int'rested in training”,
|
238 |
+
"Affection Level" : “Medium-low, independent”,
|
239 |
+
"Energy Level" : “Low, very lazy”,
|
240 |
+
"Noise Level" : “Medium, will speak their minds”,
|
241 |
+
"Play Level" : “Low, not interested in play, Treats, naps, perching/observing”,
|
242 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) British Shorthair, Brown and black tortoise shell, black and silver tabby perched on a table"
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
11. Kitsune the Cream Flame Point Longhair Ragdoll
|
247 |
+
|
248 |
+
{“Kitsune”:{
|
249 |
+
"Name" : "Kitsune",
|
250 |
+
"Breed" : “Ragdoll”,
|
251 |
+
"Pet Species" : "Cat",
|
252 |
+
"Fur" : “Cream flame point, longhair”,
|
253 |
+
"Intelligence Level" : “Low, slow to learn”,
|
254 |
+
"Affection Level" : “High, loves attention”,
|
255 |
+
"Energy Level" : “High, always moving”,
|
256 |
+
"Noise Level" : “Medium, chirpy meows”,
|
257 |
+
"Play Level" : “High, will play with anything or anyone, Toys, catnip, running, cuddling”,
|
258 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Ragdoll Cream flame point, longhair stretching "
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
12. Blucifer the Russian Blue Shorthair
|
263 |
+
|
264 |
+
{“Blucifer”:{
|
265 |
+
"Name" : "Blucifer",
|
266 |
+
"Breed" : “Russian Blue”,
|
267 |
+
"Pet Species" : "Cat",
|
268 |
+
"Fur" : “Blue-gray, smooth shorthair”,
|
269 |
+
"Intelligence Level" : “High, very trainable”,
|
270 |
+
"Affection Level" : “Medium, selectively affectionate”,
|
271 |
+
"Energy Level" : “Medium, more alert than active”,
|
272 |
+
"Noise Level" : “Low, almost silent”,
|
273 |
+
"Play Level" : “Low, more active than playful, Treats, lap time”,
|
274 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Russian Blue with Blue-gray smooth shorthair, curled up in a lap "
|
275 |
}
|
276 |
+
|
277 |
+
12. Dirk Thuderpaw the Maine Coon with Brown Stripes
|
278 |
+
{'Dirk Thunderpaw':{
|
279 |
+
"Name" : "Dirk Thunderpaw",
|
280 |
+
"Breed" : “Maine Coon”,
|
281 |
+
"Pet Species" : "Cat",
|
282 |
+
"Fur" : “Brown stripes, white face, dense longhair”,
|
283 |
+
"Intelligence Level" : “Medium, trainable”,
|
284 |
+
"Affection Level" : “Medium, affectionate with most people”,
|
285 |
+
"Energy Level" : “Low, will spring to alertness”,
|
286 |
+
"Noise Level" : “Low, rarely meows”,
|
287 |
+
"Play Level" : “Medium, more interested in training, Hunting”,
|
288 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Maine Coon Brown stripes, white face, dense longhair hunting a toy "
|
289 |
+
}
|
290 |
+
|
291 |
+
13. Scrambles Mcgee, Esquire the Gray Persian With Thick Longhair
|
292 |
+
|
293 |
+
{'Scrambles McGee Esquire':{
|
294 |
+
"Name" : "Scrambles McGee Esquire",
|
295 |
+
"Breed" : “Persian,
|
296 |
+
"Pet Species" : "Cat",
|
297 |
+
"Fur" : “Gray, thick longhair”,
|
298 |
+
"Intelligence Level" : “Low, not interested in training”,
|
299 |
+
"Affection Level" : “Low, very selectively affectionate”,
|
300 |
+
"Energy Level" : “Low, very lazy”,
|
301 |
+
"Noise Level" : “High, frequent meows”,
|
302 |
+
"Play Level" : “Low, very lazy, Naps, lap time, treats”,
|
303 |
+
"Image Prompt" : "An elegant masterpiece drawing of a ( beautiful subtle nuanced glowing biomimicry bionic robot cat) (glowing eyes)(glowing chest)(thick healthy fur) (Glowing pet collar) Persian Gray with thick longhair, very lazy napping "
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
"""
|
main.py
CHANGED
@@ -13,94 +13,78 @@ M_MMAP_THRESHOLD = -3
|
|
13 |
|
14 |
# Set malloc mmap threshold.
|
15 |
libc.mallopt(M_MMAP_THRESHOLD, 2**20)
|
16 |
-
initial_name = "
|
17 |
|
18 |
with gr.Blocks() as demo:
|
19 |
|
20 |
# Functions and State Variables
|
21 |
# Build functions W/in the Gradio format, because it only allows modification within it's context
|
22 |
# Define inputs to match what is called on click, and output of the function as a list that matches the list of outputs
|
23 |
-
textbox_default_dict = {'Name':'',
|
24 |
-
'
|
25 |
-
'
|
26 |
-
'
|
27 |
-
'
|
28 |
-
'
|
29 |
-
'
|
30 |
-
'
|
31 |
-
'
|
32 |
-
'
|
33 |
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
selected_border_image = gr.State('./card_templates/Moonstone Border.png')
|
47 |
num_image_to_generate = gr.State(4)
|
48 |
generated_image_list = gr.State([])
|
49 |
selected_generated_image = gr.State()
|
50 |
selected_seed_image = gr.State()
|
51 |
built_template = gr.State()
|
52 |
-
|
53 |
|
54 |
def set_textbox_defaults(textbox_default_dict, key):
|
55 |
-
|
56 |
-
return
|
57 |
-
<<<<<<< HEAD
|
58 |
-
|
59 |
|
60 |
# Function called when user generates item info, then assign values of dictionary to variables, output once to State, twice to textbox
|
61 |
def generate_text_update_textboxes(user_input):
|
62 |
u.reclaim_mem()
|
63 |
|
64 |
llm_output=useri.call_llm(user_input)
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
item_description = llm_output[item_key[0]]['Description']
|
90 |
-
item_quote = llm_output[item_key[0]]['Quote']
|
91 |
-
|
92 |
-
sd_prompt = llm_output[item_key[0]]['SD Prompt']
|
93 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
94 |
-
return [item_name, item_name,
|
95 |
-
item_type, item_type,
|
96 |
-
item_rarity, item_rarity,
|
97 |
-
item_value, item_value,
|
98 |
-
item_properties, item_properties,
|
99 |
-
item_damage, item_damage,
|
100 |
-
item_weight, item_weight,
|
101 |
-
item_description, item_description,
|
102 |
-
item_quote, item_quote,
|
103 |
-
sd_prompt, sd_prompt]
|
104 |
|
105 |
# Called on user selecting an image from the gallery, outputs the path of the image
|
106 |
def assign_img_path(evt: gr.SelectData):
|
@@ -117,13 +101,13 @@ with gr.Blocks() as demo:
|
|
117 |
img2img.image_list.clear()
|
118 |
|
119 |
# Called when pressing button to generate image, updates gallery by returning the list of image URLs
|
120 |
-
def generate_image_update_gallery(num_img,
|
121 |
delete_temp_images()
|
122 |
print(type(built_template))
|
123 |
image_list = []
|
124 |
-
img_gen, prompt = img2img.load_img_gen(
|
125 |
for x in range(num_img):
|
126 |
-
preview = img2img.preview_and_generate_image(x,img_gen, prompt, built_template,
|
127 |
image_list.append(preview)
|
128 |
yield image_list
|
129 |
del preview
|
@@ -143,73 +127,44 @@ with gr.Blocks() as demo:
|
|
143 |
</p>
|
144 |
</div>""")
|
145 |
|
146 |
-
=======
|
147 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
148 |
gr.HTML(""" <div id="inner"> <header>
|
149 |
<h2><b>First:</b> Build a Card Template</h2>
|
150 |
</div>""")
|
151 |
with gr.Row():
|
152 |
-
<<<<<<< HEAD
|
153 |
with gr.Column():
|
154 |
-
=======
|
155 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
gr.HTML(""" <div id="inner"> <header>
|
186 |
-
<h3>2. Click a image from the Seed Image Gallery</h3><br>
|
187 |
-
</div>""")
|
188 |
-
border_gallery.select(assign_img_path, outputs = selected_border_image)
|
189 |
-
|
190 |
-
seed_image_gallery = gr.Gallery(label= " Image Seed Gallery",
|
191 |
-
scale = 2,
|
192 |
-
value = useri.index_image_paths("./seed_images/item_seeds/","item_seeds/"),
|
193 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
194 |
-
show_label = True,
|
195 |
-
columns = [3], rows = [3],
|
196 |
-
object_fit = "contain",
|
197 |
-
height = "auto",
|
198 |
-
elem_id = "Template Gallery",
|
199 |
-
<<<<<<< HEAD
|
200 |
-
interactive=True)
|
201 |
-
=======
|
202 |
-
interactive=True)
|
203 |
-
|
204 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
205 |
|
206 |
gr.HTML(""" <div id="inner"> <header><h4> -Or- Upload your own seed image, by dropping it into the 'Generated Template Gallery' </h4><br>
|
207 |
<h3>3. Click 'Generate Card Template'</h3><br>
|
208 |
</div>""")
|
209 |
-
<<<<<<< HEAD
|
210 |
-
=======
|
211 |
-
|
212 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
213 |
|
214 |
built_template_gallery = gr.Gallery(label= "Generated Template Gallery",
|
215 |
scale = 1,
|
@@ -223,10 +178,6 @@ with gr.Blocks() as demo:
|
|
223 |
|
224 |
seed_image_gallery.select(assign_img_path, outputs = selected_seed_image)
|
225 |
built_template_gallery.upload(u.receive_upload, inputs=built_template_gallery, outputs= selected_seed_image)
|
226 |
-
<<<<<<< HEAD
|
227 |
-
=======
|
228 |
-
|
229 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
230 |
build_card_template_button = gr.Button(value = "Generate Card Template")
|
231 |
build_card_template_button.click(build_template, inputs = [selected_border_image, selected_seed_image], outputs = [built_template_gallery, built_template])
|
232 |
|
@@ -234,56 +185,54 @@ with gr.Blocks() as demo:
|
|
234 |
<h2><b>Second:</b> Generate Item Text </h2>
|
235 |
</div>""")
|
236 |
gr.HTML(""" <div id="inner"> <header>
|
237 |
-
<h3>1. Use a
|
238 |
</div>""")
|
239 |
with gr.Row():
|
240 |
-
|
241 |
-
=======
|
242 |
-
|
243 |
-
|
244 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
245 |
-
user_input = gr.Textbox(label = 'Item', lines =1, placeholder= "Flaming Magical Sword", elem_id= "Item", scale =4)
|
246 |
item_text_generate = gr.Button(value = "Generate item text", scale=1)
|
247 |
|
248 |
gr.HTML(""" <div id="inner"> <header>
|
249 |
<h3> 2. Review and Edit the text</h3>
|
250 |
</div>""")
|
251 |
with gr.Row():
|
252 |
-
<<<<<<< HEAD
|
253 |
-
|
254 |
-
# Build text boxes for the broken up item dictionary values
|
255 |
|
256 |
# Build text boxes for the broken up item dictionary values
|
257 |
with gr.Column(scale = 1):
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
with gr.Column(scale = 1):
|
262 |
-
|
263 |
-
|
264 |
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
|
270 |
|
271 |
# Pass the user input and border template to the generator
|
272 |
with gr.Column(scale = 1):
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
-
=======
|
282 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
283 |
gr.HTML(""" <div id="inner"> <header>
|
284 |
<h3> 3. This text will be used to generate the card's image.</h3>
|
285 |
</div>""")
|
286 |
-
|
287 |
|
288 |
gr.HTML(""" <div id="inner"> <header>
|
289 |
<h2> <b>Third:</b> Click 'Generate Cards' to generate 4 cards to choose from. </h2>
|
@@ -308,63 +257,47 @@ with gr.Blocks() as demo:
|
|
308 |
)
|
309 |
generate_final_item_card = gr.Button(value = "Add Text", elem_id = "Generate user card")
|
310 |
|
311 |
-
|
312 |
-
|
313 |
-
=======
|
314 |
-
|
315 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
316 |
-
card_gen_button.click(fn = generate_image_update_gallery, inputs =[num_image_to_generate,item_sd_prompt_output,item_name_output,built_template], outputs= generate_gallery)
|
317 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
318 |
|
319 |
# Button logice calls function when button object is pressed, passing inputs and passing output to components
|
320 |
llm_output = item_text_generate.click(generate_text_update_textboxes,
|
321 |
inputs = [user_input],
|
322 |
-
outputs= [
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
<<<<<<< HEAD
|
344 |
-
|
345 |
-
=======
|
346 |
-
|
347 |
-
|
348 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
349 |
generate_final_item_card.click(card.render_text_on_card, inputs = [selected_generated_image,
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
],
|
360 |
outputs = generate_gallery )
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
=======
|
365 |
-
|
366 |
-
|
367 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
368 |
if __name__ == '__main__':
|
369 |
demo.launch(server_name = "0.0.0.0", server_port = 8000, share = False, allowed_paths = ["/media/drakosfire/Shared/","/media/drakosfire/Shared/MerchantBot/card_templates"])
|
370 |
|
@@ -373,11 +306,6 @@ if __name__ == '__main__':
|
|
373 |
|
374 |
|
375 |
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
|
382 |
|
383 |
|
|
|
13 |
|
14 |
# Set malloc mmap threshold.
|
15 |
libc.mallopt(M_MMAP_THRESHOLD, 2**20)
|
16 |
+
initial_name = "Sekhmet the Sphinx Cat"
|
17 |
|
18 |
with gr.Blocks() as demo:
|
19 |
|
20 |
# Functions and State Variables
|
21 |
# Build functions W/in the Gradio format, because it only allows modification within it's context
|
22 |
# Define inputs to match what is called on click, and output of the function as a list that matches the list of outputs
|
23 |
+
textbox_default_dict = {'Name':'',
|
24 |
+
'Pet Species': '',
|
25 |
+
'Breed':'',
|
26 |
+
'Fur':'',
|
27 |
+
'Intelligence Level':'',
|
28 |
+
'Affection Level':'',
|
29 |
+
'Energy Level':'',
|
30 |
+
'Noise Level':'',
|
31 |
+
'Play Level':'',
|
32 |
+
'image Prompt':''
|
33 |
}
|
34 |
+
# Text states
|
35 |
+
pet_name_state = gr.State()
|
36 |
+
pet_species_state = gr.State()
|
37 |
+
pet_breed_state = gr.State()
|
38 |
+
pet_fur_state = gr.State()
|
39 |
+
pet_intelligence_level_state = gr.State()
|
40 |
+
pet_affection_level_state = gr.State()
|
41 |
+
pet_energy_level_state = gr.State()
|
42 |
+
pet_noise_level_state = gr.State()
|
43 |
+
pet_play_level_state = gr.State()
|
44 |
+
image_prompt_var = gr.State('')
|
45 |
+
|
46 |
+
# Image States
|
47 |
selected_border_image = gr.State('./card_templates/Moonstone Border.png')
|
48 |
num_image_to_generate = gr.State(4)
|
49 |
generated_image_list = gr.State([])
|
50 |
selected_generated_image = gr.State()
|
51 |
selected_seed_image = gr.State()
|
52 |
built_template = gr.State()
|
53 |
+
|
54 |
|
55 |
def set_textbox_defaults(textbox_default_dict, key):
|
56 |
+
pet_name = textbox_default_dict[key]
|
57 |
+
return pet_name
|
|
|
|
|
58 |
|
59 |
# Function called when user generates item info, then assign values of dictionary to variables, output once to State, twice to textbox
|
60 |
def generate_text_update_textboxes(user_input):
|
61 |
u.reclaim_mem()
|
62 |
|
63 |
llm_output=useri.call_llm(user_input)
|
64 |
+
pet_key = list(llm_output.keys())
|
65 |
+
#This is for creating a list of key values in the returned hashmap to search for specific keys.
|
66 |
+
# pet_key_values = list(llm_output[pet_key[0]].keys())
|
67 |
+
pet_name = llm_output[pet_key[0]]['Name']
|
68 |
+
pet_species = llm_output[pet_key[0]]['Pet Species']
|
69 |
+
pet_breed = llm_output[pet_key[0]]['Breed']
|
70 |
+
pet_fur = llm_output[pet_key[0]]['Fur']
|
71 |
+
pet_intelligence_level = llm_output[pet_key[0]]['Intelligence Level']
|
72 |
+
pet_affection_level = llm_output[pet_key[0]]['Affection Level']
|
73 |
+
pet_energy_level = llm_output[pet_key[0]]['Energy Level']
|
74 |
+
pet_noise_level = llm_output[pet_key[0]]['Noise Level']
|
75 |
+
pet_play_level = llm_output[pet_key[0]]['Play Level']
|
76 |
+
image_prompt = llm_output[pet_key[0]]['Image Prompt']
|
77 |
+
|
78 |
+
return [pet_name, pet_name,
|
79 |
+
pet_species, pet_species,
|
80 |
+
pet_breed, pet_breed,
|
81 |
+
pet_fur, pet_fur,
|
82 |
+
pet_intelligence_level, pet_intelligence_level,
|
83 |
+
pet_affection_level, pet_affection_level,
|
84 |
+
pet_energy_level, pet_energy_level,
|
85 |
+
pet_noise_level, pet_noise_level,
|
86 |
+
pet_play_level, pet_play_level,
|
87 |
+
image_prompt, image_prompt]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
# Called on user selecting an image from the gallery, outputs the path of the image
|
90 |
def assign_img_path(evt: gr.SelectData):
|
|
|
101 |
img2img.image_list.clear()
|
102 |
|
103 |
# Called when pressing button to generate image, updates gallery by returning the list of image URLs
|
104 |
+
def generate_image_update_gallery(num_img, image_prompt,pet_name, built_template):
|
105 |
delete_temp_images()
|
106 |
print(type(built_template))
|
107 |
image_list = []
|
108 |
+
img_gen, prompt = img2img.load_img_gen(image_prompt, pet_name)
|
109 |
for x in range(num_img):
|
110 |
+
preview = img2img.preview_and_generate_image(x,img_gen, prompt, built_template, pet_name)
|
111 |
image_list.append(preview)
|
112 |
yield image_list
|
113 |
del preview
|
|
|
127 |
</p>
|
128 |
</div>""")
|
129 |
|
|
|
|
|
130 |
gr.HTML(""" <div id="inner"> <header>
|
131 |
<h2><b>First:</b> Build a Card Template</h2>
|
132 |
</div>""")
|
133 |
with gr.Row():
|
|
|
134 |
with gr.Column():
|
|
|
|
|
135 |
|
136 |
+
# Template Gallery instructions
|
137 |
+
gr.HTML(""" <div id="inner"> <header>
|
138 |
+
<h3>1. Click a border from the 'Card Template Gallery'</h3>
|
139 |
+
</div>""")
|
140 |
+
|
141 |
+
border_gallery = gr.Gallery(label = "Card Template Gallery",
|
142 |
+
scale = 2,
|
143 |
+
value = useri.index_image_paths("Drakosfire/CardGenerator", "seed_images/card_templates"),
|
144 |
+
show_label = True,
|
145 |
+
columns = [3], rows = [3],
|
146 |
+
object_fit = "contain",
|
147 |
+
height = "auto",
|
148 |
+
elem_id = "Template Gallery")
|
149 |
+
with gr.Column():
|
150 |
+
gr.HTML(""" <div id="inner"> <header>
|
151 |
+
<h3>2. Click a image from the Seed Image Gallery</h3><br>
|
152 |
+
</div>""")
|
153 |
+
|
154 |
+
border_gallery.select(assign_img_path, outputs = selected_border_image)
|
155 |
+
seed_image_gallery = gr.Gallery(label= " Image Seed Gallery",
|
156 |
+
scale = 2,
|
157 |
+
value = useri.index_image_paths("Drakosfire/CardGenerator", "seed_images/item_seeds"),
|
158 |
+
show_label = True,
|
159 |
+
columns = [3], rows = [3],
|
160 |
+
object_fit = "contain",
|
161 |
+
height = "auto",
|
162 |
+
elem_id = "Template Gallery",
|
163 |
+
interactive=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
gr.HTML(""" <div id="inner"> <header><h4> -Or- Upload your own seed image, by dropping it into the 'Generated Template Gallery' </h4><br>
|
166 |
<h3>3. Click 'Generate Card Template'</h3><br>
|
167 |
</div>""")
|
|
|
|
|
|
|
|
|
168 |
|
169 |
built_template_gallery = gr.Gallery(label= "Generated Template Gallery",
|
170 |
scale = 1,
|
|
|
178 |
|
179 |
seed_image_gallery.select(assign_img_path, outputs = selected_seed_image)
|
180 |
built_template_gallery.upload(u.receive_upload, inputs=built_template_gallery, outputs= selected_seed_image)
|
|
|
|
|
|
|
|
|
181 |
build_card_template_button = gr.Button(value = "Generate Card Template")
|
182 |
build_card_template_button.click(build_template, inputs = [selected_border_image, selected_seed_image], outputs = [built_template_gallery, built_template])
|
183 |
|
|
|
185 |
<h2><b>Second:</b> Generate Item Text </h2>
|
186 |
</div>""")
|
187 |
gr.HTML(""" <div id="inner"> <header>
|
188 |
+
<h3>1. Use a name, a breed, some coloring and the animal type, Ex: 'Hermione the Stormy Grey English Shorthair Cat' then click 'Generate Text' </h3>
|
189 |
</div>""")
|
190 |
with gr.Row():
|
191 |
+
user_input = gr.Textbox(label = 'Item', lines =1, placeholder= "Sekhmet the Sphinx Cat", elem_id= "Item", scale =4)
|
|
|
|
|
|
|
|
|
|
|
192 |
item_text_generate = gr.Button(value = "Generate item text", scale=1)
|
193 |
|
194 |
gr.HTML(""" <div id="inner"> <header>
|
195 |
<h3> 2. Review and Edit the text</h3>
|
196 |
</div>""")
|
197 |
with gr.Row():
|
|
|
|
|
|
|
198 |
|
199 |
# Build text boxes for the broken up item dictionary values
|
200 |
with gr.Column(scale = 1):
|
201 |
+
pet_name_output = gr.Textbox(value = set_textbox_defaults(
|
202 |
+
textbox_default_dict, 'Name'),label = 'Name', lines = 1, interactive=True, elem_id='Pet Name')
|
|
|
|
|
|
|
|
|
203 |
|
204 |
+
pet_species_output = gr.Textbox(value = set_textbox_defaults(
|
205 |
+
textbox_default_dict, 'Pet Species'),label = 'Type', lines = 1, interactive=True, elem_id='Pet Species')
|
206 |
+
|
207 |
+
pet_breed_output = gr.Textbox(value = set_textbox_defaults(
|
208 |
+
textbox_default_dict, 'Breed'),label = 'Breed : [Common, Uncommon, Rare, Very Rare, Legendary]',
|
209 |
+
lines = 1, interactive=True, elem_id='Pet Breed')
|
210 |
+
|
211 |
+
pet_fur_output = gr.Textbox(value = set_textbox_defaults(
|
212 |
+
textbox_default_dict, 'Fur'),label = 'Fur Quality', lines = 1, interactive=True, elem_id='Pet Fur')
|
213 |
|
214 |
# Pass the user input and border template to the generator
|
215 |
with gr.Column(scale = 1):
|
216 |
+
pet_affection_level_output = gr.Textbox(value = set_textbox_defaults(
|
217 |
+
textbox_default_dict, 'Affection Level'),label = 'Affection Level', lines = 1, interactive=True, elem_id='Affection Level')
|
218 |
+
|
219 |
+
pet_energy_level_output = gr.Textbox(value = set_textbox_defaults(
|
220 |
+
textbox_default_dict, 'Energy Level'),label = 'Energy Level', lines = 1, interactive=True, elem_id='Energy Level')
|
221 |
+
|
222 |
+
pet_noise_level_output = gr.Textbox(value = set_textbox_defaults(
|
223 |
+
textbox_default_dict, 'Noise Level'),label = 'Noise Level', lines = 1, interactive=True, elem_id='Noise Level')
|
224 |
+
|
225 |
+
pet_play_level_output = gr.Textbox(value = set_textbox_defaults(
|
226 |
+
textbox_default_dict, 'Play Level'),label = 'Play Level', lines = 1, interactive=True, elem_id='Play Level')
|
227 |
+
|
228 |
+
pet_intelligence_level_output = gr.Textbox(value = set_textbox_defaults(
|
229 |
+
textbox_default_dict, 'Intelligence Level'),label = 'Intelligence Level',
|
230 |
+
lines = 1, interactive=True, elem_id='Intelligence Level')
|
231 |
|
|
|
|
|
232 |
gr.HTML(""" <div id="inner"> <header>
|
233 |
<h3> 3. This text will be used to generate the card's image.</h3>
|
234 |
</div>""")
|
235 |
+
image_prompt_output = gr.Textbox(label = 'Putting words or phrases in parenthesis adds weight. Example: (Flaming Magical :1.0) Sword.', value = set_textbox_defaults(textbox_default_dict, 'image Prompt'), lines = 1, interactive=True, elem_id='image Prompt')
|
236 |
|
237 |
gr.HTML(""" <div id="inner"> <header>
|
238 |
<h2> <b>Third:</b> Click 'Generate Cards' to generate 4 cards to choose from. </h2>
|
|
|
257 |
)
|
258 |
generate_final_item_card = gr.Button(value = "Add Text", elem_id = "Generate user card")
|
259 |
|
260 |
+
card_gen_button.click(fn = generate_image_update_gallery, inputs =[num_image_to_generate,image_prompt_output,pet_name_output,built_template], outputs= generate_gallery)
|
|
|
|
|
|
|
|
|
|
|
261 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
262 |
|
263 |
# Button logice calls function when button object is pressed, passing inputs and passing output to components
|
264 |
llm_output = item_text_generate.click(generate_text_update_textboxes,
|
265 |
inputs = [user_input],
|
266 |
+
outputs= [pet_name_state,
|
267 |
+
pet_name_output,
|
268 |
+
pet_species_state,
|
269 |
+
pet_species_output,
|
270 |
+
pet_breed_state,
|
271 |
+
pet_breed_output,
|
272 |
+
pet_fur_state,
|
273 |
+
pet_fur_output,
|
274 |
+
pet_intelligence_level_state,
|
275 |
+
pet_intelligence_level_output,
|
276 |
+
pet_affection_level_state,
|
277 |
+
pet_affection_level_output,
|
278 |
+
pet_energy_level_state,
|
279 |
+
pet_energy_level_output,
|
280 |
+
pet_noise_level_state,
|
281 |
+
pet_noise_level_output,
|
282 |
+
pet_play_level_state,
|
283 |
+
pet_play_level_output,
|
284 |
+
image_prompt_var,
|
285 |
+
image_prompt_output])
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
generate_final_item_card.click(card.render_text_on_card, inputs = [selected_generated_image,
|
288 |
+
pet_name_output,
|
289 |
+
pet_species_output,
|
290 |
+
pet_breed_output,
|
291 |
+
pet_fur_output,
|
292 |
+
pet_intelligence_level_output,
|
293 |
+
pet_affection_level_output,
|
294 |
+
pet_energy_level_output,
|
295 |
+
pet_noise_level_output,
|
296 |
+
pet_play_level_output
|
297 |
+
],
|
298 |
outputs = generate_gallery )
|
299 |
+
|
300 |
+
|
|
|
|
|
|
|
|
|
|
|
301 |
if __name__ == '__main__':
|
302 |
demo.launch(server_name = "0.0.0.0", server_port = 8000, share = False, allowed_paths = ["/media/drakosfire/Shared/","/media/drakosfire/Shared/MerchantBot/card_templates"])
|
303 |
|
|
|
306 |
|
307 |
|
308 |
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
|
311 |
|
user_input.py
CHANGED
@@ -5,17 +5,13 @@ import utilities as u
|
|
5 |
import sys
|
6 |
import tempfile
|
7 |
from PIL import Image
|
8 |
-
<<<<<<< HEAD
|
9 |
from github import Github
|
10 |
-
=======
|
11 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
12 |
|
13 |
image_path = str
|
14 |
end_phrase = """<|end_of_turn|>"""
|
15 |
# Indexing the contents of Card templates and temp images
|
16 |
card_template_path = "./card_templates/"
|
17 |
temp_image_path = "./image_temp"
|
18 |
-
<<<<<<< HEAD
|
19 |
|
20 |
def index_image_paths(repo_name,directory_path):
|
21 |
g = Github() # No token needed for public repos
|
@@ -28,17 +24,6 @@ def index_image_paths(repo_name,directory_path):
|
|
28 |
files.append(content_file.download_url) # Or content_file.path for just the path
|
29 |
|
30 |
return files
|
31 |
-
=======
|
32 |
-
def index_image_paths(directory_path, github_path):
|
33 |
-
list_temp_files = []
|
34 |
-
list_of_image_paths = u.directory_contents(directory_path)
|
35 |
-
for image_path in list_of_image_paths:
|
36 |
-
image_path = f"https://raw.githubusercontent.com/Drakosfire/CardGenerator/alpha-templates/seed_images/{github_path}{image_path}"
|
37 |
-
print(image_path)
|
38 |
-
list_temp_files.append(image_path)
|
39 |
-
return list_temp_files
|
40 |
-
|
41 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
42 |
|
43 |
user_pick_template_prompt = "Pick a template number from this list : "
|
44 |
user_pick_image_prompt = "Select an image : "
|
@@ -79,10 +64,7 @@ def call_llm(user_input):
|
|
79 |
response = response
|
80 |
|
81 |
response = response.replace("GPT4 Assistant: ", "")
|
82 |
-
<<<<<<< HEAD
|
83 |
print(response)
|
84 |
-
=======
|
85 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
86 |
response = igen.convert_to_dict(response)
|
87 |
if not response:
|
88 |
response = call_llm(user_input)
|
@@ -99,10 +81,6 @@ def prompt_user_input():
|
|
99 |
mimic = True
|
100 |
|
101 |
#user_input_template = input(f"Pick a template number from this list : {process_list_for_user_response(list_of_card_templates)}")
|
102 |
-
<<<<<<< HEAD
|
103 |
-
|
104 |
-
=======
|
105 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
106 |
user_input_template = user_pick_item(user_pick_template_prompt,list_of_card_templates)
|
107 |
response = call_llm(user_input_item)
|
108 |
print(response[u.keys_list(response,0)])
|
|
|
5 |
import sys
|
6 |
import tempfile
|
7 |
from PIL import Image
|
|
|
8 |
from github import Github
|
|
|
|
|
9 |
|
10 |
image_path = str
|
11 |
end_phrase = """<|end_of_turn|>"""
|
12 |
# Indexing the contents of Card templates and temp images
|
13 |
card_template_path = "./card_templates/"
|
14 |
temp_image_path = "./image_temp"
|
|
|
15 |
|
16 |
def index_image_paths(repo_name,directory_path):
|
17 |
g = Github() # No token needed for public repos
|
|
|
24 |
files.append(content_file.download_url) # Or content_file.path for just the path
|
25 |
|
26 |
return files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
user_pick_template_prompt = "Pick a template number from this list : "
|
29 |
user_pick_image_prompt = "Select an image : "
|
|
|
64 |
response = response
|
65 |
|
66 |
response = response.replace("GPT4 Assistant: ", "")
|
|
|
67 |
print(response)
|
|
|
|
|
68 |
response = igen.convert_to_dict(response)
|
69 |
if not response:
|
70 |
response = call_llm(user_input)
|
|
|
81 |
mimic = True
|
82 |
|
83 |
#user_input_template = input(f"Pick a template number from this list : {process_list_for_user_response(list_of_card_templates)}")
|
|
|
|
|
|
|
|
|
84 |
user_input_template = user_pick_item(user_pick_template_prompt,list_of_card_templates)
|
85 |
response = call_llm(user_input_item)
|
86 |
print(response[u.keys_list(response,0)])
|