krab / upload_to_hub.py
moltbot's picture
Upload 6 files
fd8c157 verified
#!/usr/bin/env python3
"""
🦞 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()
# Create repo if it doesn't exist
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}")
# Upload model files
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")
# Upload additional files
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}")
# Upload training data
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()