Skip to content

Commit

Permalink
Optionally disable SSL if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelstevens committed Oct 24, 2024
1 parent eca41da commit 974fdf7
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
import logging
import typing

import tyro

import saev

log_format = "[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=log_format)
logger = logging.getLogger("main")


def activations(
cfg: typing.Annotated[saev.Config, tyro.conf.arg(name="")],
disable_ssl: bool = False,
):
"""
Save ViT activations for use later on.
Args:
cfg: Configuration for experiment.
disable_ssl: Whether to ignore ssl when downloading models and such.
"""
if disable_ssl:
logger.warning("Ignoring SSL certs. Try not to do this!")
# https://github.com/openai/whisper/discussions/734#discussioncomment-4491761
# Ideally we don't have to disable SSL but we are only downloading weights.
import ssl

ssl._create_default_https_context = ssl._create_unverified_context

def activations(cfg: typing.Annotated[saev.Config, tyro.conf.arg(name="")]):
"""Save ViT activations for use later on."""
import saev.modeling

vit = saev.modeling.RecordedVit(cfg)
logger.info("Loaded ViT '%s'.", cfg.model)
saev.modeling.save_acts(cfg, vit)


Expand Down Expand Up @@ -38,3 +61,4 @@ def train(cfg: typing.Annotated[saev.Config, tyro.conf.arg(name="")]):
"activations": activations,
"train": train,
})
logger.info("Done.")

0 comments on commit 974fdf7

Please sign in to comment.