QIN2DIM / hcaptcha-challenger

🥂 Gracefully face hCaptcha challenge with MoE(ONNX) embedded solution.
https://docs.captchax.top/
GNU General Public License v3.0
1.48k stars 253 forks source link

[Q&A] How to use nested categories #835

Closed pawssx closed 10 months ago

pawssx commented 10 months ago

Brief description

Hi! i have problem while running nested prompt: "Please click on the largest animal." I can see they have .onyx models and they are in objects.yaml but i dont now how to run it propertly.I use demo_classify.py from examples. I would be grateful for any help.

Error

2023-10-15 18:39:56 | DEBUG - Types of challenges not yet scheduled - {'label': 'please click on the largest animal', 'prompt': 'Please click on the largest animal.'}
QIN2DIM commented 10 months ago

upgrade to latest version v0.8.7 ++

pip install -U hcaptcha-challenger[playwright]

and install(upgrade=True) to refresh assets cache

pawssx commented 10 months ago

I tried version 0.8.7, 0.8.7-post1 and pip install -U hcaptcha-challenger[playwright] all with install(upgrade=True) but still im getting same error 2023-10-15 19:08:08 | DEBUG - Types of challenges not yet scheduled - {'label': 'please click on the largest animal', 'prompt': 'Please click on the largest animal.'}

QIN2DIM commented 10 months ago

How do you use it 0.0

QIN2DIM commented 10 months ago

fine, I didn't export this feat as an example. If you do not use it in the context of AgentT, you cannot activate trigger this feature.

'nested categories' needs to provide an' example image 'and a' challenge prompt 'to filter and sort models, and then select the best model to do the second processing of' challenge images'.

https://github.com/QIN2DIM/hcaptcha-challenger/blob/54a00018d57b9376261446bca679920d9bc47d98/hcaptcha_challenger/agents/playwright/control.py#L378-L400

https://github.com/QIN2DIM/hcaptcha-challenger/blob/54a00018d57b9376261446bca679920d9bc47d98/hcaptcha_challenger/agents/playwright/control.py#L649-L658

pawssx commented 10 months ago

So what would I have to change in demo_classify.py to make it work? I'm too stupid to understand how it works exactly. I would be very grateful for your help.

QIN2DIM commented 10 months ago

@pawssx @vxrip So what I'm saying is, how do you use this program, I can just wrap a high-level interface.

pawssx commented 10 months ago

Im currently using demo_classify.py: ` import os from pathlib import Path

import hcaptcha_challenger as solver

solver.install(upgrade=True)

prompt = "diamond bracelet"

label_dir = Path(file).parent.joinpath("diamond_bracelet")

images = [label_dir.joinpath(fn).read_bytes() for fn in os.listdir(label_dir)]

def bytedance(): classifier = solver.BinaryClassifier() if result := classifier.execute(prompt, images): for i, name in enumerate(os.listdir(label_dir)): print(f"{name} - {result[i]}")

if name == "main": bytedance() `

But if nested categories dont work on this code i can switch to anything but without selenium and as always i will be very grateful for help

QIN2DIM commented 10 months ago

I mean, how did you import hcaptcha_challenger and use it in your project.

It's impossible to just run this example, right?😅

Since you'll be thinking about handling the largest animal challenge prompt, you should need a browser rendering challenge, so you can use the playwright version of the code. I guess

pawssx commented 10 months ago

Im using hcaptcha challenger literally same as demo_classify code here:

import os, json
from pathlib import Path
import time
import hcaptcha_challenger as solver
solver.install(flush_yolo=True, upgrade=True)

def solvecapclas(prompt: str, path: str):
    cap_prompt = prompt
    label_dir = Path(__file__).parent.joinpath("solverdata", "classify", path)
    images = [label_dir.joinpath(fn).read_bytes() for fn in os.listdir(label_dir)]

    classifier = solver.BinaryClassifier()

    if result := classifier.execute(cap_prompt, images):

        answers1 = {
            name[:-5]: result[i]
            for i, name in enumerate(os.listdir(label_dir))
        }
        return json.dumps(answers1)

Im getting all the images from request. I want to notice that from that from that same request i can get example_question soo it would be possible to specify a .onyx model without selenium but im not too smart to do this

QIN2DIM commented 10 months ago

emmmm......

This looks like it's just a change to the example code.

pawssx commented 10 months ago

its literally 1:1 thats why im asking if its possible that you could help me or do a new example i was thinking about separate .onyx model that will match example images

QIN2DIM commented 10 months ago

Your requirement is too simple, I changed some of the code of classifier, you only need to pass one more parameter.

see more:

https://github.com/QIN2DIM/hcaptcha-challenger/blob/main/examples/demo_rank_largest_animal.py