drakosfire commited on
Commit
6990ec5
·
1 Parent(s): bc12c8a

Removed some duplication from merge

Browse files
Files changed (4) hide show
  1. app.py +6 -7
  2. card_generator.py +1 -14
  3. img2img.py +1 -1
  4. item_dict_gen.py +0 -3
app.py CHANGED
@@ -112,13 +112,12 @@ with gr.Blocks() as demo:
112
  </div>""")
113
  markdown_instructions = """## How It Works
114
 
115
- 1. Your intitial text along with the prompt is sent to Llama 3 70b to generate a python dictionary.
116
- 2. This new text will populate in interactive text fields. If it isn't perfect you can edit the text to fit your item.
117
- 3. The final text field is the Stable Diffusion prompt, these generate like one sentence stories describing the scene of your item. This field can also be edited.
118
- ## The first image generation take about 2 minutes for model to 'cold boot' after that it's ~10s per image.
119
- 4. **Image and Text Generation**: Now generate 4 card template without text and pick your favorite.
120
- 5. Finally, add text to your favorite template.
121
- 3. **Result**: The final product is a beautifully crafted D&D item card, ready for use in your gaming sessions."""
122
 
123
  gr.Markdown(markdown_instructions)
124
 
 
112
  </div>""")
113
  markdown_instructions = """## How It Works
114
 
115
+ 1. Your intitial text along with the prompt is sent to OpenAI's GPT-4o to generate a JSON.
116
+ 2. This JSON will be parsed into textboxes to review and edit.
117
+ 3. The final text field is the image prompt, these generate like one sentence stories describing the scene of your pet.
118
+ 4. **Image and Text Generation**: Now generate 4 blank cards in about 15 seconds.
119
+ 5. Finally, click the add text button to add text to your favorite template.
120
+ 3. **Result**: The final product is a beautifully crafted collectible pet card."""
 
121
 
122
  gr.Markdown(markdown_instructions)
123
 
card_generator.py CHANGED
@@ -59,21 +59,11 @@ def render_text_on_card(image_path, pet_name,
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,
65
- pet_fur,
66
- pet_intelligence,
67
- pet_affection,
68
- pet_energy,
69
- pet_noise,
70
- pet_play) :
71
  # Card Properties
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'
@@ -109,20 +99,17 @@ def render_text_on_card(image_path, pet_name,
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
 
 
59
  pet_energy,
60
  pet_noise,
61
  pet_play) :
62
+
 
 
 
 
 
 
 
 
63
  # Card Properties
64
  image_list = []
65
  pet_properties = f"Intelligence : {pet_intelligence} \n Affection : {pet_affection} \n Energy : {pet_energy} \n Noise : {pet_noise} \n Play : {pet_play}"
66
  output_image_path = f"./{pet_name}.png"
 
 
67
  print(f"Saving image to {output_image_path}")
68
  font_path = "./fonts/Balgruf.ttf"
69
  italics_font_path = './fonts/BalgrufItalic.ttf'
 
99
  # open image and render text
100
  image = u.open_image_from_url(image_path)
101
  image = rend.render_text_with_dynamic_spacing(image, pet_name, title_center_position, title_area_width, title_area_height,font_path,initial_font_size)
 
102
  image = rend.render_text_with_dynamic_spacing(image,type_text , type_center_position, type_area_width, type_area_height,font_path,initial_font_size)
103
  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)
104
  # paste_image_and_resize(image, value_overlay_path,x_position= 0,y_position=0, img_width= 768, img_height= 1024)
105
  #Paste Sizzek Sticker
106
  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)
 
107
 
108
  # Add blur, gives it a less artificial look, put into list and return the list since gallery requires lists
109
  image = image.filter(ImageFilter.GaussianBlur(.5))
110
  image_list.append(image)
111
 
112
  image = image.save(f"./output/{pet_name}.png")
 
113
 
114
 
115
 
img2img.py CHANGED
@@ -26,7 +26,7 @@ def preview_and_generate_image(num_images, sd_prompt, user_input_template):
26
  print(f"sd_prompt: {sd_prompt}")
27
  print(f"user_input_template: {user_input_template}")
28
  num_images = int(4)
29
- sd_prompt = f"magnum opus, blank card, no text, blank textboxes, detailed high quality animal properties borders, {sd_prompt}"
30
  try:
31
  # Save the image to a temporary file
32
  with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
 
26
  print(f"sd_prompt: {sd_prompt}")
27
  print(f"user_input_template: {user_input_template}")
28
  num_images = int(4)
29
+ sd_prompt = f"magnum opus, blank card, no text, blank textbox at top for title, mid for details and bottom for description, detailed high quality animal properties borders, {sd_prompt}"
30
  try:
31
  # Save the image to a temporary file
32
  with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
item_dict_gen.py CHANGED
@@ -68,9 +68,6 @@ 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
- - "{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
76
 
 
68
  - **Input Placeholder**:
69
  - "{pet}": Replace with the pet name, ensuring it's wrapped in single quotes.
70
 
 
 
 
71
  **Output Examples**:
72
  1. Mignon the Toy Sized Chihuahua
73