zerosandones commited on
Commit
51bbb30
·
verified ·
1 Parent(s): 4568ac1

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ - zero-shot-object-detection
6
+ inference: false
7
+ library_name: transformers.js
8
+ base_model:
9
+ - google/owlv2-large-patch14-ensemble
10
+ pipeline_tag: zero-shot-object-detection
11
+ ---
12
+
13
+
14
+
15
+ # owlv2-large-patch14-ensemble (ONNX)
16
+
17
+
18
+ This is an ONNX version of [google/owlv2-large-patch14-ensemble](https://huggingface.co/google/owlv2-large-patch14-ensemble). It was automatically converted and uploaded using [this Hugging Face Space](https://huggingface.co/spaces/onnx-community/convert-to-onnx).
19
+
20
+
21
+ ## Usage with Transformers.js
22
+
23
+
24
+ See the pipeline documentation for `zero-shot-object-detection`: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ZeroShotObjectDetectionPipeline
25
+
26
+
27
+ ---
28
+
29
+
30
+ # Model Card: OWLv2
31
+
32
+ ## Model Details
33
+
34
+ The OWLv2 model (short for Open-World Localization) was proposed in [Scaling Open-Vocabulary Object Detection](https://arxiv.org/abs/2306.09683) by Matthias Minderer, Alexey Gritsenko, Neil Houlsby. OWLv2, like OWL-ViT, is a zero-shot text-conditioned object detection model that can be used to query an image with one or multiple text queries.
35
+
36
+ The model uses CLIP as its multi-modal backbone, with a ViT-like Transformer to get visual features and a causal language model to get the text features. To use CLIP for detection, OWL-ViT removes the final token pooling layer of the vision model and attaches a lightweight classification and box head to each transformer output token. Open-vocabulary classification is enabled by replacing the fixed classification layer weights with the class-name embeddings obtained from the text model. The authors first train CLIP from scratch and fine-tune it end-to-end with the classification and box heads on standard detection datasets using a bipartite matching loss. One or multiple text queries per image can be used to perform zero-shot text-conditioned object detection.
37
+
38
+
39
+ ### Model Date
40
+
41
+ June 2023
42
+
43
+ ### Model Type
44
+
45
+ The model uses a CLIP backbone with a ViT-L/14 Transformer architecture as an image encoder and uses a masked self-attention Transformer as a text encoder. These encoders are trained to maximize the similarity of (image, text) pairs via a contrastive loss. The CLIP backbone is trained from scratch and fine-tuned together with the box and class prediction heads with an object detection objective.
46
+
47
+
48
+ ### Documents
49
+
50
+ - [OWLv2 Paper](https://arxiv.org/abs/2306.09683)
51
+
52
+
53
+ ### Use with Transformers
54
+
55
+ ```python
56
+ import requests
57
+ from PIL import Image
58
+ import torch
59
+
60
+ from transformers import Owlv2Processor, Owlv2ForObjectDetection
61
+
62
+ processor = Owlv2Processor.from_pretrained("google/owlv2-large-patch14-ensemble")
63
+ model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-large-patch14-ensemble")
64
+
65
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
66
+ image = Image.open(requests.get(url, stream=True).raw)
67
+ texts = [["a photo of a cat", "a photo of a dog"]]
68
+ inputs = processor(text=texts, images=image, return_tensors="pt")
69
+
70
+ with torch.no_grad():
71
+ outputs = model(**inputs)
72
+
73
+ # Target image sizes (height, width) to rescale box predictions [batch_size, 2]
74
+ target_sizes = torch.Tensor([image.size[::-1]])
75
+ # Convert outputs (bounding boxes and class logits) to Pascal VOC Format (xmin, ymin, xmax, ymax)
76
+ results = processor.post_process_object_detection(outputs=outputs, target_sizes=target_sizes, threshold=0.1)
77
+ i = 0 # Retrieve predictions for the first image for the corresponding text queries
78
+ text = texts[i]
79
+ boxes, scores, labels = results[i]["boxes"], results[i]["scores"], results[i]["labels"]
80
+ for box, score, label in zip(boxes, scores, labels):
81
+ box = [round(i, 2) for i in box.tolist()]
82
+ print(f"Detected {text[label]} with confidence {round(score.item(), 3)} at location {box}")
83
+ ```
84
+
85
+
86
+ ## Model Use
87
+
88
+ ### Intended Use
89
+
90
+ The model is intended as a research output for research communities. We hope that this model will enable researchers to better understand and explore zero-shot, text-conditioned object detection. We also hope it can be used for interdisciplinary studies of the potential impact of such models, especially in areas that commonly require identifying objects whose label is unavailable during training.
91
+
92
+ #### Primary intended uses
93
+
94
+ The primary intended users of these models are AI researchers.
95
+
96
+ We primarily imagine the model will be used by researchers to better understand robustness, generalization, and other capabilities, biases, and constraints of computer vision models.
97
+
98
+ ## Data
99
+
100
+ The CLIP backbone of the model was trained on publicly available image-caption data. This was done through a combination of crawling a handful of websites and using commonly-used pre-existing image datasets such as [YFCC100M](http://projects.dfki.uni-kl.de/yfcc100m/). A large portion of the data comes from our crawling of the internet. This means that the data is more representative of people and societies most connected to the internet. The prediction heads of OWL-ViT, along with the CLIP backbone, are fine-tuned on publicly available object detection datasets such as [COCO](https://cocodataset.org/#home) and [OpenImages](https://storage.googleapis.com/openimages/web/index.html).
101
+
102
+ (to be updated for v2)
103
+
104
+ ### BibTeX entry and citation info
105
+
106
+ ```bibtex
107
+ @misc{minderer2023scaling,
108
+ title={Scaling Open-Vocabulary Object Detection},
109
+ author={Matthias Minderer and Alexey Gritsenko and Neil Houlsby},
110
+ year={2023},
111
+ eprint={2306.09683},
112
+ archivePrefix={arXiv},
113
+ primaryClass={cs.CV}
114
+ }
115
+ ```
config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_attn_implementation_autoset": true,
3
+ "_name_or_path": "google/owlv2-large-patch14-ensemble",
4
+ "architectures": [
5
+ "Owlv2ForObjectDetection"
6
+ ],
7
+ "initializer_factor": 1.0,
8
+ "logit_scale_init_value": 2.6592,
9
+ "model_type": "owlv2",
10
+ "projection_dim": 768,
11
+ "text_config": {
12
+ "hidden_size": 768,
13
+ "intermediate_size": 3072,
14
+ "model_type": "owlv2_text_model",
15
+ "num_attention_heads": 12,
16
+ "torch_dtype": "float32"
17
+ },
18
+ "torch_dtype": "float32",
19
+ "transformers_version": "4.49.0",
20
+ "vision_config": {
21
+ "hidden_size": 1024,
22
+ "image_size": 1008,
23
+ "intermediate_size": 4096,
24
+ "model_type": "owlv2_vision_model",
25
+ "num_attention_heads": 16,
26
+ "num_hidden_layers": 24,
27
+ "patch_size": 14,
28
+ "torch_dtype": "float32"
29
+ }
30
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a395fa0b5103667a2c0b7b9a035c7cbe931c2060b8e270bc77e725f657eae73f
3
+ size 1739806508
onnx/model_bnb4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71c9e683f87fa463bb9749e957d9595b0f8507ea22ea4b0fbb2b02a66a593536
3
+ size 397827320
onnx/model_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:996b5c3cf52b2ac9ccd3f5dd6b1a3cd6ecf749f20ae4df40e22ffaddfd1bc026
3
+ size 870317341
onnx/model_int8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8e553b23ae79489054f4938a5af263a175ba5ebcc1ba8ec121ef641c0042f10
3
+ size 453224793
onnx/model_q4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb1f9dee46f98b5f1ef8c06e1b000665970f3bcbd964268cee1476a9cf4e4267
3
+ size 422225823
onnx/model_q4f16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f61e6a7be9c9b043b3f90c3f98733fb9ce22711878e71dacd4dc278bc0b55a3
3
+ size 309144690
onnx/model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2146aacf91468140586b4fcda5d07da988662e1482d66010e9b1b7b7c561a534
3
+ size 453224901
onnx/model_uint8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2146aacf91468140586b4fcda5d07da988662e1482d66010e9b1b7b7c561a534
3
+ size 453224901
preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "do_pad": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.48145466,
8
+ 0.4578275,
9
+ 0.40821073
10
+ ],
11
+ "image_processor_type": "Owlv2ImageProcessor",
12
+ "image_std": [
13
+ 0.26862954,
14
+ 0.26130258,
15
+ 0.27577711
16
+ ],
17
+ "processor_class": "Owlv2Processor",
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 1008,
22
+ "width": 1008
23
+ }
24
+ }
quantize_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "modes": [
3
+ "fp16",
4
+ "q8",
5
+ "int8",
6
+ "uint8",
7
+ "q4",
8
+ "q4f16",
9
+ "bnb4"
10
+ ],
11
+ "per_channel": false,
12
+ "reduce_range": false,
13
+ "block_size": null,
14
+ "is_symmetric": true,
15
+ "accuracy_level": null,
16
+ "quant_type": 1,
17
+ "op_block_list": null
18
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|startoftext|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "!",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "!",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "49406": {
13
+ "content": "<|startoftext|>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "49407": {
21
+ "content": "<|endoftext|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ }
28
+ },
29
+ "additional_special_tokens": [],
30
+ "bos_token": "<|startoftext|>",
31
+ "clean_up_tokenization_spaces": true,
32
+ "do_lower_case": true,
33
+ "eos_token": "<|endoftext|>",
34
+ "errors": "replace",
35
+ "extra_special_tokens": {},
36
+ "model_max_length": 16,
37
+ "pad_token": "!",
38
+ "processor_class": "Owlv2Processor",
39
+ "tokenizer_class": "CLIPTokenizer",
40
+ "unk_token": "<|endoftext|>"
41
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff