DETR Label detection accuracy and shpae error on CRAFT model

#4
by PalmPalm7 - opened

DETR Label detection accuracy

@KabilanM Hi Kabilan, while testing your pipeline, I found DETR currently has a 71.5% accuracy in label detection on the validation set that I am running. All 1000 samples have clearn labels, but some may have lower visibilities due to the lighting and background of the images. E.g. Ink color vs Paper color is too low.

To access one of the samples below, e.g. e957ffa2.png, please go to https://www.cvh.ac.cn/spms/detail.php?id=e957ffa2.

Reading through the pipelines, I wasn't sure DETR is needed. Judging by previous chart, it seems accuracies drop after deploying DETR.

To replicate, the notebook is located on SCC, under /projectnb/sparkgrp/ml-herbarium-grp/Spring2024/trocr/trocr_with_detr_label_extraction.ipynb

CRAFT Model

I am unable to proceed with your pipeline. It appears to have shape errors. Here is the error:
```

ValueError Traceback (most recent call last)
Cell In[10], line 25
23 img = Image.open(image)
24 img.verify() # Check that the image is valid
---> 25 bounding_areas = craft.detect_text(image)
26 if len(bounding_areas['boxes']): #check that a segmentation was found
27 images.append(image)

File /projectnb/ds549/students/hxie13/.conda/envs/trocr2/lib/python3.9/site-packages/craft_text_detector/init.py:131, in Craft.detect_text(self, image, image_path)
128 image = image_path
130 # perform prediction
--> 131 prediction_result = get_prediction(
132 image=image,
133 craft_net=self.craft_net,
134 refine_net=self.refine_net,
135 text_threshold=self.text_threshold,
136 link_threshold=self.link_threshold,
137 low_text=self.low_text,
138 cuda=self.cuda,
139 long_size=self.long_size,
140 )
142 # arange regions
143 if self.crop_type == "box":

File /projectnb/ds549/students/hxie13/.conda/envs/trocr2/lib/python3.9/site-packages/craft_text_detector/predict.py:91, in get_prediction(image, craft_net, refine_net, text_threshold, link_threshold, low_text, cuda, long_size, poly)
89 # coordinate adjustment
90 boxes = craft_utils.adjustResultCoordinates(boxes, ratio_w, ratio_h)
---> 91 polys = craft_utils.adjustResultCoordinates(polys, ratio_w, ratio_h)
92 for k in range(len(polys)):
93 if polys[k] is None:

File /projectnb/ds549/students/hxie13/.conda/envs/trocr2/lib/python3.9/site-packages/craft_text_detector/craft_utils.py:415, in adjustResultCoordinates(polys, ratio_w, ratio_h, ratio_net)
413 def adjustResultCoordinates(polys, ratio_w, ratio_h, ratio_net=2):
414 if len(polys) > 0:
--> 415 polys = np.array(polys)
416 for k in range(len(polys)):
417 if polys[k] is not None:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
```

Sign up or log in to comment