Object Detection
Safetensors
detr
davanstrien HF Staff commited on
Commit
48c9026
·
verified ·
1 Parent(s): 3304b24

Fine-tuned Faster R-CNN ResNet50-FPN on loc_beyond_words

Browse files
Files changed (6) hide show
  1. README.md +75 -0
  2. args.json +1 -0
  3. class_names.json +1 -0
  4. full_model.pth +3 -0
  5. model.pth +3 -0
  6. results.json +1 -0
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: bsd-3-clause
3
+ language:
4
+ - en
5
+ tags:
6
+ - object-detection
7
+ - faster-rcnn
8
+ - resnet50
9
+ - document-layout
10
+ - historical-newspapers
11
+ pipeline_tag: object-detection
12
+ metrics:
13
+ - 0.3251
14
+ widget:
15
+ - src: https://datasets-server.huggingface.co/cached-assets/biglam/loc_beyond_words/--/6c7f5fb3c60f02d9fe925cfc14aa7008f6c89099/--/default/train/0/image/image.jpg
16
+ ---
17
+
18
+ # opencode-r1
19
+
20
+ Object detection model fine-tuned from **torchvision Faster R-CNN (ResNet-50-FPN)**
21
+ pre-trained on COCO (base model license: BSD-3-Clause, open and shareable) on the
22
+ [`biglam/loc_beyond_words`](https://huggingface.co/datasets/biglam/loc_beyond_words) dataset
23
+ (Library of Congress "Beyond Words", data license CC0-1.0).
24
+
25
+ ## Classes (7) + background
26
+
27
+ Photograph, Illustration, Map, Comics/Cartoon, Editorial Cartoon, Headline, Advertisement
28
+
29
+ ## Validation results (COCO-style, biglam/loc_beyond_words validation set)
30
+
31
+ | Metric | Value |
32
+ |---|---|
33
+ | mAP @[IoU=0.50:0.95] | 0.3251 |
34
+ | mAP @ IoU=0.50 | 0.4175 |
35
+ | mAP @ IoU=0.75 | 0.3737 |
36
+
37
+ ## Training
38
+
39
+ | Setting | Value |
40
+ |---|---|
41
+ | Base model | Faster R-CNN ResNet50-FPN (COCO, BSD-3-Clause) |
42
+ | Epochs | 12 |
43
+ | Batch size | 8 |
44
+ | Max image dim | 520 |
45
+ | Optimizer | SGD (momentum 0.9), StepLR x0.3/8 epochs |
46
+ | Head LR / Backbone LR | 0.002 / 0.0002 |
47
+ | Hardware | NVIDIA GPU (Hugging Face jobs) |
48
+
49
+ Images are downscaled so the largest dimension is 520px (aspect preserved);
50
+ boxes scaled accordingly. Predictions below score 0.5 are discarded.
51
+
52
+ ## To load and run
53
+
54
+ ```python
55
+ import torch
56
+ from torchvision.models.detection import fasterrcnn_resnet50_fpn
57
+ from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
58
+ from huggingface_hub import hf_hub_download
59
+ from PIL import Image
60
+ import numpy as np
61
+
62
+ state = torch.load(hf_hub_download("harness-race/opencode-r1", "model.pth"),
63
+ map_location="cpu")
64
+ model = fasterrcnn_resnet50_fpn(weights=None)
65
+ in_features = model.roi_heads.box_predictor.cls_score.in_features
66
+ model.roi_heads.box_predictor = FastRCNNPredictor(in_features, 1 + 7) # 7 + background
67
+ model.load_state_dict(state)
68
+ model.eval()
69
+
70
+ img = Image.open("page.jpg").convert("RGB")
71
+ # resize to max-dim 520 like training, then:
72
+ x = torch.as_tensor(np.asarray(img), dtype=torch.float32).permute(2, 0, 1) / 255.0
73
+ with torch.no_grad():
74
+ dets = model([x])[0]
75
+ ```
args.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"epochs": 12, "batch": 8, "max_dim": 520, "lr": 0.002, "base_lr": 0.0002, "seed": 0, "push": "1"}
class_names.json ADDED
@@ -0,0 +1 @@
 
 
1
+ ["Photograph", "Illustration", "Map", "Comics/Cartoon", "Editorial Cartoon", "Headline", "Advertisement"]
full_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39a92f7e53f5685d1b5da785d055dc26340d3aadcd793b0da8bbafa378f152f4
3
+ size 165882301
model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77a36019e9a77eb115c22db30856bf20137cd7b93641c58247a246cc8bdd66a8
3
+ size 165831383
results.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mAP_050_095": 0.325054090182978, "mAP_050": 0.41747069516008106, "mAP_075": 0.373689980761858}