Skip to content

Commit

Permalink
ffe
Browse files Browse the repository at this point in the history
  • Loading branch information
QIN2DIM committed Oct 22, 2023
1 parent 36e8b9b commit ba31efe
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion automation/assets_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def merge(self, fd: Path, td: Path):


def run():
sources = "https://github.com/QIN2DIM/hcaptcha-challenger/issues/696"
sources = "https://github.com/QIN2DIM/hcaptcha-challenger/issues/855"
am = AssetsManager.from_sources(sources)
am.execute()

Expand Down
50 changes: 40 additions & 10 deletions automation/check_yolo_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,58 @@
from __future__ import annotations

import os
import shutil
import sys
from pathlib import Path

from hcaptcha_challenger import install
import onnxruntime
from hcaptcha_challenger import install, YOLOv8
from hcaptcha_challenger.components.yolo_mocker import CcYOLO
from hcaptcha_challenger.onnx.modelhub import request_resource

install(upgrade=True)

# model_name = "burl_head_of_the_lion_2309_yolov8s.onnx"
model_name = "head_of_the_animal_2310_yolov8s.onnx"
images_dir = ""

this_dir = Path(__file__).parent
output_dir = this_dir.joinpath("yolo_mocker")
class CbYOLO(CcYOLO):
def __init__(self, model_name: str, images_absolute_dir: Path, this_dir: Path, classes=None):
super().__init__(model_name, images_absolute_dir, this_dir)
self.classes = classes

if isinstance(images_dir, str):
images_dir = Path(images_dir)
images_dir = images_dir.absolute()
def get_model(self) -> YOLOv8 | None:
classes = self.modelhub.ashes_of_war.get(self.model_name)
if not classes:
if not self.classes:
raise AttributeError(f"Model name not found - {self.model_name=}")
print(f">> Match model - {self.model_name=}")
model_path = Path(self.model_name)
if not model_path.exists():
request_resource(self.model_url + self.model_name, model_path)
try:
session = onnxruntime.InferenceSession(
model_path, providers=onnxruntime.get_available_providers()
)
detector = YOLOv8.from_pluggable_model(session, self.classes)
except Exception as err:
print(err)
shutil.rmtree(model_path, ignore_errors=True)
else:
return detector


def run():
ccy = CcYOLO(model_name, images_dir, output_dir)
# model_name = "burl_head_of_the_lion_2309_yolov8s.onnx"
model_name = "head_of_the_animal_turtle_2309_yolov8s.onnx"
classes = ["animal-head"]
images_dir = r"zip_dir/click_on_the_turtle_s_head_default"

this_dir = Path(__file__).parent
output_dir = this_dir.joinpath("yolo_mocker")

if isinstance(images_dir, str):
images_dir = Path(images_dir)
images_dir = images_dir.absolute()

ccy = CbYOLO(model_name, images_dir, output_dir, classes)
ccy.spawn()

if "win32" in sys.platform:
Expand Down
2 changes: 1 addition & 1 deletion automation/datasets_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from playwright.async_api import BrowserContext as ASyncContext, async_playwright

collected = []
per_times = 80
per_times = 60
tmp_dir = Path(__file__).parent.joinpath("tmp_dir")
sitekey = SiteKey.user_easy

Expand Down

0 comments on commit ba31efe

Please sign in to comment.