imprpve gui: remove onnxprovider, model samplerate, half-precision, reload without initialize

This commit is contained in:
wataru 2023-05-04 12:18:17 +09:00
parent 807e88b93b
commit 50ff96b3c5
8 changed files with 1797 additions and 55 deletions

View File

@ -36,14 +36,6 @@
{
"name": "onnxExport",
"options": {}
},
{
"name": "onnxExecutor",
"options": {}
},
{
"name": "modelSamplingRate",
"options": {}
}
],
"modelSetting": [
@ -61,7 +53,7 @@
"showFeature": true,
"showIndex": true,
"showHalfPrecision": true,
"showHalfPrecision": false,
"showPyTorchEnableCheckBox": false,
"defaultEnablePyTorch": true,
"onlySelectedFramework": true,

View File

@ -1 +1,10 @@
<!doctype html><html style="width:100%;height:100%;overflow:hidden"><head><meta charset="utf-8"/><title>Voice Changer Client Demo</title><script defer="defer" src="index.js"></script></head><body style="width:100%;height:100%;margin:0"><div id="app" style="width:100%;height:100%"></div></body></html>
<!DOCTYPE html>
<html style="width: 100%; height: 100%; overflow: hidden">
<head>
<meta charset="utf-8" />
<title>Voice Changer Client Demo</title>
<script defer src="index.js"></script></head>
<body style="width: 100%; height: 100%; margin: 0px">
<div id="app" style="width: 100%; height: 100%"></div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -1,31 +0,0 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

View File

@ -36,14 +36,6 @@
{
"name": "onnxExport",
"options": {}
},
{
"name": "onnxExecutor",
"options": {}
},
{
"name": "modelSamplingRate",
"options": {}
}
],
"modelSetting": [
@ -61,7 +53,7 @@
"showFeature": true,
"showIndex": true,
"showHalfPrecision": true,
"showHalfPrecision": false,
"showPyTorchEnableCheckBox": false,
"defaultEnablePyTorch": true,
"onlySelectedFramework": true,

View File

@ -68,8 +68,9 @@ const AppStateWrapper = () => {
// const modleKey = `${INDEXEDDB_KEY_MODEL_DATA}_${i}`
// await removeItem(modleKey)
// }
}
const onReloadClicked = () => {
location.reload();
}
return (
<div className="error-container">
@ -80,6 +81,7 @@ const AppStateWrapper = () => {
<p></p>
<p></p>
<p><button onClick={onClearCacheClicked}></button></p>
<p><button onClick={onReloadClicked}></button></p>
</div>
<div className="error-detail">
<div className="error-name">

View File

@ -40,10 +40,11 @@ import { ModelSamplingRateRow, ModelSamplingRateRowProps } from "./components/30
import { EnableEnhancerRow, EnableEnhancerRowProps } from "./components/610_EnableEnhancerRow"
import { DstIdRow2, DstIdRow2Props } from "./components/602v2_DstIdRow2"
import { SilenceFrontRow, SilenceFrontRowProps } from "./components/812_SilenceFrontRow"
import { ModelSwitchRow, ModelSwitchRowProps } from "./components/204_ModelSwitchRow"
// import { ModelSwitchRow, ModelSwitchRowProps } from "./components/204_ModelSwitchRow"
import { ONNXExportRow, ONNXExportRowProps } from "./components/205_ONNXExportRow"
import { ONNXExecutorRow, ONNXExecutorRowProps } from "./components/206_ONNXExecutorRow"
import { MergeLabRow, MergeLabRowProps } from "./components/a01_MergeLab.Row"
import { ModelSwitchRow, ModelSwitchRowProps } from "./components/204v2_ModelSwitchRow"
export const catalog: { [key: string]: (props: any) => JSX.Element } = {}

View File

@ -0,0 +1,75 @@
import { Framework } from "@dannadori/voice-changer-client-js"
import React, { useMemo } from "react"
import { useAppState } from "../../../001_provider/001_AppStateProvider"
export type ModelSwitchRowProps = {
}
export const ModelSwitchRow = (_props: ModelSwitchRowProps) => {
const appState = useAppState()
const modelSwitchRow = useMemo(() => {
const slot = appState.serverSetting.serverSetting.modelSlotIndex
const onSwitchModelClicked = async (slot: number) => {
const modelSlot = appState.serverSetting.serverSetting.modelSlots[slot]
let filename = ""
if (modelSlot.pyTorchModelFile && modelSlot.pyTorchModelFile.length > 0) {
filename = modelSlot.pyTorchModelFile.replace(/^.*[\\\/]/, '')
} else {
filename = modelSlot.onnxModelFile.replace(/^.*[\\\/]/, '')
}
const framework: Framework = filename.endsWith(".onnx") ? "ONNX" : "PyTorch"
// Quick hack for same slot is selected. 下桁が実際のSlotID
const dummyModelSlotIndex = (Math.floor(Date.now() / 1000)) * 1000 + slot
await appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, modelSlotIndex: dummyModelSlotIndex, framework: framework })
setTimeout(() => { // quick hack
appState.getInfo()
}, 1000 * 2)
}
const options = appState.serverSetting.serverSetting.modelSlots.map((x, index) => {
let filename = ""
if (x.pyTorchModelFile && x.pyTorchModelFile.length > 0) {
filename = x.pyTorchModelFile.replace(/^.*[\\\/]/, '')
} else if (x.onnxModelFile && x.onnxModelFile.length > 0) {
filename = x.onnxModelFile.replace(/^.*[\\\/]/, '')
} else {
return <div key={index} ></div>
}
const f0str = x.f0 == true ? "f0" : "nof0"
const srstr = Math.floor(x.samplingRate / 1000) + "K"
const embedstr = x.embChannels
const typestr = x.modelType == 0 ? "org" : "webui"
const metadata = x.deprecated ? "[deprecated version]" : `[${f0str},${srstr},${embedstr},${typestr}]`
const displayName = `[${metadata}] ${filename}`
return (
<option key={index} value={index}>{displayName}</option>
)
})
return (
<>
<div className="body-row split-3-7 left-padding-1 guided">
<div className="body-item-title left-padding-1">Swicth Model</div>
<div className="body-input-container">
<select className="body-select" value={slot} onChange={(e) => {
onSwitchModelClicked(Number(e.target.value))
appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, extraConvertSize: Number(e.target.value) })
}}>
{options}
</select>
</div>
</div>
</>
)
}, [appState.getInfo, appState.serverSetting.serverSetting])
return modelSwitchRow
}