hysts HF staff multimodalart HF staff commited on
Commit
c453122
1 Parent(s): c628a76

Add progress bar

Browse files

Co-authored-by: Apolinário from multimodal AI art <[email protected]>

Files changed (1) hide show
  1. app.py +30 -3
app.py CHANGED
@@ -5,6 +5,7 @@ import random
5
 
6
  import gradio as gr
7
  import numpy as np
 
8
  import torch
9
 
10
  from model import ADAPTER_NAMES, Model
@@ -25,6 +26,32 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
25
 
26
  model = Model(ADAPTER_NAMES[0])
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  with gr.Blocks(css="style.css") as demo:
29
  gr.Markdown(DESCRIPTION)
30
  gr.DuplicateButton(
@@ -107,7 +134,7 @@ with gr.Blocks(css="style.css") as demo:
107
  inputs=adapter_name,
108
  api_name=False,
109
  ).success(
110
- fn=model.run,
111
  inputs=inputs,
112
  outputs=result,
113
  api_name=False,
@@ -123,7 +150,7 @@ with gr.Blocks(css="style.css") as demo:
123
  inputs=adapter_name,
124
  api_name=False,
125
  ).success(
126
- fn=model.run,
127
  inputs=inputs,
128
  outputs=result,
129
  api_name=False,
@@ -139,7 +166,7 @@ with gr.Blocks(css="style.css") as demo:
139
  inputs=adapter_name,
140
  api_name=False,
141
  ).success(
142
- fn=model.run,
143
  inputs=inputs,
144
  outputs=result,
145
  api_name="run",
 
5
 
6
  import gradio as gr
7
  import numpy as np
8
+ import PIL.Image
9
  import torch
10
 
11
  from model import ADAPTER_NAMES, Model
 
26
 
27
  model = Model(ADAPTER_NAMES[0])
28
 
29
+
30
+ def run(
31
+ image: PIL.Image.Image,
32
+ prompt: str,
33
+ negative_prompt: str,
34
+ num_inference_steps: int = 30,
35
+ guidance_scale: float = 5.0,
36
+ adapter_conditioning_scale: float = 1.0,
37
+ cond_tau: float = 1.0,
38
+ seed: int = 0,
39
+ apply_preprocess: bool = True,
40
+ progress=gr.Progress(track_tqdm=True),
41
+ ) -> list[PIL.Image.Image]:
42
+ return model.run(
43
+ image=image,
44
+ prompt=prompt,
45
+ negative_prompt=negative_prompt,
46
+ num_inference_steps=num_inference_steps,
47
+ guidance_scale=guidance_scale,
48
+ adapter_conditioning_scale=adapter_conditioning_scale,
49
+ cond_tau=cond_tau,
50
+ seed=seed,
51
+ apply_preprocess=apply_preprocess,
52
+ )
53
+
54
+
55
  with gr.Blocks(css="style.css") as demo:
56
  gr.Markdown(DESCRIPTION)
57
  gr.DuplicateButton(
 
134
  inputs=adapter_name,
135
  api_name=False,
136
  ).success(
137
+ fn=run,
138
  inputs=inputs,
139
  outputs=result,
140
  api_name=False,
 
150
  inputs=adapter_name,
151
  api_name=False,
152
  ).success(
153
+ fn=run,
154
  inputs=inputs,
155
  outputs=result,
156
  api_name=False,
 
166
  inputs=adapter_name,
167
  api_name=False,
168
  ).success(
169
+ fn=run,
170
  inputs=inputs,
171
  outputs=result,
172
  api_name="run",