Ejemplo n.º 1
0
    def __init__(
        self,
        api_key: Optional[str] = None,
        save_dir: Optional[str] = None,
        workspace: Optional[str] = None,
        project_name: Optional[str] = None,
        rest_api_key: Optional[str] = None,
        experiment_name: Optional[str] = None,
        experiment_key: Optional[str] = None,
        offline: bool = False,
        **kwargs,
    ):

        if not _COMET_AVAILABLE:
            raise ImportError(
                "You want to use `comet_ml` logger which is not installed yet,"
                " install it with `pip install comet-ml`.")
        super().__init__()
        self._experiment = None

        # Determine online or offline mode based on which arguments were passed to CometLogger
        api_key = api_key or get_api_key(None, get_config())

        if api_key is not None and save_dir is not None:
            self.mode = "offline" if offline else "online"
            self.api_key = api_key
            self._save_dir = save_dir
        elif api_key is not None:
            self.mode = "online"
            self.api_key = api_key
            self._save_dir = None
        elif save_dir is not None:
            self.mode = "offline"
            self._save_dir = save_dir
        else:
            # If neither api_key nor save_dir are passed as arguments, raise an exception
            raise MisconfigurationException(
                "CometLogger requires either api_key or save_dir during initialization."
            )

        log.info(f"CometLogger will be initialized in {self.mode} mode")

        self.workspace = workspace
        self._project_name = project_name
        self._experiment_key = experiment_key
        self._experiment_name = experiment_name
        self._kwargs = kwargs
        self._future_experiment_key = None

        if rest_api_key is not None:
            # Comet.ml rest API, used to determine version number
            self.rest_api_key = rest_api_key
            self.comet_api = API(self.rest_api_key)
        else:
            self.rest_api_key = None
            self.comet_api = None

        self._kwargs = kwargs
Ejemplo n.º 2
0
    def get_api_key_or_login(self, api_key):
        # ok
        api_key = get_api_key(api_key, self.config)

        if api_key is None:
            return self.create_or_login()

        Reporting.report("mlflow_existing_user", api_key=api_key)

        return (api_key, None)
Ejemplo n.º 3
0
    """
    config_path = Path(config_path)

    model = CenterTrack(
        model=model_type,
        config_path=config_path,
        epoch_size=epoch_size,
        batch_size=batch_size,
        n_workers=n_workers,
        img_scale=img_scale,
        label_scale=label_scale,
        grayscale=grayscale,
    )
    print(f"# parameters: {sum(p.numel() for p in model.parameters()):,}")

    api_key = get_api_key(None, get_config())
    project_name = "vsrl"
    exp_name = f"detector_{config_path.name.split('.')[0]}"
    if use_logger:
        logger = CometLogger(
            api_key,
            save_dir,
            project_name=project_name,
            experiment_name=exp_name,
            force_offline=force_offline,
            log_env_gpu=False,
            log_env_cpu=False,
        )

        logger.log_hyperparams({
            "img_scale": img_scale,