Fabrice-TIERCELIN commited on
Commit
60e968d
1 Parent(s): 6638ae9

Add the init of SUPIR

Browse files
Files changed (1) hide show
  1. GenVideo_app.py +45 -0
GenVideo_app.py CHANGED
@@ -28,6 +28,51 @@ hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0F.ckpt", local_dir=
28
  hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0Q.ckpt", local_dir="yushan777_SUPIR")
29
  hf_hub_download(repo_id="RunDiffusion/Juggernaut-XL-Lightning", filename="Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors", local_dir="RunDiffusion_Juggernaut-XL-Lightning")
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # Available adapters (replace with your actual adapter names)
33
  adapter_options = {
 
28
  hf_hub_download(repo_id="camenduru/SUPIR", filename="SUPIR-v0Q.ckpt", local_dir="yushan777_SUPIR")
29
  hf_hub_download(repo_id="RunDiffusion/Juggernaut-XL-Lightning", filename="Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors", local_dir="RunDiffusion_Juggernaut-XL-Lightning")
30
 
31
+ parser = argparse.ArgumentParser()
32
+ parser.add_argument("--opt", type=str, default='options/SUPIR_v0.yaml')
33
+ parser.add_argument("--ip", type=str, default='127.0.0.1')
34
+ parser.add_argument("--port", type=int, default='6688')
35
+ parser.add_argument("--no_llava", action='store_true', default=False)
36
+ parser.add_argument("--use_image_slider", action='store_true', default=False)
37
+ parser.add_argument("--log_history", action='store_true', default=False)
38
+ parser.add_argument("--loading_half_params", action='store_true', default=False)
39
+ parser.add_argument("--use_tile_vae", action='store_true', default=False)
40
+ parser.add_argument("--encoder_tile_size", type=int, default=512)
41
+ parser.add_argument("--decoder_tile_size", type=int, default=64)
42
+ parser.add_argument("--load_8bit_llava", action='store_true', default=False)
43
+ args = parser.parse_args()
44
+ server_ip = args.ip
45
+ server_port = args.port
46
+ use_llava = not args.no_llava
47
+
48
+ if torch.cuda.device_count() > 0:
49
+ if torch.cuda.device_count() >= 2:
50
+ SUPIR_device = 'cuda:0'
51
+ LLaVA_device = 'cuda:1'
52
+ elif torch.cuda.device_count() == 1:
53
+ SUPIR_device = 'cuda:0'
54
+ LLaVA_device = 'cuda:0'
55
+ else:
56
+ SUPIR_device = 'cpu'
57
+ LLaVA_device = 'cpu'
58
+
59
+ # load SUPIR
60
+ model, default_setting = create_SUPIR_model(args.opt, SUPIR_sign='Q', load_default_setting=True)
61
+ if args.loading_half_params:
62
+ model = model.half()
63
+ if args.use_tile_vae:
64
+ model.init_tile_vae(encoder_tile_size=args.encoder_tile_size, decoder_tile_size=args.decoder_tile_size)
65
+ model = model.to(SUPIR_device)
66
+ model.first_stage_model.denoise_encoder_s1 = copy.deepcopy(model.first_stage_model.denoise_encoder)
67
+ model.current_model = 'v0-Q'
68
+ ckpt_Q, ckpt_F = load_QF_ckpt(args.opt)
69
+
70
+ # load LLaVA
71
+ if use_llava:
72
+ llava_agent = LLavaAgent(LLAVA_MODEL_PATH, device=LLaVA_device, load_8bit=args.load_8bit_llava, load_4bit=False)
73
+ else:
74
+ llava_agent = None
75
+
76
 
77
  # Available adapters (replace with your actual adapter names)
78
  adapter_options = {