Skip to content

Commit

Permalink
Merge branch 'master' into feature/design
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed Mar 27, 2024
2 parents eaebcad + 1916c4b commit 4601403
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="flex">
<input type="range" [min]="min()" [max]="max()" [step]="step()" [value]="value()" (input)="value.set(Number(input1.value))" class="form-control" [id]="inputId()" #input1 />
<input type="number" [min]="min()" [max]="max()" [step]="step()" class="form-control" [value]="value()" (input)="value.set(Number(input2.value))" #input2 />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
div > input {
&:first-child {
flex: 85% 1 1;
margin-right: 1vw;
}
&:last-child {
flex: 15% 1 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import {Component, effect, input, signal, WritableSignal} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR, ReactiveFormsModule} from "@angular/forms";
import {OnChange, OnTouched} from "../../types/value-accessor";

@Component({
selector: 'app-slider-with-value',
standalone: true,
imports: [
ReactiveFormsModule
],
templateUrl: './slider-with-value.component.html',
styleUrl: './slider-with-value.component.scss',
providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: SliderWithValueComponent,
},
]
})
export class SliderWithValueComponent implements ControlValueAccessor {
protected readonly Number = Number;

private onChange: WritableSignal<OnChange<number> | null> = signal(null);
private onTouched: WritableSignal<OnTouched | null> = signal(null);

public inputId = input<string>();
public required = input(false);
public min = input<number | null>(null);
public max = input<number | null>(null);
public step = input<number | null>(null);

public disabled = signal(false);

public value = signal(0);

constructor() {
effect(() => {
if (this.onChange() === null) {
return;
}
(this.onChange()!)(this.value());
if (this.onTouched() !== null) {
(this.onTouched()!)();
}
});
}

public registerOnChange(fn: OnChange<number>): void {
this.onChange.set(fn);
}

public registerOnTouched(fn: OnTouched): void {
this.onTouched.set(fn);
}

public setDisabledState(isDisabled: boolean): void {
this.disabled.set(isDisabled);
}

public writeValue(obj: number): void {
this.value.set(obj);
}
}
16 changes: 9 additions & 7 deletions src/app/pages/generate-image/generate-image.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
</div>
@if (form.value.faceFixers?.length) {
<div class="form-group">
<label for="inputFaceFixerStrength">{{ 'app.generate.face_fixer_strength' | transloco }}
({{ form.controls.faceFixerStrength.value! | formatNumber:2 }})</label>
<input type="range" min="0" max="1" step="0.01" formControlName="faceFixerStrength" class="form-control" id="inputFaceFixerStrength"/>
<!--suppress XmlInvalidId -->
<label for="inputFaceFixerStrength">{{ 'app.generate.face_fixer_strength' | transloco }}</label>
<app-slider-with-value [min]="0" [max]="1" [step]="0.01" formControlName="faceFixerStrength" inputId="inputFaceFixerStrength" />
</div>
}
<div class="form-group">
Expand Down Expand Up @@ -194,14 +194,16 @@
<div class="row formGroup">
<div class="col-md-6">
<div class="form-group">
<label for="inputDenoisingStrength">{{ 'app.generate.denoising_strength' | transloco }}({{ form.controls.denoisingStrength.value! | formatNumber:2 }})</label>
<input type="range" min="0.01" max="1" step="0.01" formControlName="denoisingStrength" class="form-control"id="inputDenoisingStrength"/>
<!--suppress XmlInvalidId -->
<label for="inputDenoisingStrength">{{ 'app.generate.denoising_strength' | transloco }})</label>
<app-slider-with-value [min]="0.01" [max]="1" [step]="0.01" formControlName="denoisingStrength" inputId="inputDenoisingStrength" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="inputCfgScale">{{ 'app.generate.cfg_scale' | transloco }}({{ form.controls.cfgScale.value! | formatNumber:1 }})</label>
<input type="range" min="0" max="100" step="0.5" formControlName="cfgScale" class="form-control" id="inputCfgScale"/>
<!--suppress XmlInvalidId -->
<label for="inputCfgScale">{{ 'app.generate.cfg_scale' | transloco }}</label>
<app-slider-with-value [min]="0" [max]="100" [step]="0.5" formControlName="cfgScale" inputId="inputCfgScale" />
<app-effective-value [value]="modifiedOptions()?.cfgScale" [original]="form.value.cfgScale" />
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/generate-image/generate-image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {getFaceFixers, getGenericPostProcessors, getUpscalers} from "../../helpe
import _ from 'lodash';
import {BaselineModel} from "../../types/sd-repo/baseline-model";
import {AutoGrowDirective} from "../../directives/auto-grow.directive";
import {SliderWithValueComponent} from "../../components/slider-with-value/slider-with-value.component";

interface Result {
width: number;
Expand Down Expand Up @@ -103,7 +104,8 @@ interface Result {
LoraTextRowComponent,
IsFaceFixerPipe,
IsUpscalerPipe,
AutoGrowDirective
AutoGrowDirective,
SliderWithValueComponent
],
templateUrl: './generate-image.component.html',
styleUrl: './generate-image.component.scss'
Expand Down
2 changes: 1 addition & 1 deletion src/app/types/db/generation-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DefaultGenerationOptions: GenerationOptions = {
cfgScale: 5,
denoisingStrength: 0.75,
height: 512,
width: 52,
width: 512,
steps: 25,
model: 'AlbedoBase XL (SDXL)',
karras: true,
Expand Down

0 comments on commit 4601403

Please sign in to comment.