Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -398,11 +398,18 @@ with gr.Blocks(title="Image Character Persona Generator") as iface:
|
|
| 398 |
# Copy to Chat Button
|
| 399 |
copy_to_chat_btn = gr.Button("Use This Persona in Chat")
|
| 400 |
|
| 401 |
-
|
|
|
|
| 402 |
def refresh_character_gallery():
|
| 403 |
image_files = get_character_images()
|
| 404 |
-
return
|
| 405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
# Function to handle gallery selection
|
| 407 |
def gallery_select(evt: gr.SelectData, gallery_images):
|
| 408 |
if gallery_images and evt.index < len(gallery_images):
|
|
@@ -551,20 +558,20 @@ with gr.Blocks(title="Image Character Persona Generator") as iface:
|
|
| 551 |
inputs=[profile_persona],
|
| 552 |
outputs=[system_prompt]
|
| 553 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 554 |
|
| 555 |
-
# Then use it
|
| 556 |
iface.load(
|
| 557 |
fn=initialize_interface,
|
| 558 |
inputs=[profiles_state],
|
| 559 |
outputs=[profile_dropdown, character_gallery]
|
| 560 |
)
|
| 561 |
-
|
| 562 |
-
# Initialize the profiles dropdown and character gallery
|
| 563 |
-
iface.load(
|
| 564 |
-
fn=lambda: (refresh_profiles_list, refresh_character_gallery),
|
| 565 |
-
inputs=[profiles_state],
|
| 566 |
-
outputs=[profile_dropdown, character_gallery]
|
| 567 |
-
)
|
| 568 |
|
| 569 |
# Function to update system prompt in Test tab when persona is generated
|
| 570 |
def update_persona_state(caption, persona, time_output, img_path):
|
|
|
|
| 398 |
# Copy to Chat Button
|
| 399 |
copy_to_chat_btn = gr.Button("Use This Persona in Chat")
|
| 400 |
|
| 401 |
+
|
| 402 |
+
# Modified function
|
| 403 |
def refresh_character_gallery():
|
| 404 |
image_files = get_character_images()
|
| 405 |
+
return image_files # Return just the list of image paths
|
| 406 |
+
|
| 407 |
+
# Modified function
|
| 408 |
+
def gallery_select(evt: gr.SelectData, gallery_images):
|
| 409 |
+
if gallery_images and evt.index < len(gallery_images):
|
| 410 |
+
selected_image = gallery_images[evt.index]
|
| 411 |
+
return selected_image, selected_image
|
| 412 |
+
return None, None
|
| 413 |
# Function to handle gallery selection
|
| 414 |
def gallery_select(evt: gr.SelectData, gallery_images):
|
| 415 |
if gallery_images and evt.index < len(gallery_images):
|
|
|
|
| 558 |
inputs=[profile_persona],
|
| 559 |
outputs=[system_prompt]
|
| 560 |
)
|
| 561 |
+
|
| 562 |
+
# Create a dedicated initialization function
|
| 563 |
+
def initialize_interface(profiles_data):
|
| 564 |
+
profile_names = [p["name"] for p in profiles_data["profiles"]] if profiles_data and "profiles" in profiles_data else []
|
| 565 |
+
image_files = get_character_images()
|
| 566 |
+
return profile_names, image_files # Return raw values, not components
|
| 567 |
|
| 568 |
+
# Then use it in place of your lambda
|
| 569 |
iface.load(
|
| 570 |
fn=initialize_interface,
|
| 571 |
inputs=[profiles_state],
|
| 572 |
outputs=[profile_dropdown, character_gallery]
|
| 573 |
)
|
| 574 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
| 576 |
# Function to update system prompt in Test tab when persona is generated
|
| 577 |
def update_persona_state(caption, persona, time_output, img_path):
|