WonwoongCho commited on
Commit
889a4b9
·
1 Parent(s): dff3f07

add torchvision to requirement

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -12,19 +12,9 @@ from src.utils_sample import set_seed, resize_and_add_margin
12
  import os
13
 
14
 
15
- dtype = torch.bfloat16
16
- token = os.environ.get("HF_TOKEN")
17
-
18
- pipe = None
19
- pipe = FluxPipeline.from_pretrained(
20
- "black-forest-labs/FLUX.1-dev",
21
- torch_dtype=dtype,
22
- use_auth_token=token
23
- )
24
- pipe = pipe.to("cuda")
25
 
26
  @spaces.GPU
27
- def process_image_and_text(image, scale, seed, text):
28
  set_seed(seed)
29
  print("execution_device 1", pipe._execution_device)
30
  blended_attn_procs = {}
@@ -147,6 +137,17 @@ header = """
147
 
148
  def create_app():
149
 
 
 
 
 
 
 
 
 
 
 
 
150
  with gr.Blocks() as app:
151
  gr.Markdown(header, elem_id="header")
152
  with gr.Row(equal_height=False):
@@ -175,10 +176,10 @@ def create_app():
175
  inputs=[original_image, scale, seed, text],
176
  label="Examples",
177
  )
178
-
179
  submit_btn.click(
180
  fn=process_image_and_text,
181
- inputs=[original_image, scale, seed, text],
182
  outputs=output_image,
183
  )
184
 
 
12
  import os
13
 
14
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  @spaces.GPU
17
+ def process_image_and_text(image, scale, seed, text, pipe):
18
  set_seed(seed)
19
  print("execution_device 1", pipe._execution_device)
20
  blended_attn_procs = {}
 
137
 
138
  def create_app():
139
 
140
+ dtype = torch.bfloat16
141
+ token = os.environ.get("HF_TOKEN")
142
+
143
+ pipe = None
144
+ pipe = FluxPipeline.from_pretrained(
145
+ "black-forest-labs/FLUX.1-dev",
146
+ torch_dtype=dtype,
147
+ use_auth_token=token
148
+ )
149
+ pipe = pipe.to("cuda")
150
+
151
  with gr.Blocks() as app:
152
  gr.Markdown(header, elem_id="header")
153
  with gr.Row(equal_height=False):
 
176
  inputs=[original_image, scale, seed, text],
177
  label="Examples",
178
  )
179
+
180
  submit_btn.click(
181
  fn=process_image_and_text,
182
+ inputs=[original_image, scale, seed, text, pipe],
183
  outputs=output_image,
184
  )
185