add default field weight multipliers

This commit is contained in:
Andrew Brown 2023-02-27 18:57:10 -08:00
parent fd7a3271e5
commit c089997b38
2 changed files with 14 additions and 5 deletions

View File

@ -106,6 +106,12 @@ class BasilController < ApplicationController
end
end
field_importance_multipliers = {
'hair color': 1.4,
'hair style': 1.2,
'skin tone': 1.3
}
# Step 3. Do it all again for every other field, too
formatted_field_values = appearance_fields.map do |field|
value = attributes.detect { |a| a.attribute_field_id == field.id }.try(:value)
@ -123,8 +129,9 @@ class BasilController < ApplicationController
value = value.gsub('(', '').gsub(')', '')
# Get the importance of this field and add 1 to get back to our SD version
importance = params.dig(:field, field.id.to_s)
importance = importance.to_f if importance.present?
importance = params.dig(:field, field.id.to_s) || 1.0
importance = importance.to_f * field_importance_multipliers.fetch(field.label.downcase.to_sym, 1.0)
importance = importance.round(2)
# If the importance is exactly 1, we can omit the parentheses and save a few tokens, since the
# default attention importance is 1.

View File

@ -11,7 +11,7 @@
</div>
<ul>
<% if @gender_field %>
<% if @gender_field && @gender_value %>
<li style="margin-bottom: 1em">
<div class="grey-text text-darken-3" style="font-weight: bold; font-size: 0.8em">
Gender
@ -23,7 +23,7 @@
</li>
<% end %>
<% if @age_field %>
<% if @age_field && @gender_value %>
<li style="margin-bottom: 1em">
<div class="grey-text text-darken-3" style="font-weight: bold; font-size: 0.8em">
Age
@ -62,7 +62,9 @@
<% end %>
<div>
<%= link_to 'Customize per-field importance', "javascript:var sliders = document.getElementsByClassName('js-importance-slider'); for(var i = 0; i < sliders.length; i++) sliders.item(i).classList.remove('hide')" %>
<% if @can_request_another %>
<%= link_to 'Customize per-field importance', "javascript:var sliders = document.getElementsByClassName('js-importance-slider'); for(var i = 0; i < sliders.length; i++) sliders.item(i).classList.remove('hide')" %>
<% end %>
<div class="card-panel js-importance-slider hide" style="margin-right: 1em">
<strong>How to customize per-field importance</strong>