Kohaku-Blueleaf commited on
Commit
0eabe5d
β€’
1 Parent(s): 228ab90

add seeding and avoid latest transformers

Browse files
__pycache__/diff.cpython-311.pyc ADDED
Binary file (6.61 kB). View file
 
__pycache__/dtg.cpython-311.pyc ADDED
Binary file (4.32 kB). View file
 
__pycache__/meta.cpython-311.pyc ADDED
Binary file (1.37 kB). View file
 
app.py CHANGED
@@ -33,6 +33,7 @@ def gen(
33
  style: str,
34
  base_prompt: str,
35
  addon_prompt: str = "",
 
36
  ):
37
  global current_dtg_model, current_sdxl_model, sdxl_pipe
38
  if sdxl_model != current_sdxl_model:
@@ -44,7 +45,9 @@ def gen(
44
  current_dtg_model = dtg_model
45
 
46
  t0 = time_ns()
47
- seed = random.randint(0, 2**31 - 1)
 
 
48
 
49
  prompt = (
50
  f"{base_prompt}, {addon_prompt}, "
@@ -79,7 +82,11 @@ def gen(
79
  torch.cuda.empty_cache()
80
  t1 = time_ns()
81
 
82
- return result.convert("RGB"), full_prompt, f"Cost: {(t1 - t0) / 1e9:.4}sec"
 
 
 
 
83
 
84
 
85
  if __name__ == "__main__":
@@ -119,18 +126,26 @@ click "Next" button until you get the dragon girl you like.
119
  label="DTG Model",
120
  value=models.model_list[0],
121
  )
122
- base_prompt = gr.Textbox(
123
- label="Base prompt",
124
- lines=1,
125
- value="1girl, solo, dragon girl, dragon wings, dragon horns, dragon tail",
126
- interactive=False,
127
- )
128
  with gr.Row():
 
 
 
 
 
 
129
  addon_propmt = gr.Textbox(
130
  label="Addon prompt",
131
  lines=1,
132
  value="cowboy shot",
133
  )
 
 
 
 
 
 
 
 
134
  style = gr.Dropdown(
135
  DEFAULT_STYLE_LIST,
136
  label="Style",
@@ -146,7 +161,7 @@ click "Next" button until you get the dragon girl you like.
146
 
147
  submit.click(
148
  fn=gen,
149
- inputs=[sdxl_model, dtg_model, style, base_prompt, addon_propmt],
150
  outputs=[result, dtg_output, cost_time],
151
  )
152
 
 
33
  style: str,
34
  base_prompt: str,
35
  addon_prompt: str = "",
36
+ seed: int = -1,
37
  ):
38
  global current_dtg_model, current_sdxl_model, sdxl_pipe
39
  if sdxl_model != current_sdxl_model:
 
45
  current_dtg_model = dtg_model
46
 
47
  t0 = time_ns()
48
+ seed = int(seed)
49
+ if seed == -1:
50
+ seed = random.randint(0, 2**31 - 1)
51
 
52
  prompt = (
53
  f"{base_prompt}, {addon_prompt}, "
 
82
  torch.cuda.empty_cache()
83
  t1 = time_ns()
84
 
85
+ return (
86
+ result.convert("RGB"),
87
+ full_prompt,
88
+ f"Cost: {(t1 - t0) / 1e9:.4}sec || Seed: {seed}",
89
+ )
90
 
91
 
92
  if __name__ == "__main__":
 
126
  label="DTG Model",
127
  value=models.model_list[0],
128
  )
 
 
 
 
 
 
129
  with gr.Row():
130
+ base_prompt = gr.Textbox(
131
+ label="Base prompt",
132
+ lines=1,
133
+ value="1girl, solo, dragon girl, dragon wings, dragon horns, dragon tail",
134
+ interactive=False,
135
+ )
136
  addon_propmt = gr.Textbox(
137
  label="Addon prompt",
138
  lines=1,
139
  value="cowboy shot",
140
  )
141
+ with gr.Row():
142
+ seed = gr.Number(
143
+ label="Seed (-1 for random)",
144
+ value=-1,
145
+ minimum=-1,
146
+ maximum=2**31 - 1,
147
+ precision=0,
148
+ )
149
  style = gr.Dropdown(
150
  DEFAULT_STYLE_LIST,
151
  label="Style",
 
161
 
162
  submit.click(
163
  fn=gen,
164
+ inputs=[sdxl_model, dtg_model, style, base_prompt, addon_propmt, seed],
165
  outputs=[result, dtg_output, cost_time],
166
  )
167
 
diff.py CHANGED
@@ -23,6 +23,7 @@ def set_timesteps_polyexponential(self, orig_sigmas, num_inference_steps, device
23
 
24
  def model_forward(k_diffusion_model: torch.nn.Module):
25
  orig_forward = k_diffusion_model.forward
 
26
  def forward(*args, **kwargs):
27
  with torch.autocast(device_type="cuda", dtype=torch.float16):
28
  result = orig_forward(*args, **kwargs)
 
23
 
24
  def model_forward(k_diffusion_model: torch.nn.Module):
25
  orig_forward = k_diffusion_model.forward
26
+
27
  def forward(*args, **kwargs):
28
  with torch.autocast(device_type="cuda", dtype=torch.float16):
29
  result = orig_forward(*args, **kwargs)
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  diffusers
2
- transformers
3
  k_diffusion
4
  requests
5
  sentencepiece
 
1
  diffusers
2
+ transformers<4.39
3
  k_diffusion
4
  requests
5
  sentencepiece