Ffftdtd5dtft commited on
Commit
1f2e94a
·
verified ·
1 Parent(s): a7950e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import numpy as np
3
  import random
4
- import spaces
5
  import torch
6
  from diffusers import DiffusionPipeline
7
  from accelerate import init_empty_weights, load_checkpoint_and_dispatch
@@ -17,8 +16,11 @@ def load_model():
17
  global pipe
18
  if pipe is None:
19
  with init_empty_weights():
20
- pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=dtype)
21
- # Cargar el modelo en la RAM y despachar los pesos a la GPU
 
 
 
22
  pipe = load_checkpoint_and_dispatch(
23
  pipe,
24
  "black-forest-labs/FLUX.1-schnell",
@@ -40,24 +42,24 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_in
40
  images = []
41
  for _ in range(num_images):
42
  image = pipe(
43
- prompt = prompt,
44
- width = width,
45
- height = height,
46
- num_inference_steps = num_inference_steps,
47
- generator = generator,
48
  guidance_scale=0.0
49
  ).images[0]
50
  images.append(image)
51
 
52
  return images, seed
53
-
54
  examples = [
55
  "a tiny astronaut hatching from an egg on the moon",
56
  "a cat holding a sign that says hello world",
57
  "an anime illustration of a wiener schnitzel",
58
  ]
59
 
60
- css="""
61
  #col-container {
62
  margin: 0 auto;
63
  max-width: 520px;
@@ -149,4 +151,5 @@ with gr.Blocks(css=css) as demo:
149
  outputs = [results, seed]
150
  )
151
 
152
- demo.launch()
 
 
1
  import gradio as gr
2
  import numpy as np
3
  import random
 
4
  import torch
5
  from diffusers import DiffusionPipeline
6
  from accelerate import init_empty_weights, load_checkpoint_and_dispatch
 
16
  global pipe
17
  if pipe is None:
18
  with init_empty_weights():
19
+ pipe = DiffusionPipeline.from_pretrained(
20
+ "black-forest-labs/FLUX.1-schnell",
21
+ torch_dtype=dtype
22
+ )
23
+ # Despachar los pesos a la GPU (sin "named_parameters")
24
  pipe = load_checkpoint_and_dispatch(
25
  pipe,
26
  "black-forest-labs/FLUX.1-schnell",
 
42
  images = []
43
  for _ in range(num_images):
44
  image = pipe(
45
+ prompt=prompt,
46
+ width=width,
47
+ height=height,
48
+ num_inference_steps=num_inference_steps,
49
+ generator=generator,
50
  guidance_scale=0.0
51
  ).images[0]
52
  images.append(image)
53
 
54
  return images, seed
55
+
56
  examples = [
57
  "a tiny astronaut hatching from an egg on the moon",
58
  "a cat holding a sign that says hello world",
59
  "an anime illustration of a wiener schnitzel",
60
  ]
61
 
62
+ css = """
63
  #col-container {
64
  margin: 0 auto;
65
  max-width: 520px;
 
151
  outputs = [results, seed]
152
  )
153
 
154
+ # Crear un enlace público con share=True
155
+ demo.launch(share=True)