WolodjaZ commited on
Commit
47dc123
·
verified ·
1 Parent(s): 6e27a97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -77,6 +77,7 @@ def predict(input_img, top_k, concept, neg_concept, max_strength):
77
  reconstructed_features, _, full_latents = sae_model(image_features)
78
 
79
  fvu_score = calculate_fvu(image_features, reconstructed_features)
 
80
 
81
  # Get the top K activating SAE features for the image
82
  full_latents = full_latents.cpu().flatten()
@@ -137,7 +138,7 @@ def predict(input_img, top_k, concept, neg_concept, max_strength):
137
  modified_latents[:, concept_feature_id] = st
138
 
139
  # Decode the modified latents back into feature space
140
- modified_reconstructed = sae_model.model.decode(modified_latents)
141
 
142
  # Normalize for comparison
143
  modified_reconstructed_norm = modified_reconstructed / modified_reconstructed.norm(dim=-1, keepdim=True)
 
77
  reconstructed_features, _, full_latents = sae_model(image_features)
78
 
79
  fvu_score = calculate_fvu(image_features, reconstructed_features)
80
+ error = image_features - reconstructed_features
81
 
82
  # Get the top K activating SAE features for the image
83
  full_latents = full_latents.cpu().flatten()
 
138
  modified_latents[:, concept_feature_id] = st
139
 
140
  # Decode the modified latents back into feature space
141
+ modified_reconstructed = sae_model.decode(modified_latents) + error
142
 
143
  # Normalize for comparison
144
  modified_reconstructed_norm = modified_reconstructed / modified_reconstructed.norm(dim=-1, keepdim=True)