maxwoe commited on
Commit
3552a79
·
verified ·
1 Parent(s): ed8d2c4

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +10 -10
README.md CHANGED
@@ -34,27 +34,27 @@ The model outputs a probability distribution over 360 angle bins (1 degree resol
34
  The inference code (`model_cgd.py`, `architectures.py`, `rotation_utils.py`) is included in this repo.
35
 
36
  ```python
37
- from huggingface_hub import hf_hub_download, snapshot_download
38
- from PIL import Image
39
 
40
- # Download inference code and checkpoint
41
  snapshot_download(
42
  repo_id="maxwoe/image-rotation-angle-estimation",
43
  allow_patterns=["*.py", "*.json"],
44
  local_dir=".",
45
  )
46
- ckpt_path = hf_hub_download(
47
- repo_id="maxwoe/image-rotation-angle-estimation",
48
- filename="cgd_mambaout_base_coco2017.ckpt",
49
- )
50
 
51
- # Load model
52
  from model_cgd import CGDAngleEstimation
 
53
 
54
- model = CGDAngleEstimation.try_load(checkpoint_path=ckpt_path)
55
- model.eval()
 
 
 
56
 
57
  # Predict rotation angle
 
58
  image = Image.open("your_image.jpg")
59
  angle = model.predict_angle(image)
60
  print(f"Predicted rotation: {angle:.2f} degrees")
 
34
  The inference code (`model_cgd.py`, `architectures.py`, `rotation_utils.py`) is included in this repo.
35
 
36
  ```python
37
+ from huggingface_hub import snapshot_download
 
38
 
39
+ # Download inference code
40
  snapshot_download(
41
  repo_id="maxwoe/image-rotation-angle-estimation",
42
  allow_patterns=["*.py", "*.json"],
43
  local_dir=".",
44
  )
 
 
 
 
45
 
46
+ # Load model (defaults to COCO 2017 checkpoint)
47
  from model_cgd import CGDAngleEstimation
48
+ model = CGDAngleEstimation.from_pretrained("maxwoe/image-rotation-angle-estimation")
49
 
50
+ # Or load a specific checkpoint by filename
51
+ # model = CGDAngleEstimation.from_pretrained(
52
+ # "maxwoe/image-rotation-angle-estimation",
53
+ # model_name="cgd_mambaout_base_coco2014.ckpt",
54
+ # )
55
 
56
  # Predict rotation angle
57
+ from PIL import Image
58
  image = Image.open("your_image.jpg")
59
  angle = model.predict_angle(image)
60
  print(f"Predicted rotation: {angle:.2f} degrees")