mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-01-13 01:38:19 +01:00
organized draw image
This commit is contained in:
parent
7c31dbb3d6
commit
0ddff9d551
@ -18,6 +18,10 @@ export default function SeedImage(_props: any) {
|
|||||||
const init_image = useImageCreate((state) =>
|
const init_image = useImageCreate((state) =>
|
||||||
state.getValueForRequestKey("init_image")
|
state.getValueForRequestKey("init_image")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isInPaintingMode = useImageCreate((state) => state.isInpainting);
|
||||||
|
|
||||||
|
|
||||||
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
const setRequestOption = useImageCreate((state) => state.setRequestOptions);
|
||||||
|
|
||||||
const _startFileSelect = () => {
|
const _startFileSelect = () => {
|
||||||
@ -38,9 +42,16 @@ export default function SeedImage(_props: any) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleInpainting = useImageCreate((state) => state.toggleInpainting);
|
||||||
|
|
||||||
const _handleClearImage = () => {
|
const _handleClearImage = () => {
|
||||||
setRequestOption("init_image", undefined);
|
setRequestOption("init_image", undefined);
|
||||||
};
|
|
||||||
|
if (isInPaintingMode) {
|
||||||
|
toggleInpainting();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ImageInputDisplay}>
|
<div className={ImageInputDisplay}>
|
||||||
@ -63,10 +74,23 @@ export default function SeedImage(_props: any) {
|
|||||||
<div className={ImageFixer}>
|
<div className={ImageFixer}>
|
||||||
{init_image && (
|
{init_image && (
|
||||||
<>
|
<>
|
||||||
<img src={init_image} width="100" height="100" />
|
<div>
|
||||||
<button className={XButton} onClick={_handleClearImage}>
|
<img src={init_image} width="100" height="100" />
|
||||||
X
|
<button className={XButton} onClick={_handleClearImage}>
|
||||||
</button>
|
X
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
onChange={(e) => {
|
||||||
|
toggleInpainting()
|
||||||
|
}}
|
||||||
|
checked={isInPaintingMode}
|
||||||
|
>
|
||||||
|
</input>
|
||||||
|
Use for Inpainting
|
||||||
|
</label>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,7 +10,7 @@ import { doMakeImage, MakeImageKey } from "../../../api";
|
|||||||
import AudioDing from "./audioDing";
|
import AudioDing from "./audioDing";
|
||||||
|
|
||||||
import GeneratedImage from "../../molecules/generatedImage";
|
import GeneratedImage from "../../molecules/generatedImage";
|
||||||
// import DrawImage from "../../molecules/drawImage";
|
import DrawImage from "../../molecules/drawImage";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
displayPanel,
|
displayPanel,
|
||||||
@ -29,6 +29,9 @@ export default function DisplayPanel() {
|
|||||||
const dingRef = useRef<HTMLAudioElement>(null);
|
const dingRef = useRef<HTMLAudioElement>(null);
|
||||||
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
|
const isSoundEnabled = useImageCreate((state) => state.isSoundEnabled());
|
||||||
|
|
||||||
|
const isInPaintingMode = useImageCreate((state) => state.isInpainting);
|
||||||
|
|
||||||
|
|
||||||
/* FETCHING */
|
/* FETCHING */
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { id, options } = useImageQueue((state) => state.firstInQueue());
|
const { id, options } = useImageQueue((state) => state.firstInQueue());
|
||||||
@ -62,6 +65,11 @@ export default function DisplayPanel() {
|
|||||||
);
|
);
|
||||||
const completedIds = useImageQueue((state) => state.completedImageIds);
|
const completedIds = useImageQueue((state) => state.completedImageIds);
|
||||||
|
|
||||||
|
|
||||||
|
const init_image = useImageCreate((state) =>
|
||||||
|
state.getValueForRequestKey("init_image")
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const testReq = {} as ImageRequest;
|
const testReq = {} as ImageRequest;
|
||||||
const completedQueries = completedIds.map((id) => {
|
const completedQueries = completedIds.map((id) => {
|
||||||
@ -98,42 +106,51 @@ export default function DisplayPanel() {
|
|||||||
return (
|
return (
|
||||||
<div className={displayPanel}>
|
<div className={displayPanel}>
|
||||||
<AudioDing ref={dingRef}></AudioDing>
|
<AudioDing ref={dingRef}></AudioDing>
|
||||||
{completedImages.length > 0 && (
|
<div className={displayContainer}>
|
||||||
<div className={displayContainer}>
|
{isInPaintingMode &&
|
||||||
<div className={CurrentDisplay}>
|
<DrawImage imageData={init_image}></DrawImage>
|
||||||
{/* TODO Put the in painting controls here */}
|
|
||||||
{/* <DrawImage imageData={completedImages[0].data}></DrawImage> */}
|
|
||||||
|
|
||||||
<GeneratedImage
|
}
|
||||||
key={completedImages[0].id}
|
|
||||||
imageData={completedImages[0].data}
|
|
||||||
metadata={completedImages[0].info}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={previousImages}>
|
{completedImages.length > 0 && (
|
||||||
{completedImages.map((image, index) => {
|
<>
|
||||||
if (void 0 !== image) {
|
<div className={CurrentDisplay}>
|
||||||
if (index == 0) {
|
|
||||||
|
|
||||||
|
|
||||||
|
<GeneratedImage
|
||||||
|
key={completedImages[0].id}
|
||||||
|
imageData={completedImages[0].data}
|
||||||
|
metadata={completedImages[0].info}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={previousImages}>
|
||||||
|
{completedImages.map((image, index) => {
|
||||||
|
if (void 0 !== image) {
|
||||||
|
if (index == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GeneratedImage
|
||||||
|
className={previousImage}
|
||||||
|
key={image.id}
|
||||||
|
imageData={image.data}
|
||||||
|
metadata={image.info}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.warn("image is undefined", image, index);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
return (
|
|
||||||
<GeneratedImage
|
|
||||||
className={previousImage}
|
|
||||||
key={image.id}
|
|
||||||
imageData={image.data}
|
|
||||||
metadata={image.info}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.warn("image is undefined", image, index);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import { devtools } from "zustand/middleware";
|
|||||||
import { useRandomSeed } from "../utils";
|
import { useRandomSeed } from "../utils";
|
||||||
|
|
||||||
export type ImageCreationUiOptions = {
|
export type ImageCreationUiOptions = {
|
||||||
// isCheckedUseUpscaling: boolean;
|
|
||||||
// isCheckUseFaceCorrection: boolean;
|
|
||||||
isUseRandomSeed: boolean;
|
isUseRandomSeed: boolean;
|
||||||
isUseAutoSave: boolean;
|
isUseAutoSave: boolean;
|
||||||
isSoundEnabled: boolean;
|
isSoundEnabled: boolean;
|
||||||
@ -19,37 +17,37 @@ export type ImageRequest = {
|
|||||||
num_inference_steps: number;
|
num_inference_steps: number;
|
||||||
guidance_scale: number;
|
guidance_scale: number;
|
||||||
width:
|
width:
|
||||||
| 128
|
| 128
|
||||||
| 192
|
| 192
|
||||||
| 256
|
| 256
|
||||||
| 320
|
| 320
|
||||||
| 384
|
| 384
|
||||||
| 448
|
| 448
|
||||||
| 512
|
| 512
|
||||||
| 576
|
| 576
|
||||||
| 640
|
| 640
|
||||||
| 704
|
| 704
|
||||||
| 768
|
| 768
|
||||||
| 832
|
| 832
|
||||||
| 896
|
| 896
|
||||||
| 960
|
| 960
|
||||||
| 1024;
|
| 1024;
|
||||||
height:
|
height:
|
||||||
| 128
|
| 128
|
||||||
| 192
|
| 192
|
||||||
| 256
|
| 256
|
||||||
| 320
|
| 320
|
||||||
| 384
|
| 384
|
||||||
| 448
|
| 448
|
||||||
| 512
|
| 512
|
||||||
| 576
|
| 576
|
||||||
| 640
|
| 640
|
||||||
| 704
|
| 704
|
||||||
| 768
|
| 768
|
||||||
| 832
|
| 832
|
||||||
| 896
|
| 896
|
||||||
| 960
|
| 960
|
||||||
| 1024;
|
| 1024;
|
||||||
// allow_nsfw: boolean;
|
// allow_nsfw: boolean;
|
||||||
turbo: boolean;
|
turbo: boolean;
|
||||||
use_cpu: boolean;
|
use_cpu: boolean;
|
||||||
@ -71,6 +69,7 @@ interface ImageCreateState {
|
|||||||
requestOptions: ImageRequest;
|
requestOptions: ImageRequest;
|
||||||
allModifiers: ModifiersOptionList;
|
allModifiers: ModifiersOptionList;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
|
isInpainting: boolean;
|
||||||
|
|
||||||
setParallelCount: (count: number) => void;
|
setParallelCount: (count: number) => void;
|
||||||
setRequestOptions: (key: keyof ImageRequest, value: any) => void;
|
setRequestOptions: (key: keyof ImageRequest, value: any) => void;
|
||||||
@ -94,6 +93,7 @@ interface ImageCreateState {
|
|||||||
isUseAutoSave: () => boolean;
|
isUseAutoSave: () => boolean;
|
||||||
toggleSoundEnabled: () => void;
|
toggleSoundEnabled: () => void;
|
||||||
isSoundEnabled: () => boolean;
|
isSoundEnabled: () => boolean;
|
||||||
|
toggleInpainting: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// devtools breaks TS
|
// devtools breaks TS
|
||||||
@ -134,6 +134,8 @@ export const useImageCreate = create<ImageCreateState>(
|
|||||||
|
|
||||||
allModifiers: [[[]]] as ModifiersOptionList,
|
allModifiers: [[[]]] as ModifiersOptionList,
|
||||||
|
|
||||||
|
isInpainting: false,
|
||||||
|
|
||||||
setParallelCount: (count: number) =>
|
setParallelCount: (count: number) =>
|
||||||
set(
|
set(
|
||||||
produce((state) => {
|
produce((state) => {
|
||||||
@ -217,7 +219,7 @@ export const useImageCreate = create<ImageCreateState>(
|
|||||||
produce((state) => {
|
produce((state) => {
|
||||||
const isSeting =
|
const isSeting =
|
||||||
typeof state.getValueForRequestKey("use_face_correction") ===
|
typeof state.getValueForRequestKey("use_face_correction") ===
|
||||||
"string"
|
"string"
|
||||||
? null
|
? null
|
||||||
: "GFPGANv1.3";
|
: "GFPGANv1.3";
|
||||||
state.requestOptions.use_face_correction = isSeting;
|
state.requestOptions.use_face_correction = isSeting;
|
||||||
@ -280,5 +282,14 @@ export const useImageCreate = create<ImageCreateState>(
|
|||||||
isSoundEnabled: () => {
|
isSoundEnabled: () => {
|
||||||
return get().uiOptions.isSoundEnabled;
|
return get().uiOptions.isSoundEnabled;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleInpainting: () => {
|
||||||
|
set(
|
||||||
|
produce((state) => {
|
||||||
|
state.isInpainting = !state.isInpainting;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user