update
This commit is contained in:
parent
aca85543ca
commit
9df94489e1
@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@ -6,22 +7,21 @@ from pathlib import Path
|
|||||||
from typing import Optional, Dict, List
|
from typing import Optional, Dict, List
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import socketio
|
|
||||||
import asyncio
|
|
||||||
from socketio import AsyncServer
|
|
||||||
import torch
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from loguru import logger
|
import socketio
|
||||||
from PIL import Image
|
import torch
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
from PIL import Image
|
||||||
from fastapi import APIRouter, FastAPI, Request, UploadFile
|
from fastapi import APIRouter, FastAPI, Request, UploadFile
|
||||||
from fastapi.encoders import jsonable_encoder
|
from fastapi.encoders import jsonable_encoder
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import JSONResponse, FileResponse, Response
|
from fastapi.responses import JSONResponse, FileResponse, Response
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from loguru import logger
|
||||||
|
from socketio import AsyncServer
|
||||||
|
|
||||||
|
from lama_cleaner.file_manager import FileManager
|
||||||
from lama_cleaner.helper import (
|
from lama_cleaner.helper import (
|
||||||
load_img,
|
load_img,
|
||||||
decode_base64_to_image,
|
decode_base64_to_image,
|
||||||
@ -33,7 +33,7 @@ from lama_cleaner.helper import (
|
|||||||
from lama_cleaner.model.utils import torch_gc
|
from lama_cleaner.model.utils import torch_gc
|
||||||
from lama_cleaner.model_info import ModelInfo
|
from lama_cleaner.model_info import ModelInfo
|
||||||
from lama_cleaner.model_manager import ModelManager
|
from lama_cleaner.model_manager import ModelManager
|
||||||
from lama_cleaner.plugins import build_plugins, InteractiveSeg, RemoveBG, AnimeSeg
|
from lama_cleaner.plugins import build_plugins
|
||||||
from lama_cleaner.plugins.base_plugin import BasePlugin
|
from lama_cleaner.plugins.base_plugin import BasePlugin
|
||||||
from lama_cleaner.schema import (
|
from lama_cleaner.schema import (
|
||||||
GenInfoResponse,
|
GenInfoResponse,
|
||||||
@ -45,7 +45,6 @@ from lama_cleaner.schema import (
|
|||||||
SDSampler,
|
SDSampler,
|
||||||
PluginInfo,
|
PluginInfo,
|
||||||
)
|
)
|
||||||
from lama_cleaner.file_manager import FileManager
|
|
||||||
|
|
||||||
CURRENT_DIR = Path(__file__).parent.absolute().resolve()
|
CURRENT_DIR = Path(__file__).parent.absolute().resolve()
|
||||||
WEB_APP_DIR = CURRENT_DIR / "web_app"
|
WEB_APP_DIR = CURRENT_DIR / "web_app"
|
||||||
@ -118,7 +117,7 @@ def api_middleware(app: FastAPI):
|
|||||||
global_sio: AsyncServer = None
|
global_sio: AsyncServer = None
|
||||||
|
|
||||||
|
|
||||||
def diffuser_callback(pipe, step: int, timestep: int, callback_kwargs: Dict):
|
def diffuser_callback(pipe, step: int, timestep: int, callback_kwargs: Dict = {}):
|
||||||
# self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict
|
# self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict
|
||||||
# logger.info(f"diffusion callback: step={step}, timestep={timestep}")
|
# logger.info(f"diffusion callback: step={step}, timestep={timestep}")
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ class StableDiffusionInpaintPipeline(
|
|||||||
):
|
):
|
||||||
progress_bar.update()
|
progress_bar.update()
|
||||||
if callback is not None and i % callback_steps == 0:
|
if callback is not None and i % callback_steps == 0:
|
||||||
callback(i, t, latents)
|
callback(self, i, t, {})
|
||||||
|
|
||||||
if not output_type == "latent":
|
if not output_type == "latent":
|
||||||
condition_kwargs = {}
|
condition_kwargs = {}
|
||||||
|
@ -66,6 +66,7 @@ const Cropper = (props: Props) => {
|
|||||||
imageWidth,
|
imageWidth,
|
||||||
imageHeight,
|
imageHeight,
|
||||||
isInpainting,
|
isInpainting,
|
||||||
|
isSD,
|
||||||
{ x, y, width, height },
|
{ x, y, width, height },
|
||||||
setX,
|
setX,
|
||||||
setY,
|
setY,
|
||||||
@ -77,6 +78,7 @@ const Cropper = (props: Props) => {
|
|||||||
state.imageWidth,
|
state.imageWidth,
|
||||||
state.imageHeight,
|
state.imageHeight,
|
||||||
state.isInpainting,
|
state.isInpainting,
|
||||||
|
state.isSD(),
|
||||||
state.cropperState,
|
state.cropperState,
|
||||||
state.setCropperX,
|
state.setCropperX,
|
||||||
state.setCropperY,
|
state.setCropperY,
|
||||||
@ -377,7 +379,7 @@ const Cropper = (props: Props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show === false) {
|
if (show === false || !isSD) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import * as React from "react"
|
|||||||
import io from "socket.io-client"
|
import io from "socket.io-client"
|
||||||
import { Progress } from "./ui/progress"
|
import { Progress } from "./ui/progress"
|
||||||
import { useStore } from "@/lib/states"
|
import { useStore } from "@/lib/states"
|
||||||
import { MODEL_TYPE_INPAINT } from "@/lib/const"
|
|
||||||
|
|
||||||
export const API_ENDPOINT = import.meta.env.VITE_BACKEND
|
export const API_ENDPOINT = import.meta.env.VITE_BACKEND
|
||||||
? import.meta.env.VITE_BACKEND
|
? import.meta.env.VITE_BACKEND
|
||||||
@ -10,16 +9,16 @@ export const API_ENDPOINT = import.meta.env.VITE_BACKEND
|
|||||||
const socket = io(API_ENDPOINT)
|
const socket = io(API_ENDPOINT)
|
||||||
|
|
||||||
const DiffusionProgress = () => {
|
const DiffusionProgress = () => {
|
||||||
const [settings, isInpainting] = useStore((state) => [
|
const [settings, isInpainting, isSD] = useStore((state) => [
|
||||||
state.settings,
|
state.settings,
|
||||||
state.isInpainting,
|
state.isInpainting,
|
||||||
|
state.isSD(),
|
||||||
])
|
])
|
||||||
|
|
||||||
const [isConnected, setIsConnected] = React.useState(false)
|
const [isConnected, setIsConnected] = React.useState(false)
|
||||||
const [step, setStep] = React.useState(0)
|
const [step, setStep] = React.useState(0)
|
||||||
|
|
||||||
const progress = Math.min(Math.round((step / settings.sdSteps) * 100), 100)
|
const progress = Math.min(Math.round((step / settings.sdSteps) * 100), 100)
|
||||||
const isSD = settings.model.model_type !== MODEL_TYPE_INPAINT
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!isSD) {
|
if (!isSD) {
|
||||||
|
@ -604,7 +604,7 @@ export default function Editor(props: EditorProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
useHotKey(
|
useHotKey(
|
||||||
"ctrl+c, cmd+c",
|
"ctrl+c,meta+c",
|
||||||
async () => {
|
async () => {
|
||||||
const hasPermission = await askWritePermission()
|
const hasPermission = await askWritePermission()
|
||||||
if (hasPermission && renders.length > 0) {
|
if (hasPermission && renders.length > 0) {
|
||||||
|
@ -48,6 +48,7 @@ const Extender = (props: Props) => {
|
|||||||
isInpainting,
|
isInpainting,
|
||||||
imageHeight,
|
imageHeight,
|
||||||
imageWdith,
|
imageWdith,
|
||||||
|
isSD,
|
||||||
{ x, y, width, height },
|
{ x, y, width, height },
|
||||||
setX,
|
setX,
|
||||||
setY,
|
setY,
|
||||||
@ -60,6 +61,7 @@ const Extender = (props: Props) => {
|
|||||||
state.isInpainting,
|
state.isInpainting,
|
||||||
state.imageHeight,
|
state.imageHeight,
|
||||||
state.imageWidth,
|
state.imageWidth,
|
||||||
|
state.isSD(),
|
||||||
state.extenderState,
|
state.extenderState,
|
||||||
state.setExtenderX,
|
state.setExtenderX,
|
||||||
state.setExtenderY,
|
state.setExtenderY,
|
||||||
@ -391,7 +393,7 @@ const Extender = (props: Props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show === false) {
|
if (show === false || !isSD) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,8 @@ type AppAction = {
|
|||||||
getBrushSize: () => number
|
getBrushSize: () => number
|
||||||
setImageSize: (width: number, height: number) => void
|
setImageSize: (width: number, height: number) => void
|
||||||
|
|
||||||
|
isSD: () => boolean
|
||||||
|
|
||||||
setCropperX: (newValue: number) => void
|
setCropperX: (newValue: number) => void
|
||||||
setCropperY: (newValue: number) => void
|
setCropperY: (newValue: number) => void
|
||||||
setCropperWidth: (newValue: number) => void
|
setCropperWidth: (newValue: number) => void
|
||||||
@ -170,6 +172,7 @@ type AppAction = {
|
|||||||
setExtenderY: (newValue: number) => void
|
setExtenderY: (newValue: number) => void
|
||||||
setExtenderWidth: (newValue: number) => void
|
setExtenderWidth: (newValue: number) => void
|
||||||
setExtenderHeight: (newValue: number) => void
|
setExtenderHeight: (newValue: number) => void
|
||||||
|
|
||||||
setIsCropperExtenderResizing: (newValue: boolean) => void
|
setIsCropperExtenderResizing: (newValue: boolean) => void
|
||||||
updateExtenderDirection: (newValue: ExtenderDirection) => void
|
updateExtenderDirection: (newValue: ExtenderDirection) => void
|
||||||
resetExtender: (width: number, height: number) => void
|
resetExtender: (width: number, height: number) => void
|
||||||
@ -618,6 +621,10 @@ export const useStore = createWithEqualityFn<AppState & AppAction>()(
|
|||||||
return get().isInpainting || get().isPluginRunning
|
return get().isInpainting || get().isPluginRunning
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isSD: (): boolean => {
|
||||||
|
return get().settings.model.model_type !== MODEL_TYPE_INPAINT
|
||||||
|
},
|
||||||
|
|
||||||
// undo/redo
|
// undo/redo
|
||||||
|
|
||||||
undoDisabled: (): boolean => {
|
undoDisabled: (): boolean => {
|
||||||
|
Loading…
Reference in New Issue
Block a user