artificialguybr commited on
Commit
c03b3ba
1 Parent(s): 3b1abe2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -23
app.py CHANGED
@@ -32,28 +32,38 @@ def run_lora(prompt, weight):
32
  # Gradio UI
33
  print("Before Gradio Interface")
34
 
35
- title = gr.HTML("<h1>LoRA the Explorer</h1>")
36
-
37
- gallery = gr.Gallery(
38
- [(item["image"], item["title"]) for item in loras],
39
- label="LoRA Gallery",
40
- allow_preview=False,
41
- columns=3,
42
- )
43
-
44
- prompt = gr.Textbox(label="Prompt", lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA")
45
-
46
- advanced_options = gr.Accordion("Advanced options", open=False)
47
-
48
- weight = gr.Slider(0, 10, value=1, step=0.1, label="LoRA weight")
49
-
50
- result = gr.Image(interactive=False, label="Generated Image")
51
-
52
- gr.Interface(
53
- fn=run_lora,
54
- inputs=[title, gallery, prompt, {"Advanced Options": advanced_options}, weight],
55
- outputs=[result],
56
- css="custom.css" # Make sure your custom CSS file is in the same directory
57
- ).launch()
 
 
 
 
 
 
 
58
 
59
  print("After Gradio Interface")
 
 
 
 
32
  # Gradio UI
33
  print("Before Gradio Interface")
34
 
35
+ # Create a Gradio Blocks interface
36
+ with gr.Blocks() as app:
37
+ title = gr.HTML("<h1>LoRA the Explorer</h1>")
38
+ gallery = gr.Gallery(
39
+ [(item["image"], item["title"]) for item in loras],
40
+ label="LoRA Gallery",
41
+ allow_preview=False,
42
+ columns=3,
43
+ )
44
+ prompt = gr.Textbox(label="Prompt", lines=1, max_lines=1, placeholder="Type a prompt after selecting a LoRA")
45
+ advanced_options = gr.Accordion("Advanced options", open=False)
46
+ weight = gr.Slider(0, 10, value=1, step=0.1, label="LoRA weight")
47
+ result = gr.Image(interactive=False, label="Generated Image")
48
+
49
+ # Link the function to run when the button is clicked
50
+ gr.Row([
51
+ gr.Column([
52
+ title,
53
+ gallery,
54
+ prompt,
55
+ advanced_options,
56
+ weight,
57
+ gr.Button("Run", label="Run").click(
58
+ fn=run_lora,
59
+ inputs=[prompt, weight],
60
+ outputs=[result]
61
+ )
62
+ ]),
63
+ gr.Column([result])
64
+ ])
65
 
66
  print("After Gradio Interface")
67
+
68
+ # Launch the Gradio interface with a queue
69
+ app.launch(debug=True, queue=True)