feng2022 commited on
Commit
67683e8
1 Parent(s): 89d1ee7

Update Time_TravelRephotography/projector.py

Browse files
Time_TravelRephotography/projector.py CHANGED
@@ -35,6 +35,9 @@ from models.degrade import (
35
  Downsample,
36
  )
37
 
 
 
 
38
 
39
  def set_random_seed(seed: int):
40
  # FIXME (xuanluo): this setup still allows randomness somehow
@@ -67,11 +70,15 @@ def normalize(img: torch.Tensor, mean=0.5, std=0.5):
67
  return (img - mean) / std
68
 
69
 
70
- def create_generator(args: Namespace, device: torch.device):
71
- generator = Generator(args.generator_size, 512, 8)
72
- generator.load_state_dict(torch.load(args.ckpt)['g_ema'], strict=False)
 
 
 
 
73
  generator.eval()
74
- generator = generator.to(device)
75
  return generator
76
 
77
 
 
35
  Downsample,
36
  )
37
 
38
+ from huggingface_hub import hf_hub_download
39
+ TOKEN = "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"
40
+
41
 
42
  def set_random_seed(seed: int):
43
  # FIXME (xuanluo): this setup still allows randomness somehow
 
70
  return (img - mean) / std
71
 
72
 
73
+ def create_generator(file_name: str, path:str,args: Namespace, device: torch.device):
74
+ path = hf_hub_download(f'{path}',
75
+ f'{file_name}',
76
+ use_auth_token=TOKEN)
77
+ with open(path, 'rb') as f:
78
+ generator = Generator(args.generator_size, 512, 8)
79
+ generator.load_state_dict(torch.load(f)['g_ema'], strict=False)
80
  generator.eval()
81
+ generator.to(device)
82
  return generator
83
 
84