Skip to content

Commit

Permalink
feat(gui): add tile order as an inpaint parameter (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Feb 11, 2023
1 parent 3c7a3e5 commit 51651ab
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"default": "histogram",
"keys": []
},
"order": {
"default": "spiral",
"keys": []
},
"outscale": {
"default": 1,
"min": 1,
Expand Down
2 changes: 2 additions & 0 deletions gui/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface InpaintParams extends BaseImgParams {
noise: string;
strength: number;
fillColor: string;
tileOrder: string;
}

/**
Expand Down Expand Up @@ -421,6 +422,7 @@ export function makeClient(root: string, f = fetch): ApiClient {
url.searchParams.append('noise', params.noise);
url.searchParams.append('strength', params.strength.toFixed(FIXED_FLOAT));
url.searchParams.append('fillColor', params.fillColor);
url.searchParams.append('tileOrder', params.tileOrder);

if (doesExist(upscale)) {
appendUpscaleToURL(url, upscale);
Expand Down
1 change: 1 addition & 0 deletions gui/src/components/input/QueryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function QueryList<T>(props: QueryListProps<T>) {
}
}

// update state when previous selection was invalid: https://github.com/ssube/onnx-web/issues/120
useEffect(() => {
if (result.status === 'success' && doesExist(result.data) && doesExist(props.onChange)) {
const data = filterQuery(query);
Expand Down
16 changes: 15 additions & 1 deletion gui/src/components/tab/Inpaint.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { doesExist, mustExist } from '@apextoaster/js-utils';
import { Box, Button, FormControlLabel, Stack } from '@mui/material';
import { Box, Button, FormControl, FormControlLabel, InputLabel, Select, Stack } from '@mui/material';
import * as React from 'react';
import { useContext } from 'react';
import { useMutation, useQuery, useQueryClient } from 'react-query';
Expand Down Expand Up @@ -58,6 +58,7 @@ export function Inpaint() {
const mask = useStore(state, (s) => s.inpaint.mask);
const source = useStore(state, (s) => s.inpaint.source);
const strength = useStore(state, (s) => s.inpaint.strength);
const tileOrder = useStore(state, (s) => s.inpaint.tileOrder);

// eslint-disable-next-line @typescript-eslint/unbound-method
const setInpaint = useStore(state, (s) => s.setInpaint);
Expand Down Expand Up @@ -149,6 +150,19 @@ export function Inpaint() {
});
}}
/>
<FormControl>
<InputLabel id={'outpaint-tiling'}>Tile Order</InputLabel>
<Select
labelId={'outpaint-tiling'}
label={'Tile Order'}
value={tileOrder}
onChange={(e) => {
setInpaint({
tileOrder: e.target.value,
});
}}
></Select>
</FormControl>
<Stack direction='row' spacing={2}>
<FormControlLabel
label='Fill Color'
Expand Down
2 changes: 2 additions & 0 deletions gui/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export function createStateSlices(server: ServerParams) {
noise: server.noise.default,
source: null,
strength: server.strength.default,
tileOrder: server.tileOrder.default,
},
setInpaint(params) {
set((prev) => ({
Expand All @@ -277,6 +278,7 @@ export function createStateSlices(server: ServerParams) {
noise: server.noise.default,
source: null,
strength: server.strength.default,
tileOrder: server.tileOrder.default,
},
});
},
Expand Down

0 comments on commit 51651ab

Please sign in to comment.