lichorosario commited on
Commit
7abaf33
·
verified ·
1 Parent(s): 0c78e19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +120 -16
app.py CHANGED
@@ -8,35 +8,139 @@ api_key = os.getenv('HF_API_KEY')
8
 
9
  from gradio_client import Client
10
 
 
 
11
 
12
- def predict(prompt):
13
  client = Client("fffiloni/sd-xl-custom-model")
14
  result = client.predict(
15
- custom_model="lichorosario/dott_remastered_style_lora_sdxl",
16
  api_name="/load_model"
17
  )
18
 
19
  client = Client("fffiloni/sd-xl-custom-model")
20
  result = client.predict(
21
- custom_model="lichorosario/dott_remastered_style_lora_sdxl",
22
- weight_name="dott_style.safetensors",
23
- prompt=prompt,
24
- inf_steps=25,
25
- guidance_scale=12,
26
- width=1024,
27
- height=512,
28
- seed=-1,
29
- lora_weight=1,
30
  api_name="/infer"
31
  )
32
 
33
  return result
34
 
35
- with gr.Blocks() as demo:
36
- inputs = gr.Textbox(label="Prompt")
37
- outputs = [gr.Image(label="Image"), gr.Textbox(label="Seed")]
38
- greet_btn = gr.Button("Generate")
39
- greet_btn.click(fn=predict, inputs=inputs, outputs=outputs, api_name="predict")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  demo.launch()
42
 
 
8
 
9
  from gradio_client import Client
10
 
11
+ custom_model="lichorosario/dott_remastered_style_lora_sdxl",
12
+ weight_name="dott_style.safetensors",
13
 
14
+ def infer (custom_model, weight_name, prompt, inf_steps, guidance_scale, width, height, seed, lora_weight, progress=gr.Progress(track_tqdm=True)):
15
  client = Client("fffiloni/sd-xl-custom-model")
16
  result = client.predict(
17
+ custom_model=custom_model,
18
  api_name="/load_model"
19
  )
20
 
21
  client = Client("fffiloni/sd-xl-custom-model")
22
  result = client.predict(
23
+ custom_model=custom_model,
24
+ weight_name=weight_name,
25
+ prompt="dott style. "+prompt,
26
+ inf_steps=inf_steps,
27
+ guidance_scale=guidance_scale,
28
+ width=width,
29
+ height=height,
30
+ seed=-seed,
31
+ lora_weight=lora_weight,
32
  api_name="/infer"
33
  )
34
 
35
  return result
36
 
37
+
38
+
39
+
40
+ css="""
41
+ #col-container{
42
+ margin: 0 auto;
43
+ max-width: 720px;
44
+ text-align: left;
45
+ }
46
+ div#warning-duplicate {
47
+ background-color: #ebf5ff;
48
+ padding: 0 16px 16px;
49
+ margin: 20px 0;
50
+ }
51
+ div#warning-duplicate > .gr-prose > h2, div#warning-duplicate > .gr-prose > p {
52
+ color: #0f4592!important;
53
+ }
54
+ div#warning-duplicate strong {
55
+ color: #0f4592;
56
+ }
57
+ p.actions {
58
+ display: flex;
59
+ align-items: center;
60
+ margin: 20px 0;
61
+ }
62
+ div#warning-duplicate .actions a {
63
+ display: inline-block;
64
+ margin-right: 10px;
65
+ }
66
+ button#load_model_btn{
67
+ height: 46px;
68
+ }
69
+ #status_info{
70
+ font-size: 0.9em;
71
+ }
72
+ .custom-color {
73
+ color: #030303 !important;
74
+ }
75
+ """
76
+
77
+ with gr.Blocks(css=css) as demo:
78
+ with gr.Column(elem_id="col-container"):
79
+ prompt_in = gr.Textbox(
80
+ label="Your Prompt",
81
+ info = "Dont' forget to include your trigger word if necessary"
82
+ )
83
+ with gr.Accordion("Advanced Settings", open=False):
84
+ with gr.Row():
85
+ inf_steps = gr.Slider(
86
+ label="Inference steps",
87
+ minimum=12,
88
+ maximum=50,
89
+ step=1,
90
+ value=25
91
+ )
92
+ guidance_scale = gr.Slider(
93
+ label="Guidance scale",
94
+ minimum=0.0,
95
+ maximum=50.0,
96
+ step=0.1,
97
+ value=7.5
98
+ )
99
+ with gr.Row():
100
+ width = gr.Slider(
101
+ label="Width",
102
+ minimum=256,
103
+ maximum=2048,
104
+ step=32,
105
+ value=1024,
106
+ )
107
+ height = gr.Slider(
108
+ label="Height",
109
+ minimum=256,
110
+ maximum=2048,
111
+ step=32,
112
+ value=1024,
113
+ )
114
+
115
+ with gr.Row():
116
+ seed = gr.Slider(
117
+ label="Seed",
118
+ info = "-1 denotes a random seed",
119
+ minimum=-1,
120
+ maximum=423538377342,
121
+ step=1,
122
+ value=-1
123
+ )
124
+ last_used_seed = gr.Number(
125
+ label = "Last used seed",
126
+ info = "the seed used in the last generation",
127
+ )
128
+ lora_weight = gr.Slider(
129
+ label="LoRa weigth",
130
+ minimum=0.0,
131
+ maximum=1.0,
132
+ step=0.01,
133
+ value=1.0
134
+ )
135
+ submit_btn = gr.Button("Submit")
136
+ image_out = gr.Image(label="Image output")
137
+
138
+ submit_btn.click(
139
+ fn = infer,
140
+ inputs = [custom_model, weight_name, prompt_in, inf_steps, guidance_scale, width, height, seed, lora_weight],
141
+ outputs = [image_out, last_used_seed]
142
+ )
143
+
144
 
145
  demo.launch()
146