Profakerr commited on
Commit
8b7ebd7
·
verified ·
1 Parent(s): 1c2d937

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -8,7 +8,7 @@ lora_path = "OedoSoldier/detail-tweaker-lora"
8
  vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse").to("cuda")
9
 
10
  @spaces.GPU
11
- def generate_image(prompt, negative_prompt, num_inference_steps=30, guidance_scale=7.0,model="Real6.0"):
12
 
13
  if model == "Real5.0":
14
  model_id = "SG161222/Realistic_Vision_V5.0_noVAE"
@@ -35,17 +35,18 @@ def generate_image(prompt, negative_prompt, num_inference_steps=30, guidance_sca
35
 
36
 
37
  # Generate the image
38
- image = pipe(
39
  prompt = prompt,
40
  negative_prompt = negative_prompt,
41
  cross_attention_kwargs = {"scale":1},
42
  num_inference_steps = num_inference_steps,
43
  guidance_scale = guidance_scale,
44
  width = 720,
45
- height = 720
 
46
  ).images[0]
47
 
48
- return image
49
 
50
  title = """<h1 align="center">ProFaker</h1>"""
51
  # Create the Gradio interface
@@ -72,6 +73,13 @@ with gr.Blocks() as demo:
72
  value="Real6.0",
73
  label="Model",
74
  )
 
 
 
 
 
 
 
75
  steps_slider = gr.Slider(
76
  minimum=1,
77
  maximum=100,
@@ -88,13 +96,19 @@ with gr.Blocks() as demo:
88
  )
89
  with gr.Column():
90
  # Output component
91
- image_output = gr.Image(label="Generated Image")
 
 
 
 
 
 
92
 
93
 
94
  # Connect the interface to the generation function
95
  generate_button.click(
96
  fn=generate_image,
97
- inputs=[prompt, negative_prompt, steps_slider, guidance_slider, model],
98
  outputs=image_output
99
  )
100
 
 
8
  vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse").to("cuda")
9
 
10
  @spaces.GPU
11
+ def generate_image(prompt, negative_prompt, num_inference_steps=30, guidance_scale=7.0,model="Real6.0",num_images_slider=1):
12
 
13
  if model == "Real5.0":
14
  model_id = "SG161222/Realistic_Vision_V5.0_noVAE"
 
35
 
36
 
37
  # Generate the image
38
+ result = pipe(
39
  prompt = prompt,
40
  negative_prompt = negative_prompt,
41
  cross_attention_kwargs = {"scale":1},
42
  num_inference_steps = num_inference_steps,
43
  guidance_scale = guidance_scale,
44
  width = 720,
45
+ height = 720,
46
+ num_images_per_prompt=num_images
47
  ).images[0]
48
 
49
+ return result.images
50
 
51
  title = """<h1 align="center">ProFaker</h1>"""
52
  # Create the Gradio interface
 
73
  value="Real6.0",
74
  label="Model",
75
  )
76
+ num_images_slider = gr.Slider( # New slider for number of images
77
+ minimum=1,
78
+ maximum=4,
79
+ value=1,
80
+ step=1,
81
+ label="Number of Images to Generate"
82
+ )
83
  steps_slider = gr.Slider(
84
  minimum=1,
85
  maximum=100,
 
96
  )
97
  with gr.Column():
98
  # Output component
99
+ gallery = gr.Gallery(
100
+ label="Generated Images",
101
+ show_label=True,
102
+ elem_id="gallery",
103
+ columns=2,
104
+ rows=2
105
+ )
106
 
107
 
108
  # Connect the interface to the generation function
109
  generate_button.click(
110
  fn=generate_image,
111
+ inputs=[prompt, negative_prompt, steps_slider, guidance_slider, model, num_images_slider],
112
  outputs=image_output
113
  )
114