Spaces:
Running
Running
Commit
•
f26612a
1
Parent(s):
da438db
added script to print directory structure and file content
Browse files- __pycache__/card_generator.cpython-310.pyc +0 -0
- app.py +7 -3
- card_generator.py +12 -3
__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
|
|
app.py
CHANGED
@@ -235,7 +235,7 @@ with gr.Blocks() as demo:
|
|
235 |
item_sd_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, 'SD Prompt'), lines = 1, interactive=True, elem_id='SD 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>
|
239 |
</div>""")
|
240 |
card_gen_button = gr.Button(value = "Generate Cards", elem_id="Generate Card Button")
|
241 |
|
@@ -253,12 +253,16 @@ with gr.Blocks() as demo:
|
|
253 |
columns =[2], rows = [2],
|
254 |
object_fit= "fill",
|
255 |
height = "768",
|
256 |
-
elem_id = "Generated Cards Gallery"
|
|
|
257 |
)
|
258 |
generate_final_item_card = gr.Button(value = "Add Text", elem_id = "Generate user card")
|
259 |
|
260 |
|
261 |
-
card_gen_button.click(fn = generate_image_update_gallery,
|
|
|
|
|
|
|
262 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
263 |
|
264 |
# Button logice calls function when button object is pressed, passing inputs and passing output to components
|
|
|
235 |
item_sd_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, 'SD Prompt'), lines = 1, interactive=True, elem_id='SD Prompt')
|
236 |
|
237 |
gr.HTML(""" <div id="inner"> <header>
|
238 |
+
<h2> <b>Third:</b> Click 'Generate Cards' to generate 4 cards to choose from. First image from a cold boot takes about 2 minutes. After that it's 10 seconds per image. </h2>
|
239 |
</div>""")
|
240 |
card_gen_button = gr.Button(value = "Generate Cards", elem_id="Generate Card Button")
|
241 |
|
|
|
253 |
columns =[2], rows = [2],
|
254 |
object_fit= "fill",
|
255 |
height = "768",
|
256 |
+
elem_id = "Generated Cards Gallery",
|
257 |
+
allow_preview=False
|
258 |
)
|
259 |
generate_final_item_card = gr.Button(value = "Add Text", elem_id = "Generate user card")
|
260 |
|
261 |
|
262 |
+
card_gen_button.click(fn = generate_image_update_gallery,
|
263 |
+
inputs =[num_image_to_generate,item_sd_prompt_output,item_name_output,
|
264 |
+
built_template_gallery], outputs= generate_gallery,
|
265 |
+
show_progress=True)
|
266 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
267 |
|
268 |
# Button logice calls function when button object is pressed, passing inputs and passing output to components
|
card_generator.py
CHANGED
@@ -2,6 +2,7 @@ import render_card_text as rend
|
|
2 |
from PIL import Image, ImageFilter
|
3 |
import utilities as u
|
4 |
import ast
|
|
|
5 |
|
6 |
|
7 |
def save_image(image,item_key):
|
@@ -18,9 +19,17 @@ blank_overlay_path = "./card_parts/white-fill-title-detail-value-transparent.png
|
|
18 |
value_overlay_path = "./card_parts/Value_box_transparent.png"
|
19 |
test_item = {'Name': 'Pustulent Raspberry', 'Type': 'Fruit', 'Value': '1 cp', 'Properties': ['Unusual Appearance', 'Rare Taste'], 'Weight': '0.2 lb', 'Description': 'This small fruit has a pustulent appearance, with bumps and irregular shapes covering its surface. Its vibrant colors and strange texture make it an oddity among other fruits.', 'Quote': 'A fruit that defies expectations, as sweet and sour as life itself.', 'SD Prompt': 'A small fruit with vibrant colors and irregular shapes, bumps covering its surface.'}
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Function that takes in an image url and a dictionary and uses the values to print onto a card.
|
26 |
def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_width, img_height, purchased_item_key = None):
|
|
|
2 |
from PIL import Image, ImageFilter
|
3 |
import utilities as u
|
4 |
import ast
|
5 |
+
import os
|
6 |
|
7 |
|
8 |
def save_image(image,item_key):
|
|
|
19 |
value_overlay_path = "./card_parts/Value_box_transparent.png"
|
20 |
test_item = {'Name': 'Pustulent Raspberry', 'Type': 'Fruit', 'Value': '1 cp', 'Properties': ['Unusual Appearance', 'Rare Taste'], 'Weight': '0.2 lb', 'Description': 'This small fruit has a pustulent appearance, with bumps and irregular shapes covering its surface. Its vibrant colors and strange texture make it an oddity among other fruits.', 'Quote': 'A fruit that defies expectations, as sweet and sour as life itself.', 'SD Prompt': 'A small fruit with vibrant colors and irregular shapes, bumps covering its surface.'}
|
21 |
|
22 |
+
def print_directory_structure(startpath):
|
23 |
+
for root, dirs, files in os.walk(startpath):
|
24 |
+
level = root.replace(startpath, '').count(os.sep)
|
25 |
+
indent = ' ' * 4 * (level)
|
26 |
+
print(f"{indent}{os.path.basename(root)}/")
|
27 |
+
subindent = ' ' * 4 * (level + 1)
|
28 |
+
for f in files:
|
29 |
+
print(f"{subindent}{f}")
|
30 |
+
base_dir = os.path.dirname(os.path.abspath(__file__))
|
31 |
+
print("Base Directory:", base_dir)
|
32 |
+
print_directory_structure(base_dir)
|
33 |
|
34 |
# Function that takes in an image url and a dictionary and uses the values to print onto a card.
|
35 |
def paste_image_and_resize(base_image,sticker_path, x_position, y_position,img_width, img_height, purchased_item_key = None):
|