isalia99 commited on
Commit
4c1430d
1 Parent(s): 9226671

small update to readme about downloading the image from remote

Browse files
Files changed (1) hide show
  1. README.md +10 -10
README.md CHANGED
@@ -9,11 +9,11 @@ datasets:
9
 
10
  # DETR (End-to-End Object Detection) model with ResNet-50 backbone trained on SKU110K Dataset with 400 num_queries
11
 
12
- DEtection TRansformer (DETR) model trained end-to-end on SKU110K object detection (8k annotated images). Main difference between the model is it having **400** num_queries and it being pretrained on SKU110K dataset.
13
 
14
  ### How to use
15
 
16
- Here is how to use this model. You can download the **IMG_3507.jpg** from HuggingFace files
17
 
18
  ```python
19
  from transformers import DetrImageProcessor, DetrForObjectDetection
@@ -21,9 +21,9 @@ import torch
21
  from PIL import Image, ImageOps
22
  import requests
23
 
24
- url = "IMG_3507.jpg" # You can download this image from HF files
25
- image = Image.open(url)
26
- ImageOps.exif_transpose(image)
27
 
28
  # you can specify the revision tag if you don't want the timm dependency
29
  processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
@@ -38,11 +38,11 @@ target_sizes = torch.tensor([image.size[::-1]])
38
  results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.8)[0]
39
 
40
  for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
41
- box = [round(i, 2) for i in box.tolist()]
42
- print(
43
- f"Detected {model.config.id2label[label.item()]} with confidence "
44
- f"{round(score.item(), 3)} at location {box}"
45
- )
46
  ```
47
  This should output:
48
  ```
 
9
 
10
  # DETR (End-to-End Object Detection) model with ResNet-50 backbone trained on SKU110K Dataset with 400 num_queries
11
 
12
+ DEtection TRansformer (DETR) model trained end-to-end on SKU110K object detection (8k annotated images). Main difference compared to the original model is it having **400** num_queries and it being pretrained on SKU110K dataset.
13
 
14
  ### How to use
15
 
16
+ Here is how to use this model:
17
 
18
  ```python
19
  from transformers import DetrImageProcessor, DetrForObjectDetection
 
21
  from PIL import Image, ImageOps
22
  import requests
23
 
24
+ url = "https://github.com/Isalia20/DETR-finetune/blob/main/IMG_3507.jpg?raw=true"
25
+ image = Image.open(requests.get(url, stream=True).raw)
26
+ image = ImageOps.exif_transpose(image)
27
 
28
  # you can specify the revision tag if you don't want the timm dependency
29
  processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50", revision="no_timm")
 
38
  results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.8)[0]
39
 
40
  for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
41
+ box = [round(i, 2) for i in box.tolist()]
42
+ print(
43
+ f"Detected {model.config.id2label[label.item()]} with confidence "
44
+ f"{round(score.item(), 3)} at location {box}"
45
+ )
46
  ```
47
  This should output:
48
  ```