NikhilJoson commited on
Commit
0d9d6b6
·
verified ·
1 Parent(s): 50af147

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -6,16 +6,17 @@ import random
6
  import numpy as np
7
 
8
  MARKDOWN = """
9
- # FLUX.1 Inpainting 🎨
10
- Shoutout to [Black Forest Labs](https://huggingface.co/black-forest-labs) team for
11
- creating this amazing model, and a big thanks to [Gothos](https://github.com/Gothos)
12
- for taking it to the next level by enabling inpainting with the FLUX.
13
  """
14
 
15
  MAX_SEED = np.iinfo(np.int32).max
16
  DEVICE = "cuda" #if torch.cuda.is_available() else "cpu"
17
 
18
- pipe = FluxInpaintPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
 
 
19
 
20
  @spaces.GPU()
21
  def process(input_image_editor, mask_image, input_text, strength, seed, randomize_seed, num_inference_steps, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
@@ -34,9 +35,9 @@ def process(input_image_editor, mask_image, input_text, strength, seed, randomiz
34
 
35
  generator = torch.Generator(device=DEVICE).manual_seed(seed)
36
 
37
- result = pipe(prompt=input_text, image=image, mask_image=mask_image, width=width, height=height,
38
- strength=strength, num_inference_steps=num_inference_steps, generator=generator,
39
- guidance_scale=guidance_scale).images[0]
40
 
41
  return result, mask_image, seed
42
 
 
6
  import numpy as np
7
 
8
  MARKDOWN = """
9
+ # Prompt Canvas🎨
10
+ Thanks to [Black Forest Labs](https://huggingface.co/black-forest-labs) team for creating this amazing model,
11
+ and a big thanks to [Gothos](https://github.com/Gothos) for taking it to the next level by enabling inpainting with the FLUX.
 
12
  """
13
 
14
  MAX_SEED = np.iinfo(np.int32).max
15
  DEVICE = "cuda" #if torch.cuda.is_available() else "cpu"
16
 
17
+ inpaint_pipe = FluxInpaintPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
18
+
19
+
20
 
21
  @spaces.GPU()
22
  def process(input_image_editor, mask_image, input_text, strength, seed, randomize_seed, num_inference_steps, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
 
35
 
36
  generator = torch.Generator(device=DEVICE).manual_seed(seed)
37
 
38
+ result = inpaint_pipe(prompt=input_text, image=image, mask_image=mask_image, width=width, height=height,
39
+ strength=strength, num_inference_steps=num_inference_steps, generator=generator,
40
+ guidance_scale=guidance_scale).images[0]
41
 
42
  return result, mask_image, seed
43