ameythakur commited on
Commit
5af56ca
·
verified ·
1 Parent(s): 84707de

text2video

Browse files
.gitattributes CHANGED
@@ -27,3 +27,5 @@
27
  *.jpeg filter=lfs diff=lfs merge=lfs -text
28
  *.png filter=lfs diff=lfs merge=lfs -text
29
  *.ipynb filter=lfs diff=lfs merge=lfs -text
 
 
 
27
  *.jpeg filter=lfs diff=lfs merge=lfs -text
28
  *.png filter=lfs diff=lfs merge=lfs -text
29
  *.ipynb filter=lfs diff=lfs merge=lfs -text
30
+ Source[[:space:]]Code/annotator/ckpts/*.pth filter=lfs diff=lfs merge=lfs -text
31
+ Source[[:space:]]Code/annotator/ckpts/*.pt filter=lfs diff=lfs merge=lfs -text
Source Code/annotator/uniformer/__init__.py CHANGED
@@ -11,10 +11,17 @@ checkpoint_file = "https://huggingface.co/lllyasviel/ControlNet/resolve/main/ann
11
  class UniformerDetector:
12
  def __init__(self):
13
  modelpath = os.path.join(annotator_ckpts_path, "upernet_global_small.pth")
 
 
 
14
  if not os.path.exists(modelpath):
15
- raise FileNotFoundError(f"Uniformer model not found in {annotator_ckpts_path}. Please ensure upernet_global_small.pth is present.")
 
 
 
16
  config_file = os.path.join(os.path.dirname(annotator_ckpts_path), "uniformer", "exp", "upernet_global_small", "config.py")
17
- self.model = init_segmentor(config_file, modelpath).cuda()
 
18
 
19
  def __call__(self, img):
20
  result = inference_segmentor(self.model, img)
 
11
  class UniformerDetector:
12
  def __init__(self):
13
  modelpath = os.path.join(annotator_ckpts_path, "upernet_global_small.pth")
14
+ if not os.path.exists(annotator_ckpts_path):
15
+ os.makedirs(annotator_ckpts_path)
16
+
17
  if not os.path.exists(modelpath):
18
+ from torch.hub import download_url_to_file
19
+ print(f"Downloading upernet_global_small from {checkpoint_file}...")
20
+ download_url_to_file(checkpoint_file, modelpath)
21
+
22
  config_file = os.path.join(os.path.dirname(annotator_ckpts_path), "uniformer", "exp", "upernet_global_small", "config.py")
23
+ device = "cuda" if torch.cuda.is_available() else "cpu"
24
+ self.model = init_segmentor(config_file, modelpath, device=device)
25
 
26
  def __call__(self, img):
27
  result = inference_segmentor(self.model, img)