-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
服务异常(TypeError: object of type 'NoneType' has no len()) #5
Comments
我也遇到了类似的问题,请问您解决了吗 |
问题已解决,可以尝试通过修改库中main.py中的函数解决 def detect_subtitle_area(ocr_results, h, w):
'''
Args:
w(int): width of the input video
h(int): height of the input video
'''
# print(ocr_results) # for debug add by L1_Sta2
ocr_results = ocr_results[0] # 0, the first image result
# Merge horizon text areas
idx = 0
candidates = []
if not ocr_results:
ocr_results = []
while idx < len(ocr_results):
boxes, text = ocr_results[idx]
# We assume the subtitle is at bottom of the video
if boxes[0][1] < h * 0.75:
idx += 1
continue
idx += 1
con_boxes = copy.deepcopy(boxes)
con_text = text[0]
while idx < len(ocr_results):
n_boxes, n_text = ocr_results[idx]
if abs(n_boxes[0][1] - boxes[0][1]) < h * 0.01 and \
abs(n_boxes[3][1] - boxes[3][1]) < h * 0.01:
con_boxes[1] = n_boxes[1]
con_boxes[2] = n_boxes[2]
con_text = con_text + ' ' + n_text[0]
idx += 1
else:
break
candidates.append((con_boxes, con_text))
# TODO(Binbin Zhang): Only support horion center subtitle
if len(candidates) > 0:
sub_boxes, subtitle = candidates[-1]
# offset is less than 10%
if (sub_boxes[0][0] + sub_boxes[1][0]) / w > 0.70: # 这里降低了要求
return True, box2int(sub_boxes), subtitle
return False, None, None
|
You save my DAY!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[2023/12/06 09:48:47] ppocr DEBUG: dt_boxes num : 1, elapsed : 1.3040359020233154
[2023/12/06 09:48:47] ppocr DEBUG: cls num : 1, elapsed : 0.038794517517089844
[2023/12/06 09:48:47] ppocr DEBUG: rec_res num : 1, elapsed : 0.24462223052978516
Traceback (most recent call last):
File "/bin/python3.9/bin/wesubtitle", line 33, in
sys.exit(load_entry_point('wesubtitle==0.0.1', 'console_scripts', 'wesubtitle')())
File "/bin/python3.9/lib/python3.9/site-packages/wesubtitle-0.0.1-py3.9.egg/wesubtitle/main.py", line 129, in main
detected, box, content = detect_subtitle_area(ocr_results, h, w)
File "/bin/python3.9/lib/python3.9/site-packages/wesubtitle-0.0.1-py3.9.egg/wesubtitle/main.py", line 28, in detect_subtitle_area
while idx < len(ocr_results):
Uploading test.mp4…
The text was updated successfully, but these errors were encountered: