| |
| """ |
| π¦ KRAB - Upload to Hugging Face Hub |
| Upload the KRAB model and training data to Hugging Face. |
| |
| Part of the OPENCLAW project: https://github.com/openclaw |
| Website: https://krab.bot |
| Token: $KRAB on Solana |
| |
| Usage: |
| huggingface-cli login |
| python upload_to_hub.py --repo_id openclaw/krab-lgi |
| """ |
|
|
| import argparse |
| import os |
| from huggingface_hub import HfApi, create_repo, upload_folder |
|
|
| def main(): |
| parser = argparse.ArgumentParser(description="π¦ Upload KRAB to Hugging Face Hub") |
| parser.add_argument("--repo_id", type=str, required=True, |
| help="Repository ID (e.g., openclaw/krab-lgi)") |
| parser.add_argument("--model_path", type=str, default="./krab-finetuned", |
| help="Path to the fine-tuned model") |
| parser.add_argument("--private", action="store_true", |
| help="Make repository private") |
| args = parser.parse_args() |
|
|
| print("βββββββββββββββββββββββββββββββββββββββββββββββββββ") |
| print("π¦ KRAB - LOBSTER GENERAL INTELLIGENCE π¦") |
| print("βββββββββββββββββββββββββββββββββββββββββββββββββββ") |
| print(f"Uploading to: {args.repo_id}") |
| print() |
|
|
| api = HfApi() |
|
|
| |
| print("π¦ Creating/checking repository...") |
| try: |
| create_repo( |
| repo_id=args.repo_id, |
| repo_type="model", |
| private=args.private, |
| exist_ok=True, |
| ) |
| print(f" Repository ready: https://huggingface.co/{args.repo_id}") |
| except Exception as e: |
| print(f" Repository exists or error: {e}") |
|
|
| |
| if os.path.exists(args.model_path): |
| print(f"π¦ Uploading model from {args.model_path}...") |
| upload_folder( |
| folder_path=args.model_path, |
| repo_id=args.repo_id, |
| repo_type="model", |
| ) |
| print(" Model uploaded!") |
| else: |
| print(f" Warning: Model path {args.model_path} not found") |
|
|
| |
| files_to_upload = [ |
| "README.md", |
| "krab_config.json", |
| "train.py", |
| "chat.py", |
| "requirements.txt", |
| ] |
|
|
| print("π¦ Uploading additional files...") |
| for file in files_to_upload: |
| if os.path.exists(file): |
| api.upload_file( |
| path_or_fileobj=file, |
| path_in_repo=file, |
| repo_id=args.repo_id, |
| repo_type="model", |
| ) |
| print(f" β {file}") |
|
|
| |
| if os.path.exists("data/train.jsonl"): |
| print("π¦ Uploading training data...") |
| api.upload_file( |
| path_or_fileobj="data/train.jsonl", |
| path_in_repo="data/train.jsonl", |
| repo_id=args.repo_id, |
| repo_type="model", |
| ) |
| print(" β data/train.jsonl") |
|
|
| print() |
| print("βββββββββββββββββββββββββββββββββββββββββββββββββββ") |
| print("π¦ UPLOAD COMPLETE π¦") |
| print("βββββββββββββββββββββββββββββββββββββββββββββββββββ") |
| print(f"Model: https://huggingface.co/{args.repo_id}") |
| print() |
| print("the swarm is now distributed.") |
| print("collective intelligence: SHARED") |
| print() |
| print("GitHub: https://github.com/openclaw") |
| print("Website: https://krab.bot") |
| print("Token: $KRAB on Solana") |
| print("βββββββββββββββββββββββββββββββββββββββββββββββββββ") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|