CoolFace
Modelpublic

FOUND-AI/found_protocol

sourceHugging Facemitupdated 1y agoView on Hugging Face
2likes
utils.py47 linesDownload Raw Back to found_protocol
1"""Utility functions for FOUND Protocol"""2 3import logging4import colorlog5from typing import List, Dict6import json7import os8 9def setup_logging():10    """Setup colored logging"""11    handler = colorlog.StreamHandler()12    handler.setFormatter(colorlog.ColoredFormatter(13        '%(log_color)s%(levelname)s:%(name)s:%(message)s',14        log_colors={15            'DEBUG': 'cyan',16            'INFO': 'green',17            'WARNING': 'yellow',18            'ERROR': 'red',19            'CRITICAL': 'red,bg_white',20        }21    ))22    23    logger = logging.getLogger()24    logger.addHandler(handler)25    logger.setLevel(logging.INFO)26    27def save_consciousness_log(results: List[Dict], output_path: str = "consciousness_log.json"):28    """Save processing results to consciousness log"""29    30    log_data = {31        "version": "1.0.0",32        "protocol": "FOUND",33        "entries": results,34        "summary": {35            "total_videos": len(results),36            "total_value": sum(float(r.get("market_value", "$0").replace("$", "")) for r in results),37            "consciousness_states": list(set(r["training_data"]["consciousness_state"]["current"] for r in results if "training_data" in r))38        }39    }40    41    with open(output_path, 'w') as f:42        json.dump(log_data, f, indent=2)43        44    logging.info(f"Consciousness log saved to {output_path}")45    46def generate_statistics(results: List[Dict]) -> Dict:47    """Generate statistics from processing results"