NikhilJoson commited on
Commit
123dc2e
1 Parent(s): 8a8f172

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -43,15 +43,20 @@ def gemini_predict(prompt):
43
  Query : {prompt}
44
  """
45
  response = gemini_flash.generate_content(system_message)
46
- return(response.text)
47
 
48
 
49
  MAX_SEED = np.iinfo(np.int32).max
50
  DEVICE = "cuda" #if torch.cuda.is_available() else "cpu"
51
 
 
52
  inpaint_pipe = FluxInpaintPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
53
- inpaint_pipe.load_lora_weights('hugovntr/flux-schnell-realism', weight_name='schnell-realism_v1')
 
 
 
54
 
 
55
 
56
  @spaces.GPU()
57
  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)):
@@ -133,11 +138,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
133
  type='pil', image_mode='RGB', label='Generated Mask')
134
  with gr.Accordion("Debug Info", open=False):
135
  output_seed = gr.Number(label="Used Seed")
 
136
 
137
  submit_button_component.click(
138
  fn=process,
139
  inputs=[input_image_component, uploaded_mask_component, input_text_component, strength_slider, seed_number, randomize_seed, num_inference_steps, guidance_scale],
140
- outputs=[output_image_component, output_mask_component, output_seed]
141
  )
142
 
143
  demo.launch(debug=False, show_error=True)
 
43
  Query : {prompt}
44
  """
45
  response = gemini_flash.generate_content(system_message)
46
+ return(str(response.text)[-2])
47
 
48
 
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=[1.0])
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)):
 
138
  type='pil', image_mode='RGB', label='Generated Mask')
139
  with gr.Accordion("Debug Info", open=False):
140
  output_seed = gr.Number(label="Used Seed")
141
+ gr.Textbox(gemini_predict(prompt))
142
 
143
  submit_button_component.click(
144
  fn=process,
145
  inputs=[input_image_component, uploaded_mask_component, input_text_component, strength_slider, seed_number, randomize_seed, num_inference_steps, guidance_scale],
146
+ outputs=[output_image_component, output_mask_component, output_seed, identified_item]
147
  )
148
 
149
  demo.launch(debug=False, show_error=True)