matejpekar commited on
Commit
4d7601c
·
verified ·
1 Parent(s): 1a817ed

Upload processor

Browse files
Files changed (2) hide show
  1. image_processing.py +4 -4
  2. preprocessor_config.json +3 -0
image_processing.py CHANGED
@@ -6,11 +6,11 @@ from transformers import BaseImageProcessorFast
6
 
7
 
8
  class LSPDetrImageProcessor(BaseImageProcessorFast):
 
9
  image_mean = [0.485, 0.456, 0.406]
10
  image_std = [0.229, 0.224, 0.225]
11
  do_rescale = True
12
  do_normalize = True
13
- return_tensors = "pt"
14
 
15
  def post_process(self, outputs: dict[str, Tensor]) -> list[dict[str, Tensor]]:
16
  """Converts the raw output into polygons.
@@ -59,11 +59,11 @@ class LSPDetrImageProcessor(BaseImageProcessorFast):
59
  device=result["polygons"].device,
60
  )
61
 
62
- for i, polygon in enumerate(result["polygons"]):
63
- img = Image.fromarray(masks[i].cpu().numpy())
64
  canvas = ImageDraw.Draw(img)
65
  canvas.polygon(xy=polygon.flatten().tolist(), outline=1, fill=1)
66
- masks[i] = torch.from_numpy(np.asarray(img))
67
 
68
  results[i]["masks"] = masks
69
 
 
6
 
7
 
8
  class LSPDetrImageProcessor(BaseImageProcessorFast):
9
+ image_processor_type = BaseImageProcessorFast
10
  image_mean = [0.485, 0.456, 0.406]
11
  image_std = [0.229, 0.224, 0.225]
12
  do_rescale = True
13
  do_normalize = True
 
14
 
15
  def post_process(self, outputs: dict[str, Tensor]) -> list[dict[str, Tensor]]:
16
  """Converts the raw output into polygons.
 
59
  device=result["polygons"].device,
60
  )
61
 
62
+ for j, polygon in enumerate(result["polygons"]):
63
+ img = Image.fromarray(masks[j].cpu().numpy())
64
  canvas = ImageDraw.Draw(img)
65
  canvas.polygon(xy=polygon.flatten().tolist(), outline=1, fill=1)
66
+ masks[j] = torch.tensor(np.asarray(img))
67
 
68
  results[i]["masks"] = masks
69
 
preprocessor_config.json CHANGED
@@ -1,4 +1,7 @@
1
  {
 
 
 
2
  "crop_size": null,
3
  "data_format": "channels_first",
4
  "default_to_square": true,
 
1
  {
2
+ "auto_map": {
3
+ "AutoImageProcessor": "image_processing.LSPDetrImageProcessor"
4
+ },
5
  "crop_size": null,
6
  "data_format": "channels_first",
7
  "default_to_square": true,