Spaces:
Sleeping
Sleeping
drakosfire
commited on
Commit
•
80c33b9
1
Parent(s):
80fd8c4
function added to user_input to get index from git directory
Browse files
main.py
CHANGED
@@ -55,10 +55,13 @@ with gr.Blocks() as demo:
|
|
55 |
item_name = textbox_default_dict[key]
|
56 |
return item_name
|
57 |
|
|
|
58 |
# Function called when user generates item info, then assign values of dictionary to variables, output once to State, twice to textbox
|
|
|
59 |
def generate_text_update_textboxes(user_input):
|
60 |
u.reclaim_mem()
|
61 |
|
|
|
62 |
llm_output=useri.call_llm(user_input)
|
63 |
item_key = list(llm_output.keys())
|
64 |
|
@@ -73,11 +76,14 @@ with gr.Blocks() as demo:
|
|
73 |
item_damage = llm_output[item_key[0]]['Damage']
|
74 |
else: item_damage = ''
|
75 |
|
|
|
76 |
item_weight = llm_output[item_key[0]]['Weight']
|
77 |
item_description = llm_output[item_key[0]]['Description']
|
78 |
item_quote = llm_output[item_key[0]]['Quote']
|
|
|
79 |
sd_prompt = llm_output[item_key[0]]['SD Prompt']
|
80 |
|
|
|
81 |
return [item_name, item_name,
|
82 |
item_type, item_type,
|
83 |
item_rarity, item_rarity,
|
@@ -125,6 +131,7 @@ with gr.Blocks() as demo:
|
|
125 |
return image_list, image_list
|
126 |
|
127 |
|
|
|
128 |
# Beginning of UI Page
|
129 |
gr.HTML(""" <div id="inner"> <header>
|
130 |
<h1>Item Card Generator</h1>
|
@@ -133,40 +140,41 @@ with gr.Blocks() as demo:
|
|
133 |
</p>
|
134 |
</div>""")
|
135 |
|
|
|
136 |
gr.HTML(""" <div id="inner"> <header>
|
137 |
<h2><b>First:</b> Build a Card Template</h2>
|
138 |
</div>""")
|
139 |
with gr.Row():
|
140 |
with gr.Column():
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
|
171 |
gr.HTML(""" <div id="inner"> <header><h4> -Or- Upload your own seed image, by dropping it into the 'Generated Template Gallery' </h4><br>
|
172 |
<h3>3. Click 'Generate Card Template'</h3><br>
|
@@ -202,6 +210,8 @@ with gr.Blocks() as demo:
|
|
202 |
</div>""")
|
203 |
with gr.Row():
|
204 |
|
|
|
|
|
205 |
# Build text boxes for the broken up item dictionary values
|
206 |
with gr.Column(scale = 1):
|
207 |
item_name_output = gr.Textbox(value = set_textbox_defaults(textbox_default_dict, 'Name'),label = 'Name', lines = 1, interactive=True, elem_id='Item Name')
|
@@ -217,6 +227,7 @@ with gr.Blocks() as demo:
|
|
217 |
item_quote_output = gr.Textbox(value = set_textbox_defaults(textbox_default_dict, 'Quote'),label = 'Quote', lines = 1, interactive=True, elem_id='Item quote')
|
218 |
item_properties_output = gr.Textbox(value = set_textbox_defaults(textbox_default_dict, 'Properties'),label = 'Properties : [List of comma seperated values]', lines = 1, interactive=True, elem_id='Item Properties')
|
219 |
|
|
|
220 |
gr.HTML(""" <div id="inner"> <header>
|
221 |
<h3> 3. This text will be used to generate the card's image.</h3>
|
222 |
</div>""")
|
@@ -245,6 +256,7 @@ with gr.Blocks() as demo:
|
|
245 |
)
|
246 |
generate_final_item_card = gr.Button(value = "Add Text", elem_id = "Generate user card")
|
247 |
|
|
|
248 |
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)
|
249 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
250 |
|
@@ -272,6 +284,7 @@ with gr.Blocks() as demo:
|
|
272 |
item_sd_prompt_var,
|
273 |
item_sd_prompt_output])
|
274 |
|
|
|
275 |
generate_final_item_card.click(card.render_text_on_card, inputs = [selected_generated_image,
|
276 |
item_name_output,
|
277 |
item_type_output,
|
@@ -285,6 +298,7 @@ with gr.Blocks() as demo:
|
|
285 |
],
|
286 |
outputs = generate_gallery )
|
287 |
|
|
|
288 |
if __name__ == '__main__':
|
289 |
demo.launch(server_name = "0.0.0.0", server_port = 8000, share = False, allowed_paths = ["/media/drakosfire/Shared/","/media/drakosfire/Shared/MerchantBot/card_templates"])
|
290 |
|
|
|
55 |
item_name = textbox_default_dict[key]
|
56 |
return item_name
|
57 |
|
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 |
def generate_text_update_textboxes(user_input):
|
62 |
u.reclaim_mem()
|
63 |
|
64 |
+
|
65 |
llm_output=useri.call_llm(user_input)
|
66 |
item_key = list(llm_output.keys())
|
67 |
|
|
|
76 |
item_damage = llm_output[item_key[0]]['Damage']
|
77 |
else: item_damage = ''
|
78 |
|
79 |
+
|
80 |
item_weight = llm_output[item_key[0]]['Weight']
|
81 |
item_description = llm_output[item_key[0]]['Description']
|
82 |
item_quote = llm_output[item_key[0]]['Quote']
|
83 |
+
item_quote = llm_output[item_key[0]]['Quote']
|
84 |
sd_prompt = llm_output[item_key[0]]['SD Prompt']
|
85 |
|
86 |
+
|
87 |
return [item_name, item_name,
|
88 |
item_type, item_type,
|
89 |
item_rarity, item_rarity,
|
|
|
131 |
return image_list, image_list
|
132 |
|
133 |
|
134 |
+
# Beginning of UI Page
|
135 |
# Beginning of UI Page
|
136 |
gr.HTML(""" <div id="inner"> <header>
|
137 |
<h1>Item Card Generator</h1>
|
|
|
140 |
</p>
|
141 |
</div>""")
|
142 |
|
143 |
+
|
144 |
gr.HTML(""" <div id="inner"> <header>
|
145 |
<h2><b>First:</b> Build a Card Template</h2>
|
146 |
</div>""")
|
147 |
with gr.Row():
|
148 |
with gr.Column():
|
149 |
|
150 |
+
# Template Gallery instructions
|
151 |
+
gr.HTML(""" <div id="inner"> <header>
|
152 |
+
<h3>1. Click a border from the 'Card Template Gallery'</h3>
|
153 |
+
</div>""")
|
154 |
+
|
155 |
+
border_gallery = gr.Gallery(label = "Card Template Gallery",
|
156 |
+
scale = 2,
|
157 |
+
value = useri.index_image_paths("Drakosfire/CardGenerator", "seed_images/card_templates"),
|
158 |
+
show_label = True,
|
159 |
+
columns = [3], rows = [3],
|
160 |
+
object_fit = "contain",
|
161 |
+
height = "auto",
|
162 |
+
elem_id = "Template Gallery")
|
163 |
+
|
164 |
+
gr.HTML(""" <div id="inner"> <header>
|
165 |
+
<h3>2. Click a image from the Seed Image Gallery</h3><br>
|
166 |
+
</div>""")
|
167 |
+
|
168 |
+
border_gallery.select(assign_img_path, outputs = selected_border_image)
|
169 |
+
seed_image_gallery = gr.Gallery(label= " Image Seed Gallery",
|
170 |
+
scale = 2,
|
171 |
+
value = useri.index_image_paths("Drakosfire/CardGenerator", "seed_images/item_seeds"),
|
172 |
+
show_label = True,
|
173 |
+
columns = [3], rows = [3],
|
174 |
+
object_fit = "contain",
|
175 |
+
height = "auto",
|
176 |
+
elem_id = "Template Gallery",
|
177 |
+
interactive=True)
|
178 |
|
179 |
gr.HTML(""" <div id="inner"> <header><h4> -Or- Upload your own seed image, by dropping it into the 'Generated Template Gallery' </h4><br>
|
180 |
<h3>3. Click 'Generate Card Template'</h3><br>
|
|
|
210 |
</div>""")
|
211 |
with gr.Row():
|
212 |
|
213 |
+
# Build text boxes for the broken up item dictionary values
|
214 |
+
|
215 |
# Build text boxes for the broken up item dictionary values
|
216 |
with gr.Column(scale = 1):
|
217 |
item_name_output = gr.Textbox(value = set_textbox_defaults(textbox_default_dict, 'Name'),label = 'Name', lines = 1, interactive=True, elem_id='Item Name')
|
|
|
227 |
item_quote_output = gr.Textbox(value = set_textbox_defaults(textbox_default_dict, 'Quote'),label = 'Quote', lines = 1, interactive=True, elem_id='Item quote')
|
228 |
item_properties_output = gr.Textbox(value = set_textbox_defaults(textbox_default_dict, 'Properties'),label = 'Properties : [List of comma seperated values]', lines = 1, interactive=True, elem_id='Item Properties')
|
229 |
|
230 |
+
|
231 |
gr.HTML(""" <div id="inner"> <header>
|
232 |
<h3> 3. This text will be used to generate the card's image.</h3>
|
233 |
</div>""")
|
|
|
256 |
)
|
257 |
generate_final_item_card = gr.Button(value = "Add Text", elem_id = "Generate user card")
|
258 |
|
259 |
+
|
260 |
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)
|
261 |
generate_gallery.select(assign_img_path, outputs = selected_generated_image)
|
262 |
|
|
|
284 |
item_sd_prompt_var,
|
285 |
item_sd_prompt_output])
|
286 |
|
287 |
+
|
288 |
generate_final_item_card.click(card.render_text_on_card, inputs = [selected_generated_image,
|
289 |
item_name_output,
|
290 |
item_type_output,
|
|
|
298 |
],
|
299 |
outputs = generate_gallery )
|
300 |
|
301 |
+
|
302 |
if __name__ == '__main__':
|
303 |
demo.launch(server_name = "0.0.0.0", server_port = 8000, share = False, allowed_paths = ["/media/drakosfire/Shared/","/media/drakosfire/Shared/MerchantBot/card_templates"])
|
304 |
|