NikhilJoson commited on
Commit
e6654e6
1 Parent(s): abf5a91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -7,7 +7,7 @@ import torch
7
  import spaces
8
  import gradio as gr
9
 
10
- from diffusers import FluxInpaintPipeline
11
  import google.generativeai as genai
12
 
13
 
@@ -49,14 +49,19 @@ def gemini_predict(prompt):
49
  MAX_SEED = np.iinfo(np.int32).max
50
  DEVICE = "cuda" #if torch.cuda.is_available() else "cpu"
51
 
52
- #Setting up Flux (Schnell) Inpainting, with Realism LoRA weights
53
- inpaint_pipe = FluxInpaintPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
54
- inpaint_pipe.load_lora_weights('hugovntr/flux-schnell-realism', weight_name='schnell-realism_v2.3.safetensors', adapter_name="better")
55
- inpaint_pipe.set_adapters(["better"], adapter_weights=[2.6])
56
- inpaint_pipe.fuse_lora(adapter_name=["better"], lora_scale=1.0)
57
- inpaint_pipe.unload_lora_weights()
58
 
59
- torch.cuda.empty_cache()
 
 
 
 
 
 
 
 
 
60
 
61
  @spaces.GPU()
62
  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)):
 
7
  import spaces
8
  import gradio as gr
9
 
10
+ from diffusers import FluxTransformer2DModel, FluxInpaintPipeline
11
  import google.generativeai as genai
12
 
13
 
 
49
  MAX_SEED = np.iinfo(np.int32).max
50
  DEVICE = "cuda" #if torch.cuda.is_available() else "cpu"
51
 
52
+ #Setting up Flux (Schnell) Inpainting
53
+ #inpaint_pipe = FluxInpaintPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
 
 
 
 
54
 
55
+ transformer_SchnellReal = FluxTransformer2DModel.from_single_file("https://huggingface.co/SG161222/RealFlux_1.0b_Schnell/blob/main/4%20-%20Schnell%20Transformer%20Version/RealFlux_1.0b_Schnell_Transformer.safetensors", torch_dtype=torch.bfloat16)
56
+ inpaint_pipe = FluxInpaintPipeline.from_pretrained(bfl_repo, transformer=transformer_SchnellReal, torch_dtype=dtype).to(DEVICE)
57
+
58
+ #Uncomment the following 4 lines, if you want LoRA Realism weights added to the pipeline
59
+ # inpaint_pipe.load_lora_weights('hugovntr/flux-schnell-realism', weight_name='schnell-realism_v2.3.safetensors', adapter_name="better")
60
+ # inpaint_pipe.set_adapters(["better"], adapter_weights=[2.6])
61
+ # inpaint_pipe.fuse_lora(adapter_name=["better"], lora_scale=1.0)
62
+ # inpaint_pipe.unload_lora_weights()
63
+
64
+ #torch.cuda.empty_cache()
65
 
66
  @spaces.GPU()
67
  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)):