nroggendorff commited on
Commit
1774837
1 Parent(s): 8f3c856

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -30
app.py CHANGED
@@ -4,43 +4,36 @@ import random
4
 
5
  import torch
6
  from diffusers import FluxPipeline
7
- from huggingface_hub.utils import RepositoryNotFoundError
8
 
9
  pipeline = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)
10
  pipeline.load_lora_weights("pepper13/fluxfw")
11
- pipeline.to("cuda")
12
-
13
- with open("main.css", "r") as css:
14
- link = css
15
 
16
  @spaces.GPU(duration=70)
17
  def generate(prompt):
18
- return pipeline(
19
- prompt=prompt,
20
- width=512,
21
- height=512,
22
- num_inference_steps=20,
23
- guidance_scale=7
24
- ).images[0]
25
 
26
- with gr.Blocks(css=link) as interface:
27
- with gr.Column(elem_classes="interface-container"):
28
- prompt = gr.Textbox(
29
- label="Prompt",
30
- info="Describe the image you want to generate.",
31
- placeholder="e.g., Keanu Reeves holding a neon sign reading 'Hello, world!', 32k HDR, paparazzi",
32
- # lines=1,
33
- elem_classes="text-box"
34
- )
35
-
36
- generate_button = gr.Button("Generate Image", elem_classes="btn")
37
- output = gr.Image(elem_classes="image-output")
38
-
39
- generate_button.click(
40
- fn=generate,
41
- inputs=[prompt],
42
- outputs=[output]
43
- )
 
44
 
45
  if __name__ == "__main__":
46
  interface.launch()
 
4
 
5
  import torch
6
  from diffusers import FluxPipeline
 
7
 
8
  pipeline = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)
9
  pipeline.load_lora_weights("pepper13/fluxfw")
10
+ # pipeline.to("cuda")
 
 
 
11
 
12
  @spaces.GPU(duration=70)
13
  def generate(prompt):
14
+ pipe_end = pipeline(prompt=prompt, width=512, height=512, num_inference_steps=24, guidance_scale=7)
15
+ image = pipe_end.images[0]
16
+ return image
 
 
 
 
17
 
18
+ with open("main.css", "r") as link:
19
+ with gr.Blocks(css=link) as interface:
20
+ with gr.Column(elem_classes="interface-container"):
21
+ prompt = gr.Textbox(
22
+ label="Prompt",
23
+ info="Describe the image you want to generate.",
24
+ placeholder="e.g., Keanu Reeves holding a neon sign reading 'Hello, world!', 32k HDR, paparazzi",
25
+ # lines=1,
26
+ elem_classes="text-box"
27
+ )
28
+
29
+ generate_button = gr.Button("Generate Image", elem_classes="btn")
30
+ output = gr.Image(elem_classes="image-output")
31
+
32
+ generate_button.click(
33
+ fn=generate,
34
+ inputs=[prompt],
35
+ outputs=[output]
36
+ )
37
 
38
  if __name__ == "__main__":
39
  interface.launch()