Spaces:
Runtime error
Runtime error
Merge branch 'pet-generator' of https://github.com/Drakosfire/CardGenerator into pet-generator
Browse files- .gitignore +4 -0
- card_generator.py +15 -0
- item_dict_gen.py +2 -0
.gitignore
CHANGED
|
@@ -4,7 +4,11 @@ cuda_12.4.0_550.54.14_linux.run
|
|
| 4 |
models/
|
| 5 |
blobs-ids.txt
|
| 6 |
|
|
|
|
|
|
|
| 7 |
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Python Cache
|
| 10 |
__pycache__/
|
|
|
|
| 4 |
models/
|
| 5 |
blobs-ids.txt
|
| 6 |
|
| 7 |
+
# Python Cache
|
| 8 |
+
__pycache__/
|
| 9 |
|
| 10 |
+
# Environment variables
|
| 11 |
+
.env
|
| 12 |
|
| 13 |
# Python Cache
|
| 14 |
__pycache__/
|
card_generator.py
CHANGED
|
@@ -50,6 +50,15 @@ def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_w
|
|
| 50 |
# Paste the resized image onto the base image
|
| 51 |
base_image.paste(image_to_paste_resized, paste_position, image_to_paste_resized)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
def render_text_on_card(image_path, pet_name,
|
| 54 |
pet_species,
|
| 55 |
pet_breed,
|
|
@@ -63,6 +72,8 @@ def render_text_on_card(image_path, pet_name,
|
|
| 63 |
image_list = []
|
| 64 |
pet_properties = f"Intelligence : {pet_intelligence} \n Affection : {pet_affection} \n Energy : {pet_energy} \n Noise : {pet_noise} \n Play : {pet_play}"
|
| 65 |
output_image_path = f"./{pet_name}.png"
|
|
|
|
|
|
|
| 66 |
print(f"Saving image to {output_image_path}")
|
| 67 |
font_path = "./fonts/Balgruf.ttf"
|
| 68 |
italics_font_path = './fonts/BalgrufItalic.ttf'
|
|
@@ -78,6 +89,7 @@ def render_text_on_card(image_path, pet_name,
|
|
| 78 |
type_area_width = 600
|
| 79 |
type_area_height = 45
|
| 80 |
type_text = f"{pet_breed} Color and Fur : {pet_fur}"
|
|
|
|
| 81 |
|
| 82 |
# Description box properties
|
| 83 |
description_position = (105, 630)
|
|
@@ -97,17 +109,20 @@ def render_text_on_card(image_path, pet_name,
|
|
| 97 |
# open image and render text
|
| 98 |
image = u.open_image_from_url(image_path)
|
| 99 |
image = rend.render_text_with_dynamic_spacing(image, pet_name, title_center_position, title_area_width, title_area_height,font_path,initial_font_size)
|
|
|
|
| 100 |
image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
|
| 101 |
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)
|
| 102 |
# paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
|
| 103 |
#Paste Sizzek Sticker
|
| 104 |
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)
|
|
|
|
| 105 |
|
| 106 |
# Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
|
| 107 |
image = image.filter(ImageFilter.GaussianBlur(.5))
|
| 108 |
image_list.append(image)
|
| 109 |
|
| 110 |
image = image.save(f"./output/{pet_name}.png")
|
|
|
|
| 111 |
|
| 112 |
|
| 113 |
|
|
|
|
| 50 |
# Paste the resized image onto the base image
|
| 51 |
base_image.paste(image_to_paste_resized, paste_position, image_to_paste_resized)
|
| 52 |
|
| 53 |
+
def render_text_on_card(image_path, pet_name,
|
| 54 |
+
pet_species,
|
| 55 |
+
pet_breed,
|
| 56 |
+
pet_fur,
|
| 57 |
+
pet_intelligence,
|
| 58 |
+
pet_affection,
|
| 59 |
+
pet_energy,
|
| 60 |
+
pet_noise,
|
| 61 |
+
pet_play) :
|
| 62 |
def render_text_on_card(image_path, pet_name,
|
| 63 |
pet_species,
|
| 64 |
pet_breed,
|
|
|
|
| 72 |
image_list = []
|
| 73 |
pet_properties = f"Intelligence : {pet_intelligence} \n Affection : {pet_affection} \n Energy : {pet_energy} \n Noise : {pet_noise} \n Play : {pet_play}"
|
| 74 |
output_image_path = f"./{pet_name}.png"
|
| 75 |
+
pet_properties = f"Intelligence : {pet_intelligence} \n Affection : {pet_affection} \n Energy : {pet_energy} \n Noise : {pet_noise} \n Play : {pet_play}"
|
| 76 |
+
output_image_path = f"./{pet_name}.png"
|
| 77 |
print(f"Saving image to {output_image_path}")
|
| 78 |
font_path = "./fonts/Balgruf.ttf"
|
| 79 |
italics_font_path = './fonts/BalgrufItalic.ttf'
|
|
|
|
| 89 |
type_area_width = 600
|
| 90 |
type_area_height = 45
|
| 91 |
type_text = f"{pet_breed} Color and Fur : {pet_fur}"
|
| 92 |
+
type_text = f"{pet_breed} Color and Fur : {pet_fur}"
|
| 93 |
|
| 94 |
# Description box properties
|
| 95 |
description_position = (105, 630)
|
|
|
|
| 109 |
# open image and render text
|
| 110 |
image = u.open_image_from_url(image_path)
|
| 111 |
image = rend.render_text_with_dynamic_spacing(image, pet_name, title_center_position, title_area_width, title_area_height,font_path,initial_font_size)
|
| 112 |
+
image = rend.render_text_with_dynamic_spacing(image, pet_name, title_center_position, title_area_width, title_area_height,font_path,initial_font_size)
|
| 113 |
image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
|
| 114 |
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)
|
| 115 |
# paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
|
| 116 |
#Paste Sizzek Sticker
|
| 117 |
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)
|
| 118 |
+
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)
|
| 119 |
|
| 120 |
# Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
|
| 121 |
image = image.filter(ImageFilter.GaussianBlur(.5))
|
| 122 |
image_list.append(image)
|
| 123 |
|
| 124 |
image = image.save(f"./output/{pet_name}.png")
|
| 125 |
+
image = image.save(f"./output/{pet_name}.png")
|
| 126 |
|
| 127 |
|
| 128 |
|
item_dict_gen.py
CHANGED
|
@@ -68,6 +68,8 @@ pet_prompt_instructions = """ **Purpose**: ONLY Generate a structured json follo
|
|
| 68 |
- **Input Placeholder**:
|
| 69 |
- "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
|
| 70 |
|
|
|
|
|
|
|
| 71 |
|
| 72 |
**Output Examples**:
|
| 73 |
1. Mignon the Toy Sized Chihuahua
|
|
|
|
| 68 |
- **Input Placeholder**:
|
| 69 |
- "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
|
| 70 |
|
| 71 |
+
- "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
|
| 72 |
+
|
| 73 |
|
| 74 |
**Output Examples**:
|
| 75 |
1. Mignon the Toy Sized Chihuahua
|