gberton commited on
Commit
44ff952
·
verified ·
1 Parent(s): 6b864bd

Fix broken image URL and add missing .cpu() in code snippets

Browse files
Files changed (1) hide show
  1. README.md +2 -2
README.md CHANGED
@@ -50,7 +50,7 @@ transform = transforms.Compose([
50
  transforms.ToTensor(),
51
  ])
52
 
53
- url = "https://huggingface.co/spaces/google/tipsv2-gpu-explorer/resolve/main/examples/zeroseg/pascal_context_00049_image.png"
54
  image = Image.open(requests.get(url, stream=True).raw)
55
  pixel_values = transform(image).unsqueeze(0)
56
  out = model.encode_image(pixel_values)
@@ -85,7 +85,7 @@ import numpy as np
85
  from sklearn.decomposition import PCA
86
 
87
  spatial = out.patch_tokens.reshape(1, 32, 32, 1152)
88
- feat = spatial[0].detach().numpy().reshape(-1, 1152)
89
  rgb = PCA(n_components=3, whiten=True).fit_transform(feat).reshape(32, 32, 3)
90
  rgb = 1 / (1 + np.exp(-2.0 * rgb)) # sigmoid for [0, 1] range with good contrast
91
  print(rgb.shape) # (32, 32, 3) — PCA of patch features as RGB
 
50
  transforms.ToTensor(),
51
  ])
52
 
53
+ url = "https://huggingface.co/spaces/google/TIPSv2/resolve/main/examples/zeroseg/pascal_context_00049_image.png"
54
  image = Image.open(requests.get(url, stream=True).raw)
55
  pixel_values = transform(image).unsqueeze(0)
56
  out = model.encode_image(pixel_values)
 
85
  from sklearn.decomposition import PCA
86
 
87
  spatial = out.patch_tokens.reshape(1, 32, 32, 1152)
88
+ feat = spatial[0].detach().cpu().numpy().reshape(-1, 1152)
89
  rgb = PCA(n_components=3, whiten=True).fit_transform(feat).reshape(32, 32, 3)
90
  rgb = 1 / (1 + np.exp(-2.0 * rgb)) # sigmoid for [0, 1] range with good contrast
91
  print(rgb.shape) # (32, 32, 3) — PCA of patch features as RGB