Spaces:
Build error
Build error
aswin-raghavan commited on
Commit ·
eb801a5
1
Parent(s): 8975e3e
log train set stats; log quant error mean; increase val bits and dims;
Browse files
app.py
CHANGED
|
@@ -15,8 +15,8 @@ from numpy.random import RandomState, SeedSequence
|
|
| 15 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
| 16 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
| 17 |
|
| 18 |
-
HYPERDIMS =
|
| 19 |
-
VALUE_BITS =
|
| 20 |
POS_BITS = 9 # CLIP features are 512 dims
|
| 21 |
val_bins = np.linspace(start=-1., stop=1., num=2**VALUE_BITS)
|
| 22 |
print(val_bins.shape, val_bins.min(), val_bins.max(), 'val bins')
|
|
@@ -89,7 +89,7 @@ def quantize_embeds(embeds):
|
|
| 89 |
quantized_embeds = np.reshape(quantized_embeds_flat, embeds.shape)
|
| 90 |
closest_bin = np.reshape(closest_bin, embeds.shape)
|
| 91 |
print(closest_bin.shape, 'values are in bins', closest_bin.min(), 'to', closest_bin.max())
|
| 92 |
-
print('abs quant error', np.abs(embeds - quantized_embeds).
|
| 93 |
return quantized_embeds, closest_bin
|
| 94 |
|
| 95 |
def update_exemplars(df, rng, exemplars, lut):
|
|
@@ -106,6 +106,7 @@ def update_exemplars(df, rng, exemplars, lut):
|
|
| 106 |
embeds_train = np.concatenate([embeds[labels_zero_train_idx], embeds[labels_one_train_idx]], axis=0)
|
| 107 |
labels_train = np.concatenate([labels[labels_zero_train_idx], labels[labels_one_train_idx]], axis=0)
|
| 108 |
print('Training set ', embeds_train.shape, labels_train.shape)
|
|
|
|
| 109 |
labels_zero_test_idx = np.setdiff1d(labels_zero_idx, labels_zero_train_idx)
|
| 110 |
labels_one_test_idx = np.setdiff1d(labels_one_idx, labels_one_train_idx)
|
| 111 |
embeds_test = np.concatenate([embeds[labels_zero_test_idx], embeds[labels_one_test_idx]], axis=0)
|
|
|
|
| 15 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
| 16 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
| 17 |
|
| 18 |
+
HYPERDIMS = 4096
|
| 19 |
+
VALUE_BITS = 10
|
| 20 |
POS_BITS = 9 # CLIP features are 512 dims
|
| 21 |
val_bins = np.linspace(start=-1., stop=1., num=2**VALUE_BITS)
|
| 22 |
print(val_bins.shape, val_bins.min(), val_bins.max(), 'val bins')
|
|
|
|
| 89 |
quantized_embeds = np.reshape(quantized_embeds_flat, embeds.shape)
|
| 90 |
closest_bin = np.reshape(closest_bin, embeds.shape)
|
| 91 |
print(closest_bin.shape, 'values are in bins', closest_bin.min(), 'to', closest_bin.max())
|
| 92 |
+
print('abs quant error avg', np.abs(embeds - quantized_embeds).mean())
|
| 93 |
return quantized_embeds, closest_bin
|
| 94 |
|
| 95 |
def update_exemplars(df, rng, exemplars, lut):
|
|
|
|
| 106 |
embeds_train = np.concatenate([embeds[labels_zero_train_idx], embeds[labels_one_train_idx]], axis=0)
|
| 107 |
labels_train = np.concatenate([labels[labels_zero_train_idx], labels[labels_one_train_idx]], axis=0)
|
| 108 |
print('Training set ', embeds_train.shape, labels_train.shape)
|
| 109 |
+
print(np.sum(labels_train == 0), " zeros and ", np.sum(labels_train == 1).sum(), " ones")
|
| 110 |
labels_zero_test_idx = np.setdiff1d(labels_zero_idx, labels_zero_train_idx)
|
| 111 |
labels_one_test_idx = np.setdiff1d(labels_one_idx, labels_one_train_idx)
|
| 112 |
embeds_test = np.concatenate([embeds[labels_zero_test_idx], embeds[labels_one_test_idx]], axis=0)
|