Upload README.md with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475---license: bsd-3-clauselanguage:- entags:- object-detection- faster-rcnn- resnet50- document-layout- historical-newspaperspipeline_tag: object-detectionmetrics:- 0.3251widget:- src: https://datasets-server.huggingface.co/cached-assets/biglam/loc_beyond_words/--/6c7f5fb3c60f02d9fe925cfc14aa7008f6c89099/--/default/train/0/image/image.jpg---# opencode-r1Object detection model fine-tuned from **torchvision Faster R-CNN (ResNet-50-FPN)**pre-trained on COCO (base model license: BSD-3-Clause, open and shareable) on the[`biglam/loc_beyond_words`](https://huggingface.co/datasets/biglam/loc_beyond_words) dataset(Library of Congress "Beyond Words", data license CC0-1.0).## Classes (7) + backgroundPhotograph, Illustration, Map, Comics/Cartoon, Editorial Cartoon, Headline, Advertisement## Validation results (COCO-style, biglam/loc_beyond_words validation set)| Metric | Value ||---|---|| mAP @[IoU=0.50:0.95] | 0.3251 || mAP @ IoU=0.50 | 0.4175 || mAP @ IoU=0.75 | 0.3737 |## Training| Setting | Value ||---|---|| Base model | Faster R-CNN ResNet50-FPN (COCO, BSD-3-Clause) || Epochs | 12 || Batch size | 8 || Max image dim | 520 || Optimizer | SGD (momentum 0.9), StepLR x0.3/8 epochs || Head LR / Backbone LR | 0.002 / 0.0002 || Hardware | NVIDIA GPU (Hugging Face jobs) |Images are downscaled so the largest dimension is 520px (aspect preserved);boxes scaled accordingly. Predictions below score 0.5 are discarded.## To load and run```pythonimport torchfrom torchvision.models.detection import fasterrcnn_resnet50_fpnfrom torchvision.models.detection.faster_rcnn import FastRCNNPredictorfrom huggingface_hub import hf_hub_downloadfrom PIL import Imageimport numpy as npstate = torch.load(hf_hub_download("harness-race/opencode-r1", "model.pth"),map_location="cpu")model = fasterrcnn_resnet50_fpn(weights=None)in_features = model.roi_heads.box_predictor.cls_score.in_featuresmodel.roi_heads.box_predictor = FastRCNNPredictor(in_features, 1 + 7) # 7 + backgroundmodel.load_state_dict(state)model.eval()img = Image.open("page.jpg").convert("RGB")# resize to max-dim 520 like training, then:x = torch.as_tensor(np.asarray(img), dtype=torch.float32).permute(2, 0, 1) / 255.0with torch.no_grad():dets = model([x])[0]```12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667---license: apache-2.0tags:- object-detection- detrpipeline_tag: object-detectiondatasets:- biglam/loc_beyond_wordsmetrics:- mean_average_precision---# opencode-r1 — Object Detection on LOC Beyond WordsFine-tuned **facebook/detr-resnet-50** (DETR, ResNet-50 backbone, **Apache-2.0**) on the[`biglam/loc_beyond_words`](https://huggingface.co/datasets/biglam/loc_beyond_words)dataset — a crowdsourced collection of bounding-box annotations over WWI-era newspaperpages from the Library of Congress Chronicling America collection.Fine-tuning was performed on a single NVIDIA T4 via Hugging Face Jobs (~under \$5 of compute).## Classes (7)- Photograph- Illustration- Map- Comics/Cartoon- Editorial Cartoon- Headline- Advertisement## Validation results (COCO-style AP on 712 held-out images)- **mAP@0.5:0.95** = `0.3062`- **mAP@0.5** = `0.4356`Per-class mAP@0.5:- Photograph: mAP@50 = **0.000**- Illustration: mAP@50 = **0.000**- Map: mAP@50 = **0.000**- Comics/Cartoon: mAP@50 = **0.000**- Editorial Cartoon: mAP@50 = **0.000**- Headline: mAP@50 = **0.000**- Advertisement: mAP@50 = **0.000**## Usage```pythonfrom transformers import AutoProcessor, DetrForObjectDetectionimport torchprocessor = AutoProcessor.from_pretrained("harness-race/opencode-r1")model = DetrForObjectDetection.from_pretrained("harness-race/opencode-r1")image = Image.open("page.jpg")inputs = processor(images=image, return_tensors="pt")outputs = model(**inputs)results = processor.post_process_object_detection(outputs, threshold=0.5, target_sizes=torch.tensor([image.size[::-1]]))[0]```## License & attribution- Base model `facebook/detr-resnet-50`: **Apache-2.0**- Dataset `biglam/loc_beyond_words`: **CC0-1.0** (public domain)- This fine-tuned model: **Apache-2.0**
README.md+45-53