Jonny001 commited on
Commit
b3b13e2
1 Parent(s): b268816

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -8
app.py CHANGED
@@ -1,30 +1,48 @@
1
  import gradio as gr
2
  import random
 
3
 
4
- #model = gr.load("models/prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA") # <-- This model is also working
5
  model = gr.load("models/Purz/face-projection")
6
 
7
- def generate_image(text, seed):
8
  if seed is not None:
9
  random.seed(seed)
10
 
11
  if text in [example[0] for example in examples]:
12
  print(f"Using example: {text}")
13
 
14
- return model(text)
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  examples = [
17
- ["Humanoid Cat Warrior, Full View", None],
18
- ["Warhammer Sisterhood", None],
19
- ["Future Robots war", None],
20
- ["Fantasy dragon", None]
21
  ]
22
 
23
  interface = gr.Interface(
24
  fn=generate_image,
25
  inputs=[
26
  gr.Textbox(label="Type here your imagination:", placeholder="Type or click an example..."),
27
- gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
 
 
 
 
28
  ],
29
  outputs=gr.Image(label="Generated Image"),
30
  examples=examples,
 
1
  import gradio as gr
2
  import random
3
+ import os
4
 
5
+ # model = gr.load("models/prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA") # <-- This model is also working
6
  model = gr.load("models/Purz/face-projection")
7
 
8
+ def generate_image(text, seed, width, height, guidance_scale, num_inference_steps):
9
  if seed is not None:
10
  random.seed(seed)
11
 
12
  if text in [example[0] for example in examples]:
13
  print(f"Using example: {text}")
14
 
15
+ result_image = model(text)
16
+
17
+ print(f"Width: {width}, Height: {height}, Guidance Scale: {guidance_scale}, Inference Steps: {num_inference_steps}")
18
+
19
+ return result_image
20
+
21
+ def randomize_parameters():
22
+ seed = random.randint(0, 999999)
23
+ width = random.randint(512, 2048)
24
+ height = random.randint(512, 2048)
25
+ guidance_scale = round(random.uniform(0.1, 20.0), 1)
26
+ num_inference_steps = random.randint(1, 40)
27
+
28
+ return seed, width, height, guidance_scale, num_inference_steps
29
 
30
  examples = [
31
+ ["Humanoid Cat Warrior, Full View", *randomize_parameters()],
32
+ ["Warhammer Sisterhood", *randomize_parameters()],
33
+ ["Future Robots war", *randomize_parameters()],
34
+ ["Fantasy dragon", *randomize_parameters()],
35
  ]
36
 
37
  interface = gr.Interface(
38
  fn=generate_image,
39
  inputs=[
40
  gr.Textbox(label="Type here your imagination:", placeholder="Type or click an example..."),
41
+ gr.Slider(label="Seed", minimum=0, maximum=999999, step=1),
42
+ gr.Slider(label="Width", minimum=512, maximum=2048, step=64, value=1024),
43
+ gr.Slider(label="Height", minimum=512, maximum=2048, step=64, value=1024),
44
+ gr.Slider(label="Guidance Scale", minimum=0.1, maximum=20.0, step=0.1, value=3.0),
45
+ gr.Slider(label="Number of inference steps", minimum=1, maximum=40, step=1, value=28),
46
  ],
47
  outputs=gr.Image(label="Generated Image"),
48
  examples=examples,