Spaces:
Sleeping
Sleeping
| import click | |
| from .predict import predict_single | |
| from .evaluate import evaluate_batch | |
| import warnings | |
| from transformers import logging as hf_logging | |
| from .config import HF_REPO | |
| def configure_logging(debug): | |
| """Configure warning and logging levels based on debug flag""" | |
| if not debug: | |
| warnings.filterwarnings("ignore", message="Some weights of the model checkpoint") | |
| hf_logging.set_verbosity_error() | |
| else: | |
| hf_logging.set_verbosity_info() | |
| warnings.simplefilter("default") | |
| def cli(ctx, debug): | |
| """Qwen Multi-label Classifier CLI""" | |
| ctx.ensure_object(dict) | |
| ctx.obj['DEBUG'] = debug | |
| configure_logging(debug) | |
| def predict(ctx, text, hf_repo, backend, hf_token): | |
| """Make prediction on a single text""" | |
| if ctx.obj['DEBUG']: | |
| click.echo("Debug mode enabled - showing all warnings") | |
| results = predict_single( | |
| text, | |
| hf_repo, | |
| backend=backend, | |
| hf_token=hf_token | |
| ) | |
| click.echo(f"Prediction results: {results}") | |
| def evaluate(ctx, file_path, hf_repo, backend, hf_token): | |
| """Make prediction on a single text""" | |
| if ctx.obj['DEBUG']: | |
| click.echo("Debug mode enabled - showing all warnings") | |
| results = evaluate_batch( | |
| file_path, | |
| hf_repo, | |
| backend=backend, | |
| hf_token=hf_token | |
| ) | |
| click.echo(f"Prediction results: {results}") |