Commit
·
1f0f854
1
Parent(s):
712055b
Update README.md
Browse files
README.md
CHANGED
@@ -10,4 +10,25 @@ Citations
|
|
10 |
author={Ankush Singal},
|
11 |
year={2023}
|
12 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
```
|
|
|
10 |
author={Ankush Singal},
|
11 |
year={2023}
|
12 |
}
|
13 |
+
```
|
14 |
+
```
|
15 |
+
def load_model_hf(repo_id, filename, ckpt_config_filename, device='cpu'):
|
16 |
+
cache_config_file = hf_hub_download(repo_id=repo_id, filename=ckpt_config_filename)
|
17 |
+
|
18 |
+
args = SLConfig.fromfile(cache_config_file)
|
19 |
+
model = build_model(args)
|
20 |
+
args.device = device
|
21 |
+
|
22 |
+
cache_file = hf_hub_download(repo_id=repo_id, filename=filename)
|
23 |
+
checkpoint = torch.load(cache_file, map_location='cpu')
|
24 |
+
log = model.load_state_dict(clean_state_dict(checkpoint['model']), strict=False)
|
25 |
+
print("Model loaded from {} \n => {}".format(cache_file, log))
|
26 |
+
_ = model.eval()
|
27 |
+
return model
|
28 |
+
|
29 |
+
ckpt_repo_id = "Andyrasika/GroundingDINO"
|
30 |
+
ckpt_filenmae = "groundingdino_swint_ogc.pth"
|
31 |
+
ckpt_config_filename = "GroundingDINO_SwinT_OGC.py"
|
32 |
+
|
33 |
+
model = load_model_hf(ckpt_repo_id, ckpt_filenmae, ckpt_config_filename)
|
34 |
```
|