IMvision12 commited on
Commit
eabf81f
·
verified ·
1 Parent(s): 20f1d6f

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +86 -0
  2. model.weights.h5 +3 -0
  3. zm_config.json +35 -0
  4. zm_preprocessor.json +22 -0
README.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: object-detection
3
+ license: apache-2.0
4
+ library_name: zeromodels
5
+ tags:
6
+ - keras
7
+ - zeromodels
8
+ - efficientdet
9
+ - object-detection
10
+ - arxiv:1911.09070
11
+ - pytorch
12
+ - jax
13
+ - tf
14
+ ---
15
+
16
+ ## ***See [our collection](https://hf.co/collections/zeromodels/efficientdet) for all versions of EfficientDet.***
17
+
18
+ # Run EfficientDet with Keras 3: JAX, PyTorch, or TensorFlow
19
+
20
+ [![GitHub](https://img.shields.io/badge/GitHub-ZeroModels-black?logo=github)](https://github.com/IMvision12/ZeroModels) [![Docs](https://img.shields.io/badge/Docs-EfficientDet-blue)](https://imvision12.github.io/ZeroModels/efficientdet/) [![Collection](https://img.shields.io/badge/HF-EfficientDet%20collection-yellow)](https://hf.co/collections/zeromodels/efficientdet)
21
+
22
+ # zeromodels/efficientdet_d6
23
+
24
+ Paper: [EfficientDet: Scalable and Efficient Object Detection (arXiv:1911.09070)](https://arxiv.org/abs/1911.09070) · [HF Papers](https://huggingface.co/papers/1911.09070)
25
+
26
+ EfficientDet is a family of single-shot, anchor-based detectors built for a clean accuracy/compute trade-off. An EfficientNet-B6 backbone feeds a weighted bi-directional feature pyramid (BiFPN) that fuses multi-scale features with learnable per-input weights, and one shared class head and box head run over every pyramid level. This checkpoint runs at 1280x1280 over the 90 COCO categories.
27
+
28
+ For more details on the model, see Google's original [AutoML EfficientDet repository](https://github.com/google/automl/tree/master/efficientdet).
29
+
30
+ Pure-**Keras 3** conversion of Google AutoML's [EfficientDet](https://github.com/google/automl/tree/master/efficientdet) (`efficientdet-d6`) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
31
+
32
+ This is an **object detection** checkpoint (`EfficientDetDetect`): the backbone, BiFPN and shared heads emit per-anchor boxes that are decoded against anchors and NMS-filtered into detections.
33
+
34
+ ## ✨ Quick start
35
+
36
+ ```python
37
+ import os
38
+ os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
39
+
40
+ from PIL import Image
41
+ from zeromodels.models.efficientdet import EfficientDetDetect, EfficientDetImageProcessor
42
+
43
+ model = EfficientDetDetect.from_weights("zeromodels/efficientdet_d6")
44
+ processor = EfficientDetImageProcessor.from_weights("zeromodels/efficientdet_d6")
45
+
46
+ image = Image.open("your_image.jpg").convert("RGB")
47
+ inputs = processor(image)
48
+ output = model(inputs["pixel_values"], training=False)
49
+ results = processor.post_process_object_detection(
50
+ output, threshold=0.3, target_sizes=inputs["original_sizes"]
51
+ )[0]
52
+ for score, name, box in zip(
53
+ results["scores"], results["label_names"], results["boxes"]
54
+ ):
55
+ print(f"{name}: {float(score):.3f} {[round(float(v)) for v in box]}")
56
+ ```
57
+
58
+ Load any EfficientDet variant the same way with `from_weights("zeromodels/<variant>")` (use `EfficientDetDetect` for detection, `EfficientDetModel` for the raw head outputs):
59
+
60
+ | Variant | Hub | Backbone | Input |
61
+ |---|---|---|---|
62
+ | `efficientdet_d0` | [`zeromodels/efficientdet_d0`](https://huggingface.co/zeromodels/efficientdet_d0) | EfficientNet-B0 | 512 |
63
+ | `efficientdet_d1` | [`zeromodels/efficientdet_d1`](https://huggingface.co/zeromodels/efficientdet_d1) | EfficientNet-B1 | 640 |
64
+ | `efficientdet_d2` | [`zeromodels/efficientdet_d2`](https://huggingface.co/zeromodels/efficientdet_d2) | EfficientNet-B2 | 768 |
65
+ | `efficientdet_d3` | [`zeromodels/efficientdet_d3`](https://huggingface.co/zeromodels/efficientdet_d3) | EfficientNet-B3 | 896 |
66
+ | `efficientdet_d4` | [`zeromodels/efficientdet_d4`](https://huggingface.co/zeromodels/efficientdet_d4) | EfficientNet-B4 | 1024 |
67
+ | `efficientdet_d5` | [`zeromodels/efficientdet_d5`](https://huggingface.co/zeromodels/efficientdet_d5) | EfficientNet-B5 | 1280 |
68
+ | `efficientdet_d6` | [`zeromodels/efficientdet_d6`](https://huggingface.co/zeromodels/efficientdet_d6) | EfficientNet-B6 | 1280 |
69
+ | `efficientdet_d7` | [`zeromodels/efficientdet_d7`](https://huggingface.co/zeromodels/efficientdet_d7) | EfficientNet-B6 | 1536 |
70
+
71
+ ## Tips
72
+
73
+ - Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
74
+ - Detection: `EfficientDetDetect` + `post_process_object_detection` (try `threshold=0.3`-`0.4`).
75
+ - NMS is class-agnostic by default (one box per object); pass `class_agnostic=False` for per-class NMS.
76
+ - `EfficientDetModel.from_weights(...)` loads the same weights without the decode head, returning raw per-level `class_outputs` / `box_outputs`.
77
+ - Larger variants take a bigger input (D0 512 up to D7 1536); each side must be divisible by 128.
78
+ - Community / fine-tuned repos hosted in the zeromodels format load with `from_weights("<org>/<repo>")`.
79
+ - Weights are resolution-independent: pass `image_size=N` (a multiple of 128) to `from_weights` to run at a custom size.
80
+ - See [EfficientDet docs](https://imvision12.github.io/ZeroModels/efficientdet/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
81
+
82
+ ## Special Thanks
83
+
84
+ A huge thank you to the Google Brain / AutoML authors (Mingxing Tan, Ruoming Pang, Quoc V. Le) for creating and releasing EfficientDet.
85
+
86
+ License: Apache 2.0.
model.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa131996891803718629dd00af34aa6447ac344c6bdd5e6958cc8c070b287404
3
+ size 211655384
zm_config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "library_name": "zeromodels",
3
+ "zeromodels_version": "1.2.6",
4
+ "model_module": "zeromodels.models.efficientdet",
5
+ "model_class": "EfficientDetModel",
6
+ "variant": "efficientdet_d6",
7
+ "weights": "model.weights.h5",
8
+ "schema_version": 2,
9
+ "weight_dtype": "float32",
10
+ "model_type": "efficientdet",
11
+ "vision_config": {
12
+ "backbone_name": "efficientnet_b6",
13
+ "image_size": 1280,
14
+ "num_classes": 90,
15
+ "min_level": 3,
16
+ "max_level": 7,
17
+ "num_scales": 3,
18
+ "aspect_ratios": [
19
+ 1.0,
20
+ 2.0,
21
+ 0.5
22
+ ],
23
+ "anchor_scale": 4.0,
24
+ "fpn_num_filters": 384,
25
+ "fpn_cell_repeats": 8,
26
+ "box_class_repeats": 5,
27
+ "act_type": "swish",
28
+ "separable_conv": true,
29
+ "apply_bn_for_resampling": true,
30
+ "conv_after_downsample": false,
31
+ "conv_bn_act_pattern": false,
32
+ "fpn_weight_method": "sum",
33
+ "survival_prob": null
34
+ }
35
+ }
zm_preprocessor.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "library_name": "zeromodels",
3
+ "zeromodels_version": "1.2.6",
4
+ "preprocessor_module": "zeromodels.models.efficientdet",
5
+ "preprocessor_class": "EfficientDetImageProcessor",
6
+ "variant": "efficientdet_d6",
7
+ "image_size": 1280,
8
+ "resample": "bilinear",
9
+ "image_mean": [
10
+ 0.485,
11
+ 0.456,
12
+ 0.406
13
+ ],
14
+ "image_std": [
15
+ 0.229,
16
+ 0.224,
17
+ 0.225
18
+ ],
19
+ "rescale_factor": 0.00392156862745098,
20
+ "return_tensor": true,
21
+ "data_format": null
22
+ }