No project description provided
Project description
clipscope
usage
import PIL
from clipscope import ConfiguredViT, TopKSAE
device='cpu'
filename_in_hf_repo = "725159424.pt"
sae = TopKSAE.from_pretrained(repo_id="lewington/CLIP-ViT-L-scope", filename=filename_in_hf_repo, device=device)
transformer_name='laion/CLIP-ViT-L-14-laion2B-s32B-b82K'
locations = [(22, 'resid')]
transformer = ConfiguredViT(locations, transformer_name, device=device)
# input = PIL.Image.open("test.jpg")
# input = input.resize((224, 224)).convert("RGB")
input = PIL.Image.new("RGB", (224, 224), (0, 0, 0)) # black image for testing
activations = transformer.all_activations(input) # (1, 257, 1024)
print('activations shape', activations.shape)
output = sae(activations)
print('output keys', output.keys())
print('latent shape', output['latent'].shape) # (1, 65536)
print('reconstruction shape', output['reconstruction'].shape) # (1, 1024)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clipscope-0.1.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for clipscope-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c22edee6a3abcc795f9a9ee47833f1b7f74f4cdc7d1c9e02078bca6e38526953 |
|
MD5 | a61fa84aa7b4b4700b42ea052116ba9d |
|
BLAKE2b-256 | 0fc1141e00aa84555b089ce5212d5dbf639f6965ab3fc0e7adbba6f296143587 |