Ryan Chesler commited on
Commit
d2e30b3
·
1 Parent(s): b452d69

Update Demo, README, and model with local tweaks

Browse files
Files changed (3) hide show
  1. Demo.ipynb +2 -2
  2. README.md +2 -2
  3. nemotron_page_elements_v3/model.py +3 -3
Demo.ipynb CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d1f448b52f30c3bdb41d9db1c3fea0274ac39726338c19a8b48005017245d1dd
3
- size 2363478
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:433fa0f144f075b75de5f2fa2925a808b6b15c18eaf58f591e09f50c3e121b9c
3
+ size 1812492
README.md CHANGED
@@ -130,8 +130,8 @@ import numpy as np
130
  import matplotlib.pyplot as plt
131
  from PIL import Image
132
 
133
- from model import define_model
134
- from utils import plot_sample, postprocess_preds_page_element, reformat_for_plotting
135
 
136
  # Load image
137
  path = "./example.png"
 
130
  import matplotlib.pyplot as plt
131
  from PIL import Image
132
 
133
+ from nemotron_page_elements_v3.model import define_model
134
+ from nemotron_page_elements_v3.utils import plot_sample, postprocess_preds_page_element, reformat_for_plotting
135
 
136
  # Load image
137
  path = "./example.png"
nemotron_page_elements_v3/model.py CHANGED
@@ -36,9 +36,9 @@ def define_model(config_name: str = "page_element_v3", verbose: bool = True) ->
36
  if verbose:
37
  print(" -> Loading weights from", config.ckpt)
38
 
39
- # Use importlib.resources to locate 'weights.pth' inside the module's directory (nmtron_page_elements_v3)
40
- with importlib.resources.path("nemotron_page_elements_v3", "weights.pth") as weights_path:
41
- ckpt = torch.load(str(weights_path), map_location="cpu", weights_only=False)
42
  model.load_state_dict(ckpt["model"], strict=True)
43
 
44
  model = YoloXWrapper(model, config)
 
36
  if verbose:
37
  print(" -> Loading weights from", config.ckpt)
38
 
39
+ # Locate 'weights.pth' in the same directory as this model.py file
40
+ weights_path = os.path.join(os.path.dirname(__file__), "weights.pth")
41
+ ckpt = torch.load(weights_path, map_location="cpu", weights_only=False)
42
  model.load_state_dict(ckpt["model"], strict=True)
43
 
44
  model = YoloXWrapper(model, config)