Upload fusion_t2i_CLIP_interrogator.ipynb
Browse files
Google Colab Jupyter Notebooks/fusion_t2i_CLIP_interrogator.ipynb
CHANGED
@@ -3122,9 +3122,21 @@
|
|
3122 |
"references = torch.load('reference_text_and_image_encodings.pt' , weights_only=False)\n",
|
3123 |
"reference = torch.add(reference, prompt_strength * C * references[index][0].dequantize())\n",
|
3124 |
"reference = torch.add(reference, prompt_strength * (1-C) * references[index][1].dequantize())\n",
|
3125 |
-
"references = ''\n",
|
3126 |
"# @markdown -----------\n",
|
3127 |
-
"# @markdown πβ Enhance similarity to prompt(s)\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3128 |
"POS = '' # @param {type:'string' ,placeholder:'item1 , item2 , ...'}\n",
|
3129 |
"log_strength = 1.06 # @param {type:\"slider\", min:-5, max:5, step:0.01}\n",
|
3130 |
"pos_strength = math.pow(10 ,log_strength-1)\n",
|
|
|
3122 |
"references = torch.load('reference_text_and_image_encodings.pt' , weights_only=False)\n",
|
3123 |
"reference = torch.add(reference, prompt_strength * C * references[index][0].dequantize())\n",
|
3124 |
"reference = torch.add(reference, prompt_strength * (1-C) * references[index][1].dequantize())\n",
|
3125 |
+
"references = '' # Clear up memory\n",
|
3126 |
"# @markdown -----------\n",
|
3127 |
+
"# @markdown πβ 1st Enhance similarity to prompt(s)\n",
|
3128 |
+
"POS = '' # @param {type:'string' ,placeholder:'item1 , item2 , ...'}\n",
|
3129 |
+
"log_strength = 1.06 # @param {type:\"slider\", min:-5, max:5, step:0.01}\n",
|
3130 |
+
"pos_strength = math.pow(10 ,log_strength-1)\n",
|
3131 |
+
"for _POS in POS.split(','):\n",
|
3132 |
+
" inputs = tokenizer(text = _POS.strip(), truncation = True , padding=True, return_tensors=\"pt\")\n",
|
3133 |
+
" text_features_POS = model.get_text_features(**inputs)\n",
|
3134 |
+
" text_features_POS = text_features_POS/text_features_POS.norm(p=2, dim=-1, keepdim=True)\n",
|
3135 |
+
" reference = torch.add(reference, pos_strength * text_features_POS)\n",
|
3136 |
+
"# @markdown -----------\n",
|
3137 |
+
"\n",
|
3138 |
+
"# @markdown -----------\n",
|
3139 |
+
"# @markdown πβ 2nd Enhance similarity to prompt(s)\n",
|
3140 |
"POS = '' # @param {type:'string' ,placeholder:'item1 , item2 , ...'}\n",
|
3141 |
"log_strength = 1.06 # @param {type:\"slider\", min:-5, max:5, step:0.01}\n",
|
3142 |
"pos_strength = math.pow(10 ,log_strength-1)\n",
|