Downloads · 30 days
15
50% of all-time downloads
GreenMap/hatch-finder-3.5m
hatch-finder-3.5m is a image segmentation model from GreenMap. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for hatchfinder. The card lists the license as apache-2.0.
Downloads · 30 days
15
50% of all-time downloads
All-time downloads
30
Public
Repo size
16.7 MB
Likes
1
Public
Click a slice to open those files.
.pt14.1 MB · 84%
From the Hugging Face model README

HatchFinder is a lightweight reference-conditioned model for locating a given hatch pattern in architectural and construction drawings.
The model takes a blueprint, a search mask defining the region of interest, and a reference image of the hatch pattern to find. It produces a dense pixel-wise heatmap indicating where the reference hatch is present.
GitHub: GreenMap-chan/hatch-finder
HatchFinder is designed for reference-based hatch detection rather than classification into a fixed set of hatch classes.
The model takes three inputs:
Since the model was trained on 896×896 images, I strongly recommend using the same input size for Drawing.
The model outputs a single-channel dense logits map with the same spatial resolution as the drawing.
After applying sigmoid, each pixel represents the predicted probability that it belongs to the reference hatch pattern.
heatmap = torch.sigmoid(logits)
heatmap = heatmap * search_mask
HatchFinder uses a custom multi-scale convolutional architecture consisting of:
The model is trained end-to-end for reference-conditioned pixel-level hatch detection.
| Metric | Value |
|---|---|
| Validation loss | 0.05881 |
| BCE loss | 0.01343 |
| Dice loss | 0.05672 |
| Dice coefficient | 0.94328 |
The metrics above were measured on the validation split used for this model and should not be interpreted as performance on arbitrary blueprint datasets.
Training includes geometric and visual augmentations applied independently where appropriate to the drawing and reference hatch.
pip install hatchfinder huggingface_hub
The following example is self-contained: it downloads the model and one input
triplet from this repository, runs inference, and saves both the probability
heatmap and a thresholded prediction. It also creates a visualization in
output/0000435_debug.png, where predictions above confidence are overlaid
in red and the area outside the search mask is darkened.
from pathlib import Path
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from torchvision.transforms.functional import to_pil_image
from hatchfinder import HatchFinder
REPO_ID = "GreenMap/hatch-finder-3.5m"
SAMPLE_ID = "0000435"
OUTPUT_DIR = Path("output")
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
def download(filename: str) -> Path:
return Path(hf_hub_download(repo_id=REPO_ID, filename=filename))
# Download the weights and a drawing/search-mask/reference-hatch triplet.
model_path = download("model.pt")
drawing_path = download(f"sample_dataset/valid/drawing/{SAMPLE_ID}.png")
mask_path = download(f"sample_dataset/valid/search_mask/{SAMPLE_ID}.png")
hatch_path = download(f"sample_dataset/valid/hatch/{SAMPLE_ID}.png")
# "auto" selects CUDA when it is available and otherwise uses the CPU.
model = HatchFinder(load_model_path=model_path, device="auto")
heatmap = model.infer(
drawing=drawing_path,
mask=mask_path,
hatch=hatch_path,
debug_path=OUTPUT_DIR,
confidence=0.5,
)
# infer() returns probabilities with shape [1, 1, height, width]. Pixels
# outside the search mask are already set to zero.
print(heatmap.shape, heatmap.min().item(), heatmap.max().item())
heatmap_cpu = heatmap[0].detach().cpu().clamp(0, 1)
to_pil_image(heatmap_cpu).save(OUTPUT_DIR / f"{SAMPLE_ID}_heatmap.png")
prediction = (heatmap_cpu >= 0.5).to(torch.uint8) * 255
Image.fromarray(prediction[0].numpy()).save(
OUTPUT_DIR / f"{SAMPLE_ID}_prediction.png"
)
drawing and hatch can be paths or Pillow images; they are converted to RGB.
mask can also be a path or a Pillow image; it is converted to grayscale and
binarized at 0.5. The drawing and search mask must have the same dimensions.
For best results, use a drawing size of 896 x 896, matching the training data.
See the hatch-finder repository for the source code, training configuration, and further examples.
Apache License 2.0