simonJJJ commited on
Commit
08d140b
1 Parent(s): 80ce4e4
Files changed (1) hide show
  1. tokenization_qwen.py +4 -3
tokenization_qwen.py CHANGED
@@ -416,7 +416,7 @@ class QWenTokenizer(PreTrainedTokenizer):
416
  else:
417
  image = plt.imread(image)
418
  h, w = image.shape[0], image.shape[1]
419
- visualizer = Visualizer(image)
420
 
421
  boxes = self._fetch_all_box_with_ref(response)
422
  if not boxes:
@@ -491,8 +491,9 @@ class VisImage:
491
 
492
 
493
  class Visualizer:
494
- def __init__(self, img_rgb, metadata=None, scale=1.0):
495
  self.img = np.asarray(img_rgb).clip(0, 255).astype(np.uint8)
 
496
  self.output = VisImage(self.img, scale=scale)
497
  self.cpu_device = torch.device("cpu")
498
 
@@ -524,7 +525,7 @@ class Visualizer:
524
  y,
525
  text,
526
  size=font_size * self.output.scale,
527
- fontproperties=FontProperties(fname=r"SimSun.ttf"),
528
  bbox={"facecolor": "black", "alpha": 0.8, "pad": 0.7, "edgecolor": "none"},
529
  verticalalignment="top",
530
  horizontalalignment=horizontal_alignment,
 
416
  else:
417
  image = plt.imread(image)
418
  h, w = image.shape[0], image.shape[1]
419
+ visualizer = Visualizer(image, self.font_path)
420
 
421
  boxes = self._fetch_all_box_with_ref(response)
422
  if not boxes:
 
491
 
492
 
493
  class Visualizer:
494
+ def __init__(self, img_rgb, font_path, metadata=None, scale=1.0):
495
  self.img = np.asarray(img_rgb).clip(0, 255).astype(np.uint8)
496
+ self.font_path = os.path.join(font_path, "SimSun.ttf")
497
  self.output = VisImage(self.img, scale=scale)
498
  self.cpu_device = torch.device("cpu")
499
 
 
525
  y,
526
  text,
527
  size=font_size * self.output.scale,
528
+ fontproperties=FontProperties(fname=self.font_path),
529
  bbox={"facecolor": "black", "alpha": 0.8, "pad": 0.7, "edgecolor": "none"},
530
  verticalalignment="top",
531
  horizontalalignment=horizontal_alignment,