get samplers from backend

This commit is contained in:
Qing
2024-01-02 14:34:36 +08:00
parent a2fd5bb3ea
commit f38be37f8c
14 changed files with 141 additions and 101 deletions

View File

@@ -11,7 +11,7 @@ import {
SelectValue,
} from "../ui/select"
import { Textarea } from "../ui/textarea"
import { ExtenderDirection, PowerPaintTask, SDSampler } from "@/lib/types"
import { ExtenderDirection, PowerPaintTask } from "@/lib/types"
import { Separator } from "../ui/separator"
import { Button, ImageUploadButton } from "../ui/button"
import { Slider } from "../ui/slider"
@@ -42,6 +42,7 @@ const ExtenderButton = ({
const DiffusionOptions = () => {
const [
samplers,
settings,
paintByExampleFile,
isProcessing,
@@ -51,6 +52,7 @@ const DiffusionOptions = () => {
updateExtenderByBuiltIn,
updateExtenderDirection,
] = useStore((state) => [
state.serverConfig.samplers,
state.settings,
state.paintByExampleFile,
state.getIsProcessing(),
@@ -652,16 +654,16 @@ const DiffusionOptions = () => {
<Select
defaultValue={settings.sdSampler}
value={settings.sdSampler}
onValueChange={(value: SDSampler) => {
onValueChange={(value) => {
updateSettings({ sdSampler: value })
}}
>
<SelectTrigger className="w-[120px]">
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select sampler" />
</SelectTrigger>
<SelectContent align="end">
<SelectGroup>
{Object.values(SDSampler).map((sampler) => (
{samplers.map((sampler) => (
<SelectItem key={sampler} value={sampler}>
{sampler}
</SelectItem>

View File

@@ -194,3 +194,8 @@ export async function getGenInfo(file: File): Promise<GenInfo> {
const res = await api.post(`/gen-info`, fd)
return res.data
}
export async function getSamplers(): Promise<string[]> {
const res = await api.post("/samplers")
return res.data
}

View File

@@ -14,7 +14,6 @@ import {
PluginParams,
Point,
PowerPaintTask,
SDSampler,
ServerConfig,
Size,
SortBy,
@@ -85,7 +84,7 @@ export type Settings = {
sdStrength: number
sdSteps: number
sdGuidanceScale: number
sdSampler: SDSampler
sdSampler: string
sdMatchHistograms: boolean
sdScale: number
@@ -274,6 +273,7 @@ const defaultValues: AppState = {
controlnetMethod: "lllyasviel/control_v11p_sd15_canny",
disableModelSwitch: false,
isDesktop: false,
samplers: ["DPM++ 2M"],
},
settings: {
model: {
@@ -310,7 +310,7 @@ const defaultValues: AppState = {
sdStrength: 1.0,
sdSteps: 50,
sdGuidanceScale: 7.5,
sdSampler: SDSampler.uni_pc,
sdSampler: "DPM++ 2M",
sdMatchHistograms: false,
sdScale: 100,
p2pImageGuidanceScale: 1.5,

View File

@@ -14,6 +14,7 @@ export interface ServerConfig {
controlnetMethod: string
disableModelSwitch: boolean
isDesktop: boolean
samplers: string[]
}
export interface GenInfo {
@@ -82,17 +83,6 @@ export interface Rect {
height: number
}
export enum SDSampler {
ddim = "ddim",
pndm = "pndm",
klms = "k_lms",
kEuler = "k_euler",
kEulerA = "k_euler_a",
dpmPlusPlus = "dpm++",
uni_pc = "uni_pc",
// lcm = "lcm",
}
export interface FreeuConfig {
s1: number
s2: number