only call keepGUIAlive when run as gui
This commit is contained in:
parent
51daa8d02e
commit
30e205a5f8
@ -9,6 +9,7 @@ import { fileState, toastState } from './store/Atoms'
|
|||||||
import { keepGUIAlive } from './utils'
|
import { keepGUIAlive } from './utils'
|
||||||
import Header from './components/Header/Header'
|
import Header from './components/Header/Header'
|
||||||
import useHotKey from './hooks/useHotkey'
|
import useHotKey from './hooks/useHotkey'
|
||||||
|
import { isDesktop } from './adapters/inpainting'
|
||||||
|
|
||||||
const SUPPORTED_FILE_TYPE = [
|
const SUPPORTED_FILE_TYPE = [
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
@ -18,9 +19,6 @@ const SUPPORTED_FILE_TYPE = [
|
|||||||
'image/tiff',
|
'image/tiff',
|
||||||
]
|
]
|
||||||
|
|
||||||
// Keeping GUI Window Open
|
|
||||||
keepGUIAlive()
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [file, setFile] = useRecoilState(fileState)
|
const [file, setFile] = useRecoilState(fileState)
|
||||||
const [theme, setTheme] = useRecoilState(themeState)
|
const [theme, setTheme] = useRecoilState(themeState)
|
||||||
@ -34,6 +32,17 @@ function App() {
|
|||||||
setFile(userInputImage)
|
setFile(userInputImage)
|
||||||
}, [userInputImage, setFile])
|
}, [userInputImage, setFile])
|
||||||
|
|
||||||
|
// Keeping GUI Window Open
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchData = async () => {
|
||||||
|
const isRunDesktop = await isDesktop().then(res => res.text())
|
||||||
|
if (isRunDesktop === 'True') {
|
||||||
|
keepGUIAlive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchData()
|
||||||
|
}, [])
|
||||||
|
|
||||||
// Dark Mode Hotkey
|
// Dark Mode Hotkey
|
||||||
useHotKey(
|
useHotKey(
|
||||||
'shift+d',
|
'shift+d',
|
||||||
|
@ -102,6 +102,12 @@ export function currentModel() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isDesktop() {
|
||||||
|
return fetch(`${API_ENDPOINT}/is_desktop`, {
|
||||||
|
method: 'GET',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function modelDownloaded(name: string) {
|
export function modelDownloaded(name: string) {
|
||||||
return fetch(`${API_ENDPOINT}/model_downloaded/${name}`, {
|
return fetch(`${API_ENDPOINT}/model_downloaded/${name}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -74,6 +74,7 @@ model: ModelManager = None
|
|||||||
device = None
|
device = None
|
||||||
input_image_path: str = None
|
input_image_path: str = None
|
||||||
is_disable_model_switch: bool = False
|
is_disable_model_switch: bool = False
|
||||||
|
is_desktop: bool = False
|
||||||
|
|
||||||
def get_image_ext(img_bytes):
|
def get_image_ext(img_bytes):
|
||||||
w = imghdr.what("", img_bytes)
|
w = imghdr.what("", img_bytes)
|
||||||
@ -188,6 +189,9 @@ def get_is_disable_model_switch():
|
|||||||
def model_downloaded(name):
|
def model_downloaded(name):
|
||||||
return str(model.is_downloaded(name)), 200
|
return str(model.is_downloaded(name)), 200
|
||||||
|
|
||||||
|
@app.route("/is_desktop")
|
||||||
|
def get_is_desktop():
|
||||||
|
return str(is_desktop), 200
|
||||||
|
|
||||||
@app.route("/model", methods=["POST"])
|
@app.route("/model", methods=["POST"])
|
||||||
def switch_model():
|
def switch_model():
|
||||||
@ -227,10 +231,12 @@ def main(args):
|
|||||||
global device
|
global device
|
||||||
global input_image_path
|
global input_image_path
|
||||||
global is_disable_model_switch
|
global is_disable_model_switch
|
||||||
|
global is_desktop
|
||||||
|
|
||||||
device = torch.device(args.device)
|
device = torch.device(args.device)
|
||||||
input_image_path = args.input
|
input_image_path = args.input
|
||||||
is_disable_model_switch = args.disable_model_switch
|
is_disable_model_switch = args.disable_model_switch
|
||||||
|
is_desktop = args.gui
|
||||||
if is_disable_model_switch:
|
if is_disable_model_switch:
|
||||||
logger.info(f"Start with --disable-model-switch, model switch on frontend is disable")
|
logger.info(f"Start with --disable-model-switch, model switch on frontend is disable")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user