| import os |
| import time |
| from huggingface_hub import HfApi, snapshot_download |
| from datasets import load_dataset |
|
|
| |
| DATASET_ID = "toecm/IEDID" |
| MODEL_ID = "toecm/PureVersation_Model" |
| THRESHOLD = 1000 |
| HF_TOKEN = os.environ.get("HF_TOKEN") |
|
|
| api = HfApi(token=HF_TOKEN) |
|
|
| def check_and_trigger_training(): |
| print("🔍 Checking Pure Chain status...") |
| |
| |
| try: |
| ds = load_dataset(DATASET_ID, split="train", streaming=True, token=HF_TOKEN) |
| |
| |
| dataset_info = api.dataset_info(DATASET_ID) |
| last_modified = dataset_info.lastModified |
| |
| |
| |
| |
| count = 0 |
| for row in ds: |
| if row.get('status') == 'verified': |
| count += 1 |
| |
| print(f"✅ Found {count} verified clips.") |
|
|
| if count >= THRESHOLD: |
| print("🚀 Threshold reached! Triggering AutoTrain...") |
| trigger_autotrain(count) |
| else: |
| print(f"💤 Not enough data yet ({count}/{THRESHOLD}). Sleeping.") |
|
|
| except Exception as e: |
| print(f"❌ Error checking dataset: {e}") |
|
|
| def trigger_autotrain(data_count): |
| |
| |
| |
| from autotrain.api import AutoTrainClient |
| client = AutoTrainClient(hf_token=HF_TOKEN) |
| |
| |
| project_name = f"pure-versation-finetune-{int(time.time())}" |
| client.create_project(project_name, task="speech-recognition") |
| |
| |
| print(f"🔥 Training job '{project_name}' started with {data_count} clips.") |
| |
| |
| |
|
|
| if __name__ == "__main__": |
| |
| while True: |
| check_and_trigger_training() |
| time.sleep(86400) |