Spaces:
Runtime error
Runtime error
Commit
·
8f0c3a9
1
Parent(s):
cb26647
pet generator first commit
Browse files- item_dict_gen.py +116 -313
- main.py +0 -44
item_dict_gen.py
CHANGED
@@ -4,32 +4,21 @@ import gc
|
|
4 |
import torch
|
5 |
|
6 |
model_path = "./models/starling-lm-7b-alpha.Q8_0.gguf"
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
=======
|
10 |
-
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
11 |
-
|
12 |
-
|
13 |
-
# Simple inference example
|
14 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
15 |
def load_llm(user_input):
|
16 |
llm = Llama(
|
17 |
model_path=model_path,
|
18 |
n_ctx=8192, # The max sequence length to use - note that longer sequence lengths require much more resources
|
19 |
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
|
20 |
-
<<<<<<< HEAD
|
21 |
n_gpu_layers=32 # The number of layers to offload to GPU, if you have GPU acceleration available
|
22 |
)
|
23 |
return llm(
|
24 |
-
f"GPT4 User: {prompt_instructions} the
|
25 |
max_tokens=768, # Generate up to 512 tokens
|
26 |
-
|
27 |
-
n_gpu_layers=-1 # The number of layers to offload to GPU, if you have GPU acceleration available
|
28 |
-
)
|
29 |
-
return llm(
|
30 |
-
f"GPT4 User: {prompt_instructions} the item is {user_input}: <|end_of_turn|>GPT4 Assistant:", # Prompt
|
31 |
-
max_tokens=512, # Generate up to 512 tokens
|
32 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
33 |
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
|
34 |
echo=False # Whether to echo the prompt
|
35 |
)
|
@@ -51,7 +40,7 @@ def convert_to_dict(string):
|
|
51 |
try:
|
52 |
result = ast.literal_eval(string)
|
53 |
if isinstance(result, dict):
|
54 |
-
print("
|
55 |
return result
|
56 |
# If not, modify by attempting to add brackets to where they tend to fail to generate.
|
57 |
else:
|
@@ -71,313 +60,127 @@ def convert_to_dict(string):
|
|
71 |
|
72 |
# Instructions past 4 are not time tested and may need to be removed.
|
73 |
### Meta prompted :
|
74 |
-
prompt_instructions = """ **Purpose**: Generate a structured inventory entry for a
|
75 |
|
76 |
**Instructions**:
|
77 |
-
1. Replace `{
|
78 |
2. Ensure your request is formatted as a hashmap.
|
79 |
-
3.
|
80 |
-
4. The description should be brief and puncy, or concise and
|
81 |
5. The quote and SD Prompt MUST be inside double quotations ie " ".
|
82 |
-
|
83 |
-
7. Value should be assigned as an integer of copper pieces (cp), silver pieces (sp), electrum pieces (ep), gold pieces (gp), and platinum pieces (pp).
|
84 |
-
8. Use this table for reference on value :
|
85 |
-
1 cp 1 lb. of wheat
|
86 |
-
2 cp 1 lb. of flour or one chicken
|
87 |
-
5 cp 1 lb. of salt
|
88 |
-
1 sp 1 lb. of iron or 1 sq. yd. of canvas
|
89 |
-
5 sp 1 lb. of copper or 1 sq. yd. of cotton cloth
|
90 |
-
1 gp 1 lb. of ginger or one goat
|
91 |
-
2 gp 1 lb. of cinnamon or pepper, or one sheep
|
92 |
-
3 gp 1 lb. of cloves or one pig
|
93 |
-
5 gp 1 lb. of silver or 1 sq. yd. of linen
|
94 |
-
10 gp 1 sq. yd. of silk or one cow
|
95 |
-
15 gp 1 lb. of saffron or one ox
|
96 |
-
50 gp 1 lb. of gold
|
97 |
-
500 gp 1 lb. of platinum
|
98 |
-
|
99 |
-
|
100 |
-
300 gp +1 Melee or Ranged Weapon
|
101 |
-
2000 gp +2 Melee or Ranged Weapon
|
102 |
-
10000 gp +3 Melee or Ranged Weapon
|
103 |
-
300 gp +1 Armor Uncommon
|
104 |
-
2000 gp +2 Armor Rare
|
105 |
-
10000 gp +3 Armor Very Rare
|
106 |
-
300 gp +1 Shield Uncommon
|
107 |
-
2000 gp +2 Shield Rare
|
108 |
-
10000 gp +3 Shield Very Rare
|
109 |
-
|
110 |
-
9. Examples of Magical Scroll Value:
|
111 |
-
Common: 50-100 gp
|
112 |
-
Uncommon: 101-500 gp
|
113 |
-
Rare: 501-5000 gp
|
114 |
-
Very rare: 5001-50000 gp
|
115 |
-
Legendary: 50001+ gp
|
116 |
|
117 |
-
|
118 |
-
Cantrip-1: Common
|
119 |
-
2-3: Uncommon
|
120 |
-
4-5: Rare
|
121 |
-
6-8: Very rare
|
122 |
-
9: Legendary
|
123 |
-
|
124 |
-
10. Explanation of Mimics:
|
125 |
-
Mimics are shapeshifting predators able to take on the form of inanimate objects to lure creatures to their doom. In dungeons, these cunning creatures most often take the form of doors and chests, having learned that such forms attract a steady stream of prey.
|
126 |
-
Imitative Predators. Mimics can alter their outward texture to resemble wood, stone, and other basic materials, and they have evolved to assume the appearance of objects that other creatures are likely to come into contact with. A mimic in its altered form is nearly unrecognizable until potential prey blunders into its reach, whereupon the monster sprouts pseudopods and attacks.
|
127 |
-
When it changes shape, a mimic excretes an adhesive that helps it seize prey and weapons that touch it. The adhesive is absorbed when the mimic assumes its amorphous form and on parts the mimic uses to move itself.
|
128 |
-
Cunning Hunters. Mimics live and hunt alone, though they occasionally share their feeding grounds with other creatures. Although most mimics have only predatory intelligence, a rare few evolve greater cunning and the ability to carry on simple conversations in Common or Undercommon. Such mimics might allow safe passage through their domains or provide useful information in exchange for food.
|
129 |
-
|
130 |
-
11.
|
131 |
**Format Example**:
|
132 |
- **Dictionary Structure**:
|
133 |
|
134 |
-
{"{
|
135 |
-
'Name': "{
|
136 |
-
'
|
137 |
-
'
|
138 |
-
'
|
139 |
-
'
|
140 |
-
'
|
141 |
-
'
|
142 |
-
'
|
143 |
-
'
|
144 |
-
'SD Prompt': "{special description for the
|
145 |
} }
|
146 |
|
147 |
- **Input Placeholder**:
|
148 |
-
- "{
|
149 |
|
150 |
**Output Examples**:
|
151 |
-
1.
|
152 |
-
|
153 |
-
{
|
154 |
-
|
155 |
-
'
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
'
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
3.
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
'
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
'
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
'
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
'Rarity': 'Very Rare',
|
244 |
-
'Value': '3000 gp',
|
245 |
-
'Properties': ["Flying", "Personal Flight", "Up to 2 passengers", Speed : 60 ft],
|
246 |
-
'Weight': '50 lb',
|
247 |
-
'Description': "This enchanted carpet whisks its riders through the skies, providing a swift and comfortable mode of transport across great distances.",
|
248 |
-
'Quote': "Soar above the mundane, and embrace the winds of adventure with this magical gift from the heavens.",
|
249 |
-
'SD Prompt': "a vibrant, intricately patterned flying carpet soaring high in the sky, with clouds and a clear blue backdrop, emphasizing its magical essence and freedom of flight"
|
250 |
-
} }
|
251 |
-
|
252 |
-
8. Tome of Endless Stories Entry:
|
253 |
-
|
254 |
-
{"Tome of Endless Stories": {
|
255 |
-
'Name': "Tome of Endless Stories",
|
256 |
-
'Type': 'Book',
|
257 |
-
'Rarity': 'Uncommon'
|
258 |
-
'Value': '500 gp',
|
259 |
-
'Properties': [
|
260 |
-
"Generates a new story or piece of lore each day",
|
261 |
-
"Reading a story grants insight or a hint towards solving a problem or puzzle"
|
262 |
-
],
|
263 |
-
'Weight': '3 lbs',
|
264 |
-
'Description': "An ancient tome bound in leather that shifts colors like the sunset. Its pages are never-ending, filled with tales from worlds both known and undiscovered.",
|
265 |
-
'Quote': "Within its pages lie the keys to a thousand worlds, each story a doorway to infinite possibilities.",
|
266 |
-
'SD Prompt': "leather-bound with gold and silver inlay, pages appear aged but are incredibly durable, magical glyphs shimmer softly on the cover."
|
267 |
-
} }
|
268 |
-
|
269 |
-
9. Ring of Miniature Summoning Entry:
|
270 |
-
|
271 |
-
{"Ring of Miniature Summoning": {
|
272 |
-
'Name': "Ring of Miniature Summoning",
|
273 |
-
'Type': 'Ring',
|
274 |
-
'Rarity': 'Rare',
|
275 |
-
'Value': '1500 gp',
|
276 |
-
'Properties': ["Summons a miniature beast ally once per day", "Beast follows commands and lasts for 1 hour", "Choice of beast changes with each dawn"],
|
277 |
-
'Weight': '0 lb',
|
278 |
-
'Description': "A delicate ring with a gem that shifts colors. When activated, it brings forth a small, loyal beast companion from the ether.",
|
279 |
-
'Quote': "Not all companions walk beside us. Some are summoned from the depths of magic, small in size but vast in heart.",
|
280 |
-
'SD Prompt': "gemstone with changing colors, essence of companionship and versatility."
|
281 |
-
} }
|
282 |
-
|
283 |
-
|
284 |
-
10. Spoon of Tasting Entry:
|
285 |
-
|
286 |
-
{"Spoon of Tasting": {
|
287 |
-
'Name': "Spoon of Tasting",
|
288 |
-
'Type': 'Spoon',
|
289 |
-
'Rarity': 'Uncommon',
|
290 |
-
'Value': '200 gp',
|
291 |
-
'Properties': ["When used to taste any dish, it can instantly tell you all the ingredients", "Provides exaggerated compliments or critiques about the dish"],
|
292 |
-
'Weight': '0.2 lb',
|
293 |
-
'Description': "A culinary critic’s dream or nightmare. This spoon doesn’t hold back its opinions on any dish it tastes.",
|
294 |
-
'Quote': "A spoonful of sugar helps the criticism go down.",
|
295 |
-
'SD Prompt': "Looks like an ordinary spoon, but with a mouth that speaks more than you’d expect."
|
296 |
-
} }
|
297 |
-
|
298 |
-
11. Infinite Scroll Entry:
|
299 |
-
|
300 |
-
{"Infinite Scroll": {
|
301 |
-
'Name': "Infinite Scroll",
|
302 |
-
'Type': 'Magical Scroll',
|
303 |
-
'Rarity': 'Legendary',
|
304 |
-
'Value': '25000',
|
305 |
-
'Properties': [
|
306 |
-
"Endlessly Extends with New Knowledge","Reveals Content Based on Reader’s Need or Desire","Cannot be Fully Transcribed"],
|
307 |
-
'Weight': '0.5 lb',
|
308 |
-
'Description': "This scroll appears to be a standard parchment at first glance. However, as one begins to read, it unrolls to reveal an ever-expanding tapestry of knowledge, lore, and spells that seems to have no end.",
|
309 |
-
'Quote': "In the pursuit of knowledge, the horizon is ever receding. So too is the content of this scroll, an endless journey within a parchment’s bounds.",
|
310 |
-
'SD Prompt': "A seemingly ordinary scroll that extends indefinitely"
|
311 |
-
} }
|
312 |
-
|
313 |
-
12. Mimic Treasure Chest Entry:
|
314 |
-
|
315 |
-
{"Mimic Treasure Chest": {
|
316 |
-
'Name': "Mimic Treasure Chest",
|
317 |
-
'Type': 'Trap',
|
318 |
-
'Rarity': 'Rare',
|
319 |
-
'Value': '1000 gp', # Increased value reflects its dangerous and rare nature
|
320 |
-
'Properties': ["Deceptively inviting","Springs to life when interacted with","Capable of attacking unwary adventurers"],
|
321 |
-
'Weight': '50 lb', # Mimics are heavy due to their monstrous nature
|
322 |
-
'Description': "This enticing treasure chest is a deadly Mimic, luring adventurers with the promise of riches only to unleash its monstrous true form upon those who dare to approach, turning their greed into a fight for survival.",
|
323 |
-
'SD Prompt': "A seemingly ordinary treasure chest that glimmers with promise. Upon closer inspection, sinister, almost living edges move with malice, revealing its true nature as a Mimic, ready to unleash fury on the unwary."
|
324 |
-
} }
|
325 |
-
|
326 |
-
13. Hammer of Thunderbolts Entry:
|
327 |
-
|
328 |
-
{'Hammer of Thunderbolts': {
|
329 |
-
'Name': 'Hammer of Thunderbolts',
|
330 |
-
'Type': 'Melee Weapon (maul, bludgeoning)',
|
331 |
-
'Rarity': 'Legendary',
|
332 |
-
'Value': '16000',
|
333 |
-
'Damage': '2d6 + 1 (martial, bludgeoning)',
|
334 |
-
'Properties': ["requires attunement","Giant's Bane","must be wearing a belt of giant strength and gauntlets of ogre power","Str +4","Can excees 20 but not 30","20 against giant, DC 17 save against death","5 charges, expend 1 to make a range attack 20/60","ranged attack releases thunderclap on hit, DC 17 save against stunned 30 ft","regain 1d4+1 charges at dawn"],
|
335 |
-
'Weight': 15 lb',
|
336 |
-
'Description': "God-forged and storm-bound, a supreme force, its rune-etched head blazing with power. More than a weapon, it's a symbol of nature's fury, capable of reshaping landscapes and commanding elements with every strike.",
|
337 |
-
'Quote': "When the skies rage and the earth trembles, know that the Hammer of Thunderbolts has found its mark. It is not merely a weapon, but the embodiment of the storm\'s wrath wielded by those deemed worthy.",
|
338 |
-
'SD Prompt': "It radiates with electric energy, its rune-etched head and storm-weathered leather grip symbolizing its dominion over storms. In its grasp, it pulses with the potential to summon the heavens' fury, embodying the tempest's raw power."
|
339 |
-
} }
|
340 |
-
|
341 |
-
14. Shadow Lamp Entry:
|
342 |
-
|
343 |
-
{'Shadow Lamp': {
|
344 |
-
'Name': 'Shadow Lamp',
|
345 |
-
'Type': 'Magical Item',
|
346 |
-
'Rarity': 'Uncommon',
|
347 |
-
'Value': '500 gp',
|
348 |
-
'Properties': ["Provides dim light in a 20-foot radius", "Invisibility to darkness-based senses", "Can cast Darkness spell once per day"],
|
349 |
-
'Weight': '1 lb',
|
350 |
-
'Description': "A small lamp carved from obsidian and powered by a mysterious force, it casts an eerie glow that illuminates its surroundings while making the wielder invisible to those relying on darkness-based senses.",
|
351 |
-
'Quote': "In the heart of shadow lies an unseen light, casting away darkness and revealing what was once unseen.",
|
352 |
-
'SD Prompt': "Glass lantern filled with inky swirling shadows, black gaseous clouds flow out, blackness flows from it, spooky, sneaky"
|
353 |
-
} }
|
354 |
-
|
355 |
-
15. Dark Mirror:
|
356 |
-
|
357 |
-
{'Dark Mirror': {
|
358 |
-
'Name': 'Dark Mirror',
|
359 |
-
'Type': 'Magical Item',
|
360 |
-
'Rarity': 'Rare',
|
361 |
-
'Value': '600 gp',
|
362 |
-
'Properties': ["Reflects only darkness when viewed from one side", "Grants invisibility to its reflection", "Can be used to cast Disguise Self spell once per day"],
|
363 |
-
'Weight': '2 lb',
|
364 |
-
'Description': "An ordinary-looking mirror with a dark, almost sinister tint. It reflects only darkness and distorted images when viewed from one side, making it an ideal tool for spies and those seeking to hide their true identity.",
|
365 |
-
'Quote': "A glass that hides what lies within, a surface that reflects only darkness and deceit.",
|
366 |
-
'SD Prompt': "Dark and mysterious black surfaced mirror with an obsidian flowing center with a tint of malice, its surface reflecting nothing but black and distorted images, swirling with tendrils, spooky, ethereal"
|
367 |
-
} }
|
368 |
-
|
369 |
-
16. Moon-Touched Greatsword Entry:
|
370 |
-
|
371 |
-
{'Moon-Touched Greatsword':{
|
372 |
-
'Name': 'Moontouched Greatsword',
|
373 |
-
'Type': 'Melee Weapon (greatsword, slashing)',
|
374 |
-
'Rarity': 'Very Rare',
|
375 |
-
'Value': '8000 gp',
|
376 |
-
'Damage': '2d6 + Str slashing',
|
377 |
-
'Properties': ["Adds +2 to attack and damage rolls while wielder is under the effects of Moonbeam or Daylight spells", "Requires attunement"],
|
378 |
-
'Weight': '6 lb',
|
379 |
-
'Description': "Forged from lunar metal and imbued with celestial magic, this greatsword gleams like a silver crescent moon, its edge sharp enough to cut through the darkest shadows.",
|
380 |
-
'Quote': "With each swing, it sings a melody of light that pierces the veil of darkness, a beacon of hope and justice.",
|
381 |
-
'SD Prompt': "A silver greatsword with a crescent moon-shaped blade that reflects a soft glow, reminiscent of the moon's radiance. The hilt is wrapped in silvery leather, and the metal seems to shimmer and change with the light, reflecting the lunar cycles."
|
382 |
-
} }
|
383 |
"""
|
|
|
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
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def load_llm(user_input):
|
12 |
llm = Llama(
|
13 |
model_path=model_path,
|
14 |
n_ctx=8192, # The max sequence length to use - note that longer sequence lengths require much more resources
|
15 |
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
|
|
|
16 |
n_gpu_layers=32 # The number of layers to offload to GPU, if you have GPU acceleration available
|
17 |
)
|
18 |
return llm(
|
19 |
+
f"GPT4 User: {prompt_instructions} the pet is {user_input}: <|end_of_turn|>GPT4 Assistant:", # Prompt
|
20 |
max_tokens=768, # Generate up to 512 tokens
|
21 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
|
23 |
echo=False # Whether to echo the prompt
|
24 |
)
|
|
|
40 |
try:
|
41 |
result = ast.literal_eval(string)
|
42 |
if isinstance(result, dict):
|
43 |
+
print("pet dictionary is valid")
|
44 |
return result
|
45 |
# If not, modify by attempting to add brackets to where they tend to fail to generate.
|
46 |
else:
|
|
|
60 |
|
61 |
# Instructions past 4 are not time tested and may need to be removed.
|
62 |
### Meta prompted :
|
63 |
+
prompt_instructions = """ **Purpose**: Generate a structured inventory entry for a model of cybernetic pet made by the imaginary Cavall technology company.
|
64 |
|
65 |
**Instructions**:
|
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 description 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 quote and SD 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 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
**Format Example**:
|
75 |
- **Dictionary Structure**:
|
76 |
|
77 |
+
{"{Pet}": {
|
78 |
+
'Name': "{Pet Name}",
|
79 |
+
'Pet Species': '{pet species}',
|
80 |
+
'Breed': '{pet breed},
|
81 |
+
'Fur': '{pet fur qualities}',
|
82 |
+
'Intelligence Level': ["{property1}", "{property2}", ...],
|
83 |
+
'Affection Level': '{property1} , '{property2}',
|
84 |
+
'Energy Level': '{energy level}',
|
85 |
+
'Noise Level': "{pet description}",
|
86 |
+
'Play Level': "{play level}",
|
87 |
+
'SD Prompt': "{special description for the pet}"
|
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 |
+
{“Mignon”: {
|
97 |
+
'Name': "Mignon”
|
98 |
+
'Pet Species': Dog,
|
99 |
+
“Breed” : ”Chihuahua (Toy)”,
|
100 |
+
“Fur”: “Cream, smooth shorthair”,
|
101 |
+
“Intelligence Level”: “Medium-high, trainable but stubborn”,
|
102 |
+
“Affection Level”: “High but selective, prefers favorite humans”,
|
103 |
+
“Energy Level”: “High”,
|
104 |
+
“Noise Level” : “Very high, yappy”,
|
105 |
+
“Play Level” : “Low“, Fetch, chase“
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
2. Marmalade the Austrailian Shepherd Herding Dog
|
110 |
+
|
111 |
+
{“Marmalade”:{
|
112 |
+
“Breed” : ”Australian Shepherd (Herding)”,
|
113 |
+
'Pet Species': Dog,
|
114 |
+
“Fur”: “Blue merle with white markings and tan points, medium double coat”,
|
115 |
+
“Intelligence Level”: “Very high, suitable for jobs”,
|
116 |
+
“Affection Level”: “High”,
|
117 |
+
“Energy Level”: “Very high”,
|
118 |
+
“Noise Level” : “Medium, piercing”,
|
119 |
+
“Play Level” : “Very high, Agility, herding, obedience, frisbee, puzzles”
|
120 |
+
}
|
121 |
+
|
122 |
+
3. Holden Clawfield the Pembroke Welsh Corgi Herding Dog
|
123 |
+
|
124 |
+
{“Holden Clawfield”:{
|
125 |
+
“Breed” : ”Pembroke Welsh Corgi (Herding)”,
|
126 |
+
'Pet Species': Dog,
|
127 |
+
“Fur”: “Fawn with white markings, short double coat”,
|
128 |
+
“Intelligence Level”: “High, trainable”,
|
129 |
+
“Affection Level”: “Very high, loves humans and other Pets”,
|
130 |
+
“Energy Level”: “High”,
|
131 |
+
“Noise Level” : “High, piercing”,
|
132 |
+
“Play Level” : “High, Toys, herding, obedience”
|
133 |
+
}
|
134 |
+
|
135 |
+
4. Tyr the Great Pyr the Great Pyreness Working Dog
|
136 |
+
|
137 |
+
{“Tyr the Great Pyr”:{
|
138 |
+
“Breed” : ”Great Pyrenees (Working)”,
|
139 |
+
'Pet Species': Dog,
|
140 |
+
“Fur”: “White, medium double coat”,
|
141 |
+
“Intelligence Level”: “Medium, trainable to a point”,
|
142 |
+
“Affection Level”: “Medium, wary of strangers”,
|
143 |
+
“Energy Level”: “Low, mostly lazy but vigilant”,
|
144 |
+
“Noise Level and Style” : “Medium, will bark to alert”,
|
145 |
+
“Play Level” : “Medium, not motivated by play, Toys, treats”
|
146 |
+
}
|
147 |
+
|
148 |
+
5. Emperor Maximus the Great Dane Working Dog
|
149 |
+
|
150 |
+
{“Emperor Maximus”:{
|
151 |
+
“Breed” : ”Great Dane (Working)”,
|
152 |
+
'Pet Species': Dog,
|
153 |
+
“Fur”: “Black and white with black mask, smooth shorthair”,
|
154 |
+
“Intelligence Level”: “Medium, trainable”,
|
155 |
+
“Affection Level”: “Very high, needy”,
|
156 |
+
“Energy Level”: “Medium, enjoys hiking”,
|
157 |
+
“Noise Level and Style” : “Medium, will bark to alert”,
|
158 |
+
“Play Level” : “Medium, Chase, tug”
|
159 |
+
}
|
160 |
+
|
161 |
+
6. Becks the Airedale Terrier Dog
|
162 |
+
|
163 |
+
{“Becks”:{
|
164 |
+
“Breed” : ”Airedale Terrier (Terrier)”,
|
165 |
+
'Pet Species': Dog,
|
166 |
+
“Fur”: “Black and tan, medium wiry coat”,
|
167 |
+
“Intelligence Level”: “Medium, responds well to training”,
|
168 |
+
“Affection Level”: “Medium, reserved”,
|
169 |
+
“Energy Level”: “High, alert and active”,
|
170 |
+
“Noise Level and Style” : “Medium, vigilant watchdog”,
|
171 |
+
“Play Level” : “Medium, Fetch, toys, treats”
|
172 |
+
}
|
173 |
+
|
174 |
+
7. Blue Carolina the Plott Hound
|
175 |
+
|
176 |
+
{“Blue Carolina”:{
|
177 |
+
“Breed” : ”Plott Hound (Hound)”,
|
178 |
+
'Pet Species': Dog,
|
179 |
+
“Fur”: “Chocolate brindle, smooth shorthair”,
|
180 |
+
“Intelligence Level”: “High, driven and trainable”,
|
181 |
+
“Affection Level”: “High, very sweet”,
|
182 |
+
“Energy Level”: “High, alert and active”,
|
183 |
+
“Noise Level and Style” : “Medium, will bark to alert”,
|
184 |
+
“Play Level” : “Medium, more active than playful, Toys, frisbee, chase”
|
185 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
"""
|
main.py
CHANGED
@@ -6,13 +6,6 @@ import ctypes
|
|
6 |
import user_input as useri
|
7 |
import gradio as gr
|
8 |
import template_builder as tb
|
9 |
-
<<<<<<< HEAD
|
10 |
-
=======
|
11 |
-
import threading
|
12 |
-
import time
|
13 |
-
|
14 |
-
|
15 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
16 |
|
17 |
# This is a fix for the way that python doesn't release system memory back to the OS and it was leading to locking up the system
|
18 |
libc = ctypes.cdll.LoadLibrary("libc.so.6")
|
@@ -22,13 +15,6 @@ M_MMAP_THRESHOLD = -3
|
|
22 |
libc.mallopt(M_MMAP_THRESHOLD, 2**20)
|
23 |
initial_name = "A Crowbar"
|
24 |
|
25 |
-
<<<<<<< HEAD
|
26 |
-
=======
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
32 |
with gr.Blocks() as demo:
|
33 |
|
34 |
# Functions and State Variables
|
@@ -72,28 +58,9 @@ with gr.Blocks() as demo:
|
|
72 |
|
73 |
|
74 |
# Function called when user generates item info, then assign values of dictionary to variables, output once to State, twice to textbox
|
75 |
-
def generate_text_update_textboxes(user_input):
|
76 |
def generate_text_update_textboxes(user_input):
|
77 |
u.reclaim_mem()
|
78 |
|
79 |
-
|
80 |
-
=======
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
# Function called when user generates item info, then assign values of dictionary to variables, output once to State, twice to textbox
|
85 |
-
def generate_text_update_textboxes(user_input, progress = gr.Progress()):
|
86 |
-
u.reclaim_mem()
|
87 |
-
|
88 |
-
# Define a function to update progress
|
89 |
-
def update_progress(duration, progress):
|
90 |
-
for i in range(10):
|
91 |
-
time.sleep(duration / 10) # Wait for a fraction of the total duration
|
92 |
-
progress((i + 1) / 10, desc="Thinking...") # Update progress
|
93 |
-
# Start the progress update in a separate thread, passing `progress` explicitly
|
94 |
-
threading.Thread(target=update_progress, args=(10, progress)).start()
|
95 |
-
|
96 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
97 |
llm_output=useri.call_llm(user_input)
|
98 |
item_key = list(llm_output.keys())
|
99 |
|
@@ -159,11 +126,8 @@ with gr.Blocks() as demo:
|
|
159 |
preview = img2img.preview_and_generate_image(x,img_gen, prompt, built_template, item_name)
|
160 |
image_list.append(preview)
|
161 |
yield image_list
|
162 |
-
#generate_gallery.change(image_list)
|
163 |
del preview
|
164 |
u.reclaim_mem()
|
165 |
-
|
166 |
-
#generated_image_list = img2img.generate_image(num_img,sd_prompt,item_name,selected_border)
|
167 |
return image_list
|
168 |
|
169 |
def build_template(selected_border, selected_seed_image):
|
@@ -171,21 +135,13 @@ with gr.Blocks() as demo:
|
|
171 |
return image_list, image_list
|
172 |
|
173 |
|
174 |
-
<<<<<<< HEAD
|
175 |
# Beginning of UI Page
|
176 |
-
# Beginning of UI Page
|
177 |
-
=======
|
178 |
-
# Beginning of page format
|
179 |
-
# Title
|
180 |
-
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
181 |
gr.HTML(""" <div id="inner"> <header>
|
182 |
<h1>Item Card Generator</h1>
|
183 |
<p>
|
184 |
With this AI driven tool you will build a collectible style card of a fantasy flavored item with details.
|
185 |
</p>
|
186 |
</div>""")
|
187 |
-
<<<<<<< HEAD
|
188 |
-
|
189 |
|
190 |
=======
|
191 |
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|
|
|
6 |
import user_input as useri
|
7 |
import gradio as gr
|
8 |
import template_builder as tb
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# This is a fix for the way that python doesn't release system memory back to the OS and it was leading to locking up the system
|
11 |
libc = ctypes.cdll.LoadLibrary("libc.so.6")
|
|
|
15 |
libc.mallopt(M_MMAP_THRESHOLD, 2**20)
|
16 |
initial_name = "A Crowbar"
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
with gr.Blocks() as demo:
|
19 |
|
20 |
# Functions and State Variables
|
|
|
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 |
item_key = list(llm_output.keys())
|
66 |
|
|
|
126 |
preview = img2img.preview_and_generate_image(x,img_gen, prompt, built_template, item_name)
|
127 |
image_list.append(preview)
|
128 |
yield image_list
|
|
|
129 |
del preview
|
130 |
u.reclaim_mem()
|
|
|
|
|
131 |
return image_list
|
132 |
|
133 |
def build_template(selected_border, selected_seed_image):
|
|
|
135 |
return image_list, image_list
|
136 |
|
137 |
|
|
|
138 |
# Beginning of UI Page
|
|
|
|
|
|
|
|
|
|
|
139 |
gr.HTML(""" <div id="inner"> <header>
|
140 |
<h1>Item Card Generator</h1>
|
141 |
<p>
|
142 |
With this AI driven tool you will build a collectible style card of a fantasy flavored item with details.
|
143 |
</p>
|
144 |
</div>""")
|
|
|
|
|
145 |
|
146 |
=======
|
147 |
>>>>>>> 9a956dd (Polished and launch to Hugging Face)
|