too light
This commit is contained in:
parent
31bb1eb722
commit
8884b3cec4
1 changed files with 13 additions and 4 deletions
|
|
@ -78,8 +78,17 @@ class TextProcessor:
|
|||
# Filter out special tokens
|
||||
cleaned = self.special_token_pattern.sub('', text)
|
||||
|
||||
|
||||
# Remove consecutive duplicates
|
||||
return cleaned
|
||||
if not cleaned:
|
||||
return ''
|
||||
|
||||
result = [cleaned[0]]
|
||||
for char in cleaned[1:]:
|
||||
if char != result[-1]:
|
||||
result.append(char)
|
||||
return ''.join(result)
|
||||
|
||||
|
||||
|
||||
def decode(self, indices) -> str:
|
||||
|
|
@ -130,13 +139,13 @@ def preprocess_image(image_path):
|
|||
gray = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
||||
|
||||
# Convert grayscale to 3-channel RGB by duplicating the gray channel
|
||||
img = adjust_gamma(cv2.cvtColor(gray, cv2.COLOR_GRAY2RGB),gamma=1.67,alpha=1.67,beta=-6) # perfect tunning
|
||||
img = adjust_gamma(cv2.cvtColor(gray, cv2.COLOR_GRAY2RGB),gamma=1.3,alpha=1.65,beta=-2) # perfect tunning
|
||||
mat_in = ncnn.Mat.from_pixels_resize(
|
||||
img, ncnn.Mat.PixelType.PIXEL_RGB, img.shape[1], img.shape[0], 224, 224
|
||||
)
|
||||
|
||||
mean_vals = [0.5, 0.5, 0.5] * 3
|
||||
norm_vals = [1/255, 1/255, 1/255] * 3
|
||||
mean_vals = [0.5, 0.5, 0.5] * 2
|
||||
norm_vals = [1/255, 1/255, 1/255] * 2
|
||||
mat_in.substract_mean_normalize(mean_vals, norm_vals)
|
||||
return mat_in
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue