Skip to content

Commit

Permalink
feat(gui): add strength to img2img controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 8, 2023
1 parent f2e2b20 commit 2328c5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions gui/src/api/client.ts
Expand Up @@ -26,6 +26,7 @@ export interface BaseImgParams {

export interface Img2ImgParams extends BaseImgParams {
source: File;
strength: number;
}

export type Img2ImgResponse = Required<Omit<Img2ImgParams, 'file'>>;
Expand Down
13 changes: 13 additions & 0 deletions gui/src/components/Img2Img.tsx
Expand Up @@ -9,6 +9,7 @@ import { SCHEDULER_LABELS } from '../strings.js';
import { ImageCard } from './ImageCard.js';
import { ImageControl } from './ImageControl.js';
import { MutationHistory } from './MutationHistory.js';
import { NumericField } from './NumericField.js';
import { QueryList } from './QueryList.js';

const { useState } = React;
Expand All @@ -31,6 +32,7 @@ export function Img2Img(props: Img2ImgProps) {
model,
platform,
scheduler,
strength,
source: mustExist(source), // TODO: show an error if this doesn't exist
});
}
Expand All @@ -50,6 +52,7 @@ export function Img2Img(props: Img2ImgProps) {
});

const [source, setSource] = useState<File>();
const [strength, setStrength] = useState(0.5);
const [params, setParams] = useState<BaseImgParams>({
cfg: 6,
seed: -1,
Expand All @@ -76,6 +79,16 @@ export function Img2Img(props: Img2ImgProps) {
<ImageControl params={params} onChange={(newParams) => {
setParams(newParams);
}} />
<NumericField
label='Width'
min={0}
max={1}
step='any'
value={strength}
onChange={(value) => {
setStrength(value);
}}
/>
<Button onClick={() => upload.mutate()}>Generate</Button>
<MutationHistory result={upload} limit={4} element={ImageCard}
isEqual={(a, b) => a.output === b.output}
Expand Down
2 changes: 1 addition & 1 deletion gui/src/components/NumericField.tsx
Expand Up @@ -6,7 +6,7 @@ export interface ImageControlProps {
label: string;
min: number;
max: number;
step: number;
step: number | 'any';
value: number;

onChange?: (value: number) => void;
Expand Down

0 comments on commit 2328c5f

Please sign in to comment.