Alibrown commited on
Commit
276668a
·
verified ·
1 Parent(s): 19ab272

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -25
app.py CHANGED
@@ -1,17 +1,7 @@
1
- #
2
  import gradio as gr
3
  from diffusers import DiffusionPipeline
4
  import torch
5
 
6
- # Pipeline global vorinitialisieren für bessere Performance
7
- pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
8
- pipe.load_lora_weights("enhanceaiteam/Flux-uncensored")
9
-
10
- # GPU-Optimierung
11
- if torch.cuda.is_available():
12
- pipe = pipe.to("cuda")
13
- pipe.enable_model_cpu_offload() # Zusätzliche Speicheroptimierung
14
-
15
  def generate_image(
16
  prompt,
17
  width=512,
@@ -20,6 +10,13 @@ def generate_image(
20
  guidance_scale=7.5
21
  ):
22
  try:
 
 
 
 
 
 
 
23
  image = pipe(
24
  prompt=prompt,
25
  width=width,
@@ -32,7 +29,7 @@ def generate_image(
32
  print(f"Fehler bei Bildgenerierung: {e}")
33
  return None
34
 
35
- # Gradio-Interface mit erweiterten Optionen
36
  def create_gradio_interface():
37
  with gr.Blocks() as demo:
38
  gr.Markdown("# Flux Bildgenerator")
@@ -54,26 +51,13 @@ def create_gradio_interface():
54
  inputs=[prompt, width, height, steps, guidance],
55
  outputs=output_image
56
  )
57
-
58
- # Beispiel-Prompts
59
- gr.Examples(
60
- examples=[
61
- ["Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"],
62
- ["Cyberpunk city landscape at night"],
63
- ["Realistic portrait of a wolf in mountain terrain"]
64
- ],
65
- inputs=[prompt]
66
- )
67
 
68
  return demo
69
 
70
  # Hauptausführung
71
  def main():
72
  interface = create_gradio_interface()
73
- interface.launch(
74
- share=True, # Für öffentlichen Zugang
75
- debug=True # Detaillierte Fehlermeldungen
76
- )
77
 
78
  if __name__ == "__main__":
79
  main()
 
 
1
  import gradio as gr
2
  from diffusers import DiffusionPipeline
3
  import torch
4
 
 
 
 
 
 
 
 
 
 
5
  def generate_image(
6
  prompt,
7
  width=512,
 
10
  guidance_scale=7.5
11
  ):
12
  try:
13
+ # Alternativen Flux-Modell verwenden
14
+ pipe = DiffusionPipeline.from_pretrained("enhanceaiteam/Flux-uncensored")
15
+
16
+ # GPU-Optimierung
17
+ if torch.cuda.is_available():
18
+ pipe = pipe.to("cuda")
19
+
20
  image = pipe(
21
  prompt=prompt,
22
  width=width,
 
29
  print(f"Fehler bei Bildgenerierung: {e}")
30
  return None
31
 
32
+ # Gradio-Interface
33
  def create_gradio_interface():
34
  with gr.Blocks() as demo:
35
  gr.Markdown("# Flux Bildgenerator")
 
51
  inputs=[prompt, width, height, steps, guidance],
52
  outputs=output_image
53
  )
 
 
 
 
 
 
 
 
 
 
54
 
55
  return demo
56
 
57
  # Hauptausführung
58
  def main():
59
  interface = create_gradio_interface()
60
+ interface.launch(share=True)
 
 
 
61
 
62
  if __name__ == "__main__":
63
  main()