Skip to content

Commit

Permalink
ffe
Browse files Browse the repository at this point in the history
  • Loading branch information
QIN2DIM committed Oct 21, 2023
1 parent 0b67fc8 commit 36e8b9b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 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/851"
sources = "https://github.com/QIN2DIM/hcaptcha-challenger/issues/696"
am = AssetsManager.from_sources(sources)
am.execute()

Expand Down
31 changes: 19 additions & 12 deletions automation/auto_labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,23 @@ class DataGroup:
joined_dirs: List[str]
negative_labels: List[str]

_labeler: AutoLabeling | None = None

def __post_init__(self):
self.positive = self.positive.replace("_", " ")

@property
def input_dir(self):
return db_dir.joinpath(*self.joined_dirs).absolute()

@property
def output_dir(self):
return self._labeler.output_dir

def auto_labeling(self, **kwargs):
positive_label = split_prompt_message(label_cleaning(self.positive), "en")
candidate_labels = [positive_label]
if isinstance(self.negative_labels, list) and len(self.negative_labels) != 0:
candidate_labels.extend(self.negative_labels)

self._labeler = AutoLabeling.from_prompt(positive_label, candidate_labels, self.input_dir)
self._labeler.execute(limit=kwargs.get("limit"))
al = AutoLabeling.from_prompt(positive_label, candidate_labels, self.input_dir)
al.execute(limit=kwargs.get("limit"))

return self
return al


def edit_in_the_common_cases():
Expand All @@ -159,10 +153,23 @@ def edit_in_the_common_cases():
# negative_labels=["phone", "playground", "laptop", "chess", "helicopter", "icecream"],
# ).auto_labeling(limit="all")

# nox = DataGroup(
# positive="natural_landscape",
# joined_dirs=["natural_landscape"],
# negative_labels=["laptop", "helicopter", "chess", "playground"]
# ).auto_labeling(limit="all")

nox = DataGroup(
positive="natural_landscape",
joined_dirs=["natural_landscape"],
negative_labels=["laptop", "helicopter", "chess", "playground"]
positive="electronic device",
joined_dirs=["electronic_device"],
negative_labels=[
"helicopter",
"chess",
"playground",
"natural landscape",
"plant",
"somthing can be eaten",
],
).auto_labeling(limit="all")

if "win32" in sys.platform and nox.output_dir:
Expand Down
3 changes: 2 additions & 1 deletion automation/roboflow_resnet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"outputs": [],
"source": [
"from __future__ import annotations\n",
"\n",
"!nvidia-smi"
],
"metadata": {
Expand Down Expand Up @@ -275,7 +276,7 @@
" def to_yaml(self, path: Path | None = None):\n",
" path = path or Path(\"objects-tmp.yaml\")\n",
" with open(path, \"w\", encoding=\"utf8\") as file:\n",
" yaml.safe_dump(self.__dict__, file, sort_keys=False, allow_unicode=True, line_break=\"\\n\")\n",
" yaml.safe_dump(self.__dict__, file, sort_keys=False, allow_unicode=True)\n",
" return path\n",
"\n",
" @staticmethod\n",
Expand Down
2 changes: 1 addition & 1 deletion automation/zip_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def zip_dataset(prompt: str):
print(f">> OUTPUT - {zip_path=}")


zip_dataset(prompt="natural landscape")
zip_dataset(prompt="electronic_device")
webbrowser.open(
"https://colab.research.google.com/github/captcha-challenger/hcaptcha-model-factory/blob/main/automation/roboflow_resnet.ipynb"
)

0 comments on commit 36e8b9b

Please sign in to comment.