liuhaotian commited on
Commit
99cdea0
β€’
1 Parent(s): 4ef7732
Files changed (1) hide show
  1. app.py +1 -19
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  import torch
3
- import argparse
4
  from omegaconf import OmegaConf
5
  from gligen.task_grounded_generation import grounded_generation_box, load_ckpt, load_common_ckpt
6
 
@@ -17,23 +16,6 @@ from huggingface_hub import hf_hub_download
17
  hf_hub_download = partial(hf_hub_download, library_name="gligen_demo")
18
 
19
 
20
- arg_bool = lambda x: x.lower() == 'true'
21
-
22
-
23
- def parse_option():
24
- parser = argparse.ArgumentParser('GLIGen Demo', add_help=False)
25
- parser.add_argument("--folder", type=str, default="create_samples", help="path to OUTPUT")
26
- parser.add_argument("--official_ckpt", type=str, default='ckpts/sd-v1-4.ckpt', help="")
27
- parser.add_argument("--guidance_scale", type=float, default=5, help="")
28
- parser.add_argument("--alpha_scale", type=float, default=1, help="scale tanh(alpha). If 0, the behaviour is same as original model")
29
- parser.add_argument("--load-text-box-generation", type=arg_bool, default=True, help="Load text-box generation pipeline.")
30
- parser.add_argument("--load-text-box-inpainting", type=arg_bool, default=True, help="Load text-box inpainting pipeline.")
31
- parser.add_argument("--load-text-image-box-generation", type=arg_bool, default=True, help="Load text-image-box generation pipeline.")
32
- args = parser.parse_args()
33
- return args
34
- args = parse_option()
35
-
36
-
37
  def load_from_hf(repo_id, filename='diffusion_pytorch_model.bin', subfolder=None):
38
  cache_file = hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder)
39
  return torch.load(cache_file, map_location='cpu')
@@ -47,7 +29,7 @@ def load_ckpt_config_from_hf(modality):
47
  def ckpt_load_helper(modality, is_inpaint, is_style, common_instances=None):
48
  pretrained_ckpt_gligen, config = load_ckpt_config_from_hf(modality)
49
  config = OmegaConf.create( config["_content"] ) # config used in training
50
- config.update( vars(args) )
51
  config.model['params']['is_inpaint'] = is_inpaint
52
  config.model['params']['is_style'] = is_style
53
 
 
1
  import gradio as gr
2
  import torch
 
3
  from omegaconf import OmegaConf
4
  from gligen.task_grounded_generation import grounded_generation_box, load_ckpt, load_common_ckpt
5
 
 
16
  hf_hub_download = partial(hf_hub_download, library_name="gligen_demo")
17
 
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def load_from_hf(repo_id, filename='diffusion_pytorch_model.bin', subfolder=None):
20
  cache_file = hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder)
21
  return torch.load(cache_file, map_location='cpu')
 
29
  def ckpt_load_helper(modality, is_inpaint, is_style, common_instances=None):
30
  pretrained_ckpt_gligen, config = load_ckpt_config_from_hf(modality)
31
  config = OmegaConf.create( config["_content"] ) # config used in training
32
+ config.alpha_scale = 1.0
33
  config.model['params']['is_inpaint'] = is_inpaint
34
  config.model['params']['is_style'] = is_style
35