Skip to content

Commit

Permalink
build fixes and old tests removed
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisoro committed Jan 24, 2025
1 parent 01d5bb8 commit 25e4d31
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.2
rev: v0.9.3
hooks:
- id: ruff
args: [--fix]
Expand Down
Binary file modified dependencies/tesserocr-2.7.1-cp313-cp313-win_amd64.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import tesserocr # noqa # Note: Somehow needed, otherwise the binary has an issue with tesserocr
from PIL import Image # noqa # Note: Somehow needed, otherwise the binary has an issue with tesserocr
import logging
import os
import sys
Expand All @@ -7,7 +8,6 @@

import keyboard
from beautifultable import BeautifulTable
from PIL import Image # noqa # Note: Somehow needed, otherwise the binary has an issue with tesserocr

import src.logger
from src import __version__
Expand Down
10 changes: 6 additions & 4 deletions src/utils/ocr/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import cv2
import numpy as np
from tesserocr import OEM, RIL, PyTessBaseAPI
import tesserocr

from src.config import BASE_DIR
from src.config.data import COLORS
Expand All @@ -24,13 +24,15 @@ def __init__(self):
self._apis = []
self._lock = threading.Lock()

def get_api(self, user: uuid.UUID) -> PyTessBaseAPI:
def get_api(self, user: uuid.UUID) -> tesserocr.PyTessBaseAPI:
with self._lock:
for api in self._apis:
if not api["user"]:
api["user"] = user
return api["api"]
new_api = PyTessBaseAPI(psm=3, oem=OEM.LSTM_ONLY, path=str(self.tessdata_path), lang=IniConfigLoader().general.language)
new_api = tesserocr.PyTessBaseAPI(
psm=3, oem=tesserocr.OEM.LSTM_ONLY, path=str(self.tessdata_path), lang=IniConfigLoader().general.language
)
new_api.SetVariable("debug_file", "/dev/null")
self._apis.append({"api": new_api, "user": user})
return new_api
Expand Down Expand Up @@ -69,7 +71,7 @@ def image_to_text(img: np.ndarray, line_boxes: bool = False, do_pre_proc: bool =
text = api.GetUTF8Text().strip()
res = OcrResult(original_text=text, text=text, word_confidences=api.AllWordConfidences(), mean_confidence=api.MeanTextConf())
if line_boxes:
line_boxes_res = api.GetComponentImages(RIL.TEXTLINE, True)
line_boxes_res = api.GetComponentImages(tesserocr.RIL.TEXTLINE, True)
_APILoader().release_api(my_id)
return res, line_boxes_res
_APILoader().release_api(my_id)
Expand Down
Binary file not shown.
Binary file not shown.
17 changes: 0 additions & 17 deletions tests/item/read_descr_season5_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,6 @@
rarity=ItemRarity.Mythic,
),
),
(
(1920, 1080),
f"{BASE_PATH}/1080p_small_read_descr_3.png",
Item(
affixes=[
Affix(name="maximum_life", value=950),
Affix(name="cooldown_reduction", value=9.1, type=AffixType.rerolled),
Affix(name="to_conjuration_mastery", value=2),
Affix(name="unstable_currents_cooldown_reduction", value=16.1, type=AffixType.tempered),
Affix(name="overpower_damage", value=80.5, type=AffixType.tempered),
],
inherent=[Affix(name="resistance_to_all_elements", value=25, type=AffixType.inherent)],
item_type=ItemType.Amulet,
power=925,
rarity=ItemRarity.Legendary,
),
),
(
(1920, 1080),
f"{BASE_PATH}/1080p_small_read_descr_4.png",
Expand Down
17 changes: 0 additions & 17 deletions tests/item/read_descr_season6_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,6 @@
rarity=ItemRarity.Unique,
),
),
(
(2160, 1440),
f"{BASE_PATH}/1440p_small_read_descr_2.png",
Item(
affixes=[
Affix(name="maximum_resource", value=8),
Affix(name="critical_strike_damage", value=76),
Affix(name="chance_for_core_skills_to_hit_twice", value=24),
Affix(name="to_velocity", value=3),
],
aspect=Aspect(name="rod_of_kepeleke", value=2.2),
inherent=[Affix(name="block_chance", value=40, type=AffixType.inherent)],
item_type=ItemType.Quarterstaff,
power=750,
rarity=ItemRarity.Unique,
),
),
(
(2160, 1440),
f"{BASE_PATH}/1440p_small_read_descr_3.png",
Expand Down

0 comments on commit 25e4d31

Please sign in to comment.