vosstalane commited on
Commit
888be09
·
verified ·
1 Parent(s): 0c399da

Upload 5 files

Browse files

PoloPan Object Detection

Files changed (6) hide show
  1. .gitattributes +2 -0
  2. README.md +58 -0
  3. config.json +73 -0
  4. model.safetensors +3 -0
  5. preprocessor_config.json +26 -0
  6. sample_image.png +3 -0
.gitattributes ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ model.safetensors filter=lfs diff=lfs merge=lfs -text
2
+ sample_image.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: mit
4
+ language:
5
+ - en
6
+ pipeline_tag: object-detection
7
+ base_model:
8
+ - microsoft/conditional-detr-resnet-50
9
+ tags:
10
+ - object-detection
11
+ - fashion
12
+ - search
13
+ ---
14
+ This model is fine-tuned version of microsoft/conditional-detr-resnet-50.
15
+
16
+ You can find details of model in this github repo -> [fashion-visual-search](https://github.com/yainage90/fashion-visual-search)
17
+
18
+ And you can find fashion image feature extractor model -> [yainage90/fashion-image-feature-extractor](https://huggingface.co/yainage90/fashion-image-feature-extractor)
19
+
20
+ This model was trained using a combination of two datasets: [modanet](https://github.com/eBay/modanet) and [fashionpedia](https://fashionpedia.github.io/home/)
21
+
22
+ The labels are ['bag', 'bottom', 'dress', 'hat', 'shoes', 'outer', 'top']
23
+
24
+ In the 96th epoch out of total of 100 epochs, the best score was achieved with mAP 0.7542. Therefore, it is believed that there is a little room for performance improvement.
25
+
26
+ ``` python
27
+ from PIL import Image
28
+ import torch
29
+ from transformers import AutoImageProcessor, AutoModelForObjectDetection
30
+
31
+ device = 'cpu'
32
+ if torch.cuda.is_available():
33
+ device = torch.device('cuda')
34
+ elif torch.backends.mps.is_available():
35
+ device = torch.device('mps')
36
+
37
+ ckpt = 'yainage90/fashion-object-detection'
38
+ image_processor = AutoImageProcessor.from_pretrained(ckpt)
39
+ model = AutoModelForObjectDetection.from_pretrained(ckpt).to(device)
40
+
41
+ image = Image.open('<path/to/image>').convert('RGB')
42
+
43
+ with torch.no_grad():
44
+ inputs = image_processor(images=[image], return_tensors="pt")
45
+ outputs = model(**inputs.to(device))
46
+ target_sizes = torch.tensor([[image.size[1], image.size[0]]])
47
+ results = image_processor.post_process_object_detection(outputs, threshold=0.4, target_sizes=target_sizes)[0]
48
+
49
+ items = []
50
+ for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
51
+ score = score.item()
52
+ label = label.item()
53
+ box = [i.item() for i in box]
54
+ print(f"{model.config.id2label[label]}: {round(score, 3)} at {box}")
55
+ items.append((score, label, box))
56
+ ```
57
+
58
+ ![sample_image](sample_image.png)
config.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "./object_detection/model_ckpt",
3
+ "activation_dropout": 0.0,
4
+ "activation_function": "relu",
5
+ "architectures": [
6
+ "ConditionalDetrForObjectDetection"
7
+ ],
8
+ "attention_dropout": 0.0,
9
+ "auxiliary_loss": false,
10
+ "backbone": "resnet50",
11
+ "backbone_config": null,
12
+ "backbone_kwargs": {
13
+ "in_chans": 3,
14
+ "out_indices": [
15
+ 1,
16
+ 2,
17
+ 3,
18
+ 4
19
+ ]
20
+ },
21
+ "bbox_cost": 5,
22
+ "bbox_loss_coefficient": 5,
23
+ "class_cost": 2,
24
+ "cls_loss_coefficient": 2,
25
+ "d_model": 256,
26
+ "decoder_attention_heads": 8,
27
+ "decoder_ffn_dim": 2048,
28
+ "decoder_layerdrop": 0.0,
29
+ "decoder_layers": 6,
30
+ "dice_loss_coefficient": 1,
31
+ "dilation": false,
32
+ "dropout": 0.1,
33
+ "encoder_attention_heads": 8,
34
+ "encoder_ffn_dim": 2048,
35
+ "encoder_layerdrop": 0.0,
36
+ "encoder_layers": 6,
37
+ "focal_alpha": 0.25,
38
+ "giou_cost": 2,
39
+ "giou_loss_coefficient": 2,
40
+ "id2label": {
41
+ "0": "bag",
42
+ "1": "bottom",
43
+ "2": "dress",
44
+ "3": "hat",
45
+ "4": "outer",
46
+ "5": "shoes",
47
+ "6": "top"
48
+ },
49
+ "init_std": 0.02,
50
+ "init_xavier_std": 1.0,
51
+ "is_encoder_decoder": true,
52
+ "label2id": {
53
+ "bag": 0,
54
+ "bottom": 1,
55
+ "dress": 2,
56
+ "hat": 3,
57
+ "outer": 4,
58
+ "shoes": 5,
59
+ "top": 6
60
+ },
61
+ "mask_loss_coefficient": 1,
62
+ "max_position_embeddings": 1024,
63
+ "model_type": "conditional_detr",
64
+ "num_channels": 3,
65
+ "num_hidden_layers": 6,
66
+ "num_queries": 300,
67
+ "position_embedding_type": "sine",
68
+ "scale_embedding": false,
69
+ "torch_dtype": "float32",
70
+ "transformers_version": "4.44.0",
71
+ "use_pretrained_backbone": true,
72
+ "use_timm_backbone": true
73
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01f78edc0c0e3abfcf8b09555d04ab5a43216a501bf24559ce5619673c4ce824
3
+ size 174081852
preprocessor_config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_annotations": true,
3
+ "do_normalize": true,
4
+ "do_pad": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "format": "coco_detection",
8
+ "image_mean": [
9
+ 0.485,
10
+ 0.456,
11
+ 0.406
12
+ ],
13
+ "image_processor_type": "ConditionalDetrImageProcessor",
14
+ "image_std": [
15
+ 0.229,
16
+ 0.224,
17
+ 0.225
18
+ ],
19
+ "pad_size": null,
20
+ "resample": 2,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 1333,
24
+ "shortest_edge": 800
25
+ }
26
+ }
sample_image.png ADDED

Git LFS Details

  • SHA256: e9df36ba15d8d2fdd45f91c39e510214976f9dc60b4664e22dd5d8008e4e61d1
  • Pointer size: 131 Bytes
  • Size of remote file: 795 kB