artificialguybr commited on
Commit
057bc07
1 Parent(s): 10fbca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -27
app.py CHANGED
@@ -25,35 +25,39 @@ def run_lora(prompt):
25
  image_bytes = query(payload, api_url, token)
26
  return Image.open(image_bytes)
27
 
28
-
29
  # Gradio UI
30
- print("Before Gradio Interface")
31
-
32
  with gr.Blocks(css="custom.css") as app:
33
  title = gr.HTML("<h1>LoRA the Explorer</h1>")
34
- gallery = gr.Gallery(
35
- [(item["image"], item["title"]) for item in loras],
36
- label="LoRA Gallery",
37
- allow_preview=False,
38
- columns=3,
39
- )
40
- prompt = gr.Textbox(label="Prompt", lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA")
41
- result = gr.Image(interactive=False, label="Generated Image")
42
-
43
  with gr.Row():
44
- with gr.Column(): # Removed the width parameter
45
- title
46
- gallery
47
- with gr.Column(): # Removed the width parameter
48
- prompt
49
- gr.Button("Run").click(
50
- fn=run_lora,
51
- inputs=[prompt],
52
- outputs=[result]
53
- )
54
- result
55
-
56
- print("After Gradio Interface")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- # Launch the Gradio interface with a queue and specify the width here
59
- app.launch(debug=True, layout=("100%", "100%")) # Added layout parameter
 
25
  image_bytes = query(payload, api_url, token)
26
  return Image.open(image_bytes)
27
 
 
28
  # Gradio UI
 
 
29
  with gr.Blocks(css="custom.css") as app:
30
  title = gr.HTML("<h1>LoRA the Explorer</h1>")
31
+ selected_state = gr.State()
 
 
 
 
 
 
 
 
32
  with gr.Row():
33
+ gallery = gr.Gallery(
34
+ [(item["image"], item["title"]) for item in loras],
35
+ label="LoRA Gallery",
36
+ allow_preview=False,
37
+ columns=3
38
+ )
39
+ with gr.Column():
40
+ prompt_title = gr.Markdown("### Click on a LoRA in the gallery to select it")
41
+ with gr.Row():
42
+ prompt = gr.Textbox(label="Prompt", show_label=False, lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA")
43
+ button = gr.Button("Run")
44
+ result = gr.Image(interactive=False, label="Generated Image")
45
+ with gr.Accordion("Advanced options", open=False):
46
+ # Add any advanced options you need here
47
+
48
+ gallery.select(
49
+ # Define your update_selection function
50
+ )
51
+ prompt.submit(
52
+ fn=run_lora,
53
+ inputs=[prompt],
54
+ outputs=[result]
55
+ )
56
+ button.click(
57
+ fn=run_lora,
58
+ inputs=[prompt],
59
+ outputs=[result]
60
+ )
61
 
62
+ app.queue(max_size=20)
63
+ app.launch()