GameSentenceMiner 2.13.15__py3-none-any.whl → 2.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- GameSentenceMiner/ai/ai_prompting.py +77 -132
- GameSentenceMiner/anki.py +48 -6
- GameSentenceMiner/config_gui.py +196 -30
- GameSentenceMiner/gametext.py +8 -19
- GameSentenceMiner/gsm.py +5 -4
- GameSentenceMiner/locales/en_us.json +21 -11
- GameSentenceMiner/locales/ja_jp.json +21 -11
- GameSentenceMiner/locales/zh_cn.json +9 -11
- GameSentenceMiner/obs.py +6 -5
- GameSentenceMiner/owocr/owocr/ocr.py +28 -25
- GameSentenceMiner/tools/__init__.py +0 -0
- GameSentenceMiner/util/configuration.py +241 -105
- GameSentenceMiner/util/db.py +408 -0
- GameSentenceMiner/util/ffmpeg.py +2 -10
- GameSentenceMiner/util/get_overlay_coords.py +331 -0
- GameSentenceMiner/util/model.py +8 -2
- GameSentenceMiner/util/text_log.py +1 -1
- GameSentenceMiner/web/texthooking_page.py +1 -1
- GameSentenceMiner/wip/__init___.py +0 -0
- {gamesentenceminer-2.13.15.dist-info → gamesentenceminer-2.14.0.dist-info}/METADATA +5 -1
- {gamesentenceminer-2.13.15.dist-info → gamesentenceminer-2.14.0.dist-info}/RECORD +28 -26
- GameSentenceMiner/util/package.py +0 -37
- GameSentenceMiner/wip/get_overlay_coords.py +0 -535
- /GameSentenceMiner/{util → tools}/audio_offset_selector.py +0 -0
- /GameSentenceMiner/{util → tools}/ss_selector.py +0 -0
- /GameSentenceMiner/{util → tools}/window_transparency.py +0 -0
- {gamesentenceminer-2.13.15.dist-info → gamesentenceminer-2.14.0.dist-info}/WHEEL +0 -0
- {gamesentenceminer-2.13.15.dist-info → gamesentenceminer-2.14.0.dist-info}/entry_points.txt +0 -0
- {gamesentenceminer-2.13.15.dist-info → gamesentenceminer-2.14.0.dist-info}/licenses/LICENSE +0 -0
- {gamesentenceminer-2.13.15.dist-info → gamesentenceminer-2.14.0.dist-info}/top_level.txt +0 -0
@@ -280,7 +280,10 @@ class GoogleLens:
|
|
280
280
|
logger.info('Google Lens ready')
|
281
281
|
|
282
282
|
def __call__(self, img, furigana_filter_sensitivity=0, return_coords=False):
|
283
|
-
furigana_filter_sensitivity
|
283
|
+
if furigana_filter_sensitivity != None:
|
284
|
+
furigana_filter_sensitivity = get_furigana_filter_sensitivity()
|
285
|
+
else:
|
286
|
+
furigana_filter_sensitivity = 0
|
284
287
|
lang = get_ocr_language()
|
285
288
|
img, is_path = input_to_pil_image(img)
|
286
289
|
if lang != self.initial_lang:
|
@@ -900,9 +903,12 @@ class OneOCR:
|
|
900
903
|
self.regex = re.compile(
|
901
904
|
r'[a-zA-Z\u00C0-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u1D00-\u1D7F\u1D80-\u1DBF\u1E00-\u1EFF\u2C60-\u2C7F\uA720-\uA7FF\uAB30-\uAB6F]')
|
902
905
|
|
903
|
-
def __call__(self, img, furigana_filter_sensitivity=0, return_coords=False, multiple_crop_coords=False):
|
906
|
+
def __call__(self, img, furigana_filter_sensitivity=0, return_coords=False, multiple_crop_coords=False, return_one_box=True):
|
904
907
|
lang = get_ocr_language()
|
905
|
-
furigana_filter_sensitivity
|
908
|
+
if furigana_filter_sensitivity != None:
|
909
|
+
furigana_filter_sensitivity = get_furigana_filter_sensitivity()
|
910
|
+
else:
|
911
|
+
furigana_filter_sensitivity = 0
|
906
912
|
if lang != self.initial_lang:
|
907
913
|
self.initial_lang = lang
|
908
914
|
self.regex = get_regex(lang)
|
@@ -983,23 +989,15 @@ class OneOCR:
|
|
983
989
|
# else:
|
984
990
|
# continue
|
985
991
|
# res += '\n'
|
986
|
-
|
987
|
-
for line in filtered_lines:
|
988
|
-
for word in line['words']:
|
989
|
-
box = {
|
990
|
-
"text": word['text'],
|
991
|
-
"bounding_rect": word['bounding_rect']
|
992
|
-
}
|
993
|
-
boxes.append(box)
|
992
|
+
else:
|
994
993
|
res = ocr_resp['text']
|
995
|
-
|
994
|
+
|
995
|
+
if multiple_crop_coords:
|
996
|
+
logger.info(f"Getting multiple crop coords for {len(filtered_lines)} lines")
|
996
997
|
for line in filtered_lines:
|
997
998
|
crop_coords_list.append(
|
998
999
|
(line['bounding_rect']['x1'] - 5, line['bounding_rect']['y1'] - 5,
|
999
1000
|
line['bounding_rect']['x3'] + 5, line['bounding_rect']['y3'] + 5))
|
1000
|
-
res = ocr_resp['text']
|
1001
|
-
else:
|
1002
|
-
res = ocr_resp['text']
|
1003
1001
|
|
1004
1002
|
except RuntimeError as e:
|
1005
1003
|
return (False, e)
|
@@ -1015,12 +1013,14 @@ class OneOCR:
|
|
1015
1013
|
return (False, 'Unknown error!')
|
1016
1014
|
|
1017
1015
|
res = res.json()['text']
|
1016
|
+
|
1017
|
+
x = [True, res]
|
1018
1018
|
if return_coords:
|
1019
|
-
x
|
1020
|
-
|
1021
|
-
x
|
1022
|
-
|
1023
|
-
x
|
1019
|
+
x.append(filtered_lines)
|
1020
|
+
if multiple_crop_coords:
|
1021
|
+
x.append(crop_coords_list)
|
1022
|
+
if return_one_box:
|
1023
|
+
x.append(crop_coords)
|
1024
1024
|
if is_path:
|
1025
1025
|
img.close()
|
1026
1026
|
return x
|
@@ -1410,9 +1410,12 @@ class localLLMOCR:
|
|
1410
1410
|
base_url=self.api_url.replace('/v1/chat/completions', '/v1'),
|
1411
1411
|
api_key=self.api_key
|
1412
1412
|
)
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1413
|
+
if self.client.models.retrieve(self.model):
|
1414
|
+
self.model = self.model
|
1415
|
+
logger.info(f'Local LLM OCR (OpenAI-compatible) ready with model {self.model}')
|
1416
|
+
if self.keep_warm:
|
1417
|
+
self.keep_llm_hot_thread = threading.Thread(target=self.keep_llm_warm, daemon=True)
|
1418
|
+
self.keep_llm_hot_thread.start()
|
1416
1419
|
except Exception as e:
|
1417
1420
|
logger.warning(f'Error initializing Local LLM OCR, Local LLM OCR will not work!')
|
1418
1421
|
|
@@ -1441,7 +1444,7 @@ class localLLMOCR:
|
|
1441
1444
|
prompt = self.custom_prompt.strip()
|
1442
1445
|
else:
|
1443
1446
|
prompt = f"""
|
1444
|
-
Extract all {CommonLanguages.from_code(get_ocr_language())} Text from Image. Ignore all Furigana. Do not return any commentary, just the text in the image. If there is no text in the image, return "" (Empty String).
|
1447
|
+
Extract all {CommonLanguages.from_code(get_ocr_language()).name} Text from Image. Ignore all Furigana. Do not return any commentary, just the text in the image. If there is no text in the image, return "" (Empty String).
|
1445
1448
|
"""
|
1446
1449
|
|
1447
1450
|
response = self.client.chat.completions.create(
|
@@ -1455,7 +1458,7 @@ class localLLMOCR:
|
|
1455
1458
|
],
|
1456
1459
|
}
|
1457
1460
|
],
|
1458
|
-
max_tokens=
|
1461
|
+
max_tokens=4096,
|
1459
1462
|
temperature=0.1
|
1460
1463
|
)
|
1461
1464
|
self.last_ocr_time = time.time()
|
File without changes
|