-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c41c0b
commit 766b0e6
Showing
9 changed files
with
72 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
# hold the image creation for the form | ||
class ImageMaker | ||
include ActiveModel::Model | ||
|
||
attr_accessor :prompt, :negative_prompt, :sd_model, :batch_size, :steps, :cfg_scale | ||
attr_accessor :vae, :sampler_name, :seed, :width, :height, :random_seed, :aspect_ratio | ||
attr_accessor :prompt, :negative_prompt, :sd_model, :steps, :seed, :random_seed | ||
attr_accessor :width, :height, :sampler_name, :style_template, :aspect_ratio | ||
|
||
def initialize(attributes = {}) | ||
# Default values | ||
@prompt = attributes[:prompt] || '' | ||
@negative_prompt = attributes[:negative_prompt] || '' | ||
@sd_model = attributes[:sd_model] || 'BigGAN-512' | ||
@batch_size = attributes[:batch_size] || 1 | ||
@steps = attributes[:steps] || 20 | ||
@cfg_scale = attributes[:cfg_scale] || 7.5 | ||
@vae = attributes[:vae] || 'default_vae' | ||
@sampler_name = attributes[:sampler_name] || 'Euler ' | ||
@seed = attributes[:seed] || -1 | ||
@width = attributes[:width] || 512 | ||
@height = attributes[:height] || 512 | ||
@random_seed = attributes[:random_seed] || 1 | ||
@aspect_ratio = attributes[:aspect_ratio] || '1:1' | ||
|
||
super(attributes) | ||
def initialize(params = {}) | ||
@prompt = params[:prompt] || "" | ||
@negative_prompt = params[:negative_prompt] || "" | ||
@sd_model = params[:sd_model] || "dall-e" | ||
@steps = params[:steps] || 32 | ||
@seed = params[:seed] || -1 | ||
@random_seed = params[:random_seed] || true | ||
@width = params[:width] || 512 | ||
@height = params[:height] || 512 | ||
@sampler_name = params[:sampler_name] || "Euler" | ||
@style_template = params[:style_template] || "default" | ||
@aspect_ratio = params[:aspect_ratio] || "1:1" #square | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<turbo-frame class="image-maker" action="update"> | ||
<turbo-frame class="image_maker" action="update"> | ||
We will make your image in a moment. Please wait... | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,85 @@ | ||
<%= form_with(model: ImageMaker.new, url: txt2_imgs_path, method: :post) do |form|%> | ||
<%= form_with model: ImageMaker.new, url: txt2_imgs_path, method: :post do |form| %> | ||
<div class='row mb-2'> | ||
<div class='col-2'> | ||
<strong> | ||
<%= form.label :style_template, "Style", class: "form-label" %> | ||
</strong> | ||
</div> | ||
<div class='col'> | ||
<%= form.select :style_template, @styles.map { |s| [s[:name].titleize, s[:name]] }.sort, { include_blank: true }, {class: "form-select w-100"} %> | ||
<%= form.select :style_template, @styles.map { |s| [s[:name].titleize, s[:name]] }.sort, { include_blank: true}, class: "form-select" %> | ||
</div> | ||
</div> | ||
|
||
<div class='row mb-2'> | ||
<div class='col-2'> | ||
<strong> | ||
<%= form.label :sd_model, "Model", class: "form-label" %> | ||
</strong> | ||
</div> | ||
<div class='col'> | ||
<%= form.select :sd_model, @models.sort, {}, {class: "form-select w-100"} %> | ||
<%= form.select :sd_model, @models.sort, {}, { class: "form-select" } %> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= form.text_area :prompt, placeholder: "Prompt", size: "70x5", class: "form-control" %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= form.text_area :negative_prompt, placeholder: "Negative Prompt (optional)", size: "70x5", class: "form-control" %> | ||
</div> | ||
|
||
<div class='row mb-2'> | ||
<div class='col'> | ||
<div class="btn-group w-100 d-flex" role="group" aria-label="Choose aspect ratio"> | ||
<%= form.radio_button :aspect_ratio, "3:2", class: 'btn-check' %> | ||
<%= form.label :aspect_ratio_32, class: "btn btn-outline-default" do %> | ||
<i class='fas fa-regular fa-rectangle-wide'></i> 3:2 | ||
<% end %> | ||
<%= form.radio_button :aspect_ratio, "1:1", class: 'btn-check', checked: true %> | ||
<%= form.label :aspect_ratio_11, class: "btn btn-outline-default" do %> | ||
<i class='fas fa-regular fa-square'></i> 1:1 | ||
<% end %> | ||
<%= form.radio_button :aspect_ratio, "2:3", class: 'btn-check' %> | ||
<%= form.label :aspect_ratio_23, class: "btn btn-outline-default" do %> | ||
<i class='fas fa-regular fa-rectangle-vertical'></i> 2:3 | ||
<% end %> | ||
</div> | ||
<div class="mb-2"> | ||
<div class="btn-group w-100 d-flex" role="group" aria-label="choose the aspect ratio"> | ||
<%= form.radio_button :aspect_ratio, "3:2", class: "btn-check" %> | ||
<%= form.label :aspect_ratio_32, class: "btn btn-outline-default" do %> | ||
<i class="fa-thin fa-rectangle-wide"></i> 3:2 | ||
<% end %> | ||
<%= form.radio_button :aspect_ratio, "1:1", class: "btn-check" %> | ||
<%= form.label :aspect_ratio_11, class: "btn btn-outline-default" do %> | ||
<i class="fa-thin fa-square"></i> 1:1 | ||
<% end %> | ||
<%= form.radio_button :aspect_ratio, "2:3", class: "btn-check" %> | ||
<%= form.label :aspect_ratio_23, class: "btn btn-outline-default" do %> | ||
<i class="fa-thin fa-rectangle-vertical"></i> 2:3 | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-2 text-center"> | ||
<%= form.submit "Generate", class: "btn btn-primary" %> | ||
<%= form.submit "Generate", class: "btn btn-primary"%> | ||
</div> | ||
|
||
<div class="container" data-controller="random-seed toggle"> | ||
<div class="row mb-2"> | ||
<div class="col-3 pt-1"> | ||
<strong> | ||
<%= form.label :seed, "Seed", class: "form-label" %> | ||
</strong> | ||
</div> | ||
<div class="col-9"> | ||
<%= form.number_field :seed, in: -1..9999999999, class: "form-control", data: { random_seed_target: "inputField", toggle_target: "inputField" } %> | ||
</div> | ||
<div class="row mb-2" data-controller="random-seed toggle"> | ||
<div class="col-2 pt-1"> | ||
<strong><%= form.label :seed, "Seed", class: "form-label" %></strong> | ||
</div> | ||
<div class="row mb-2"> | ||
<div class="col-2"> | ||
<button type="button" class="btn btn-sm pt-2" data-action="click->random-seed#populate" data-random-seed-target="button"> | ||
<i class="fas fa-sync-alt"></i> | ||
</button> | ||
</div> | ||
<div class="col-10 pt-2"> | ||
<%= form.check_box :random_seed, class: "form-check-input", data: { toggle_target: "toggle", action: "change->toggle#toggle" } %> | ||
<%= form.label :random_seed, "Random Number", class: "form-check-label fs-6" %> | ||
</div> | ||
<div class="col-6"> | ||
<%= form.number_field :seed, in: -1..9999999999, class: "form-control", data: { random_seed_target: "inputField", toggle_target: "inputField" } %> | ||
</div> | ||
<div class="col-1"> | ||
<button type="button" class="btn btn-sm" data-action="click->random-seed#populate"><i class="fa-thin fa-rotate"></i></button> | ||
</div> | ||
<div class="col-3 pt-1"> | ||
<%= form.check_box :random_seed, class: "form-check-input", data: { toggle_target: "toggle", action: "change->toggle#toggle"} %> | ||
<%= form.label :random_seed, class: "form-check-label" do %> | ||
<small>Rnd</small> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-2 row"> | ||
<div class="col-1 pt-1"> | ||
<strong> | ||
Q | ||
</strong> | ||
<strong>Q</strong> | ||
</div> | ||
<div class="col"> | ||
<div class="btn-group w-100 d-flex" role="group" aria-label="Set image quality"> | ||
<%= form.radio_button :steps, "14", class: 'btn-check' %> | ||
<div class="btn-group w-100 d-flex" role="group" aria-label="set image quality"> | ||
<%= form.radio_button :steps, "14", class: "btn-check" %> | ||
<%= form.label :steps_14, class: "btn btn-outline-default" do %> | ||
Fast | ||
<% end %> | ||
<%= form.radio_button :steps, "32", class: 'btn-check', checked: true %> | ||
<%= form.radio_button :steps, "32", class: "btn-check" %> | ||
<%= form.label :steps_32, class: "btn btn-outline-default" do %> | ||
Medium | ||
<% end %> | ||
<%= form.radio_button :steps, "50", class: 'btn-check' %> | ||
<%= form.radio_button :steps, "50", class: "btn-check" %> | ||
<%= form.label :steps_50, class: "btn btn-outline-default" do %> | ||
High | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters