diff --git a/backend.py b/backend.py index 852c7cc..3818393 100644 --- a/backend.py +++ b/backend.py @@ -1,5 +1,9 @@ import os from typing import Union +import webbrowser +from threading import Thread +import time + import uvicorn from fastapi import FastAPI,UploadFile from fastapi.middleware.cors import CORSMiddleware @@ -17,7 +21,7 @@ class HppnetInferTask(BaseModel): device:str onset_t:float frame_t:float - gpu_id:Union[str, None] = None + gpu_id:Union[int, None] = None app = FastAPI() app.mount("/static", StaticFiles(directory="./webui/static"), name="static") @@ -98,5 +102,20 @@ async def create_upload_file(file: UploadFile): return {"filename": file.filename} +def run_server(port): + uvicorn.run(app, host="0.0.0.0", port=port) + +def open_browser(port): + time.sleep(3) + webbrowser.open(f'http://127.0.0.1:{port}/') + if __name__ == "__main__": - uvicorn.run(app, host="0.0.0.0", port=8000) \ No newline at end of file + port = 8612 + t1 = Thread(target=run_server, args=[port]) + t2 = Thread(target=open_browser, args=[port]) + + t1.start() + t2.start() + + t1.join() + t2.join() \ No newline at end of file diff --git a/react_app/src/PianoTrans.js b/react_app/src/PianoTrans.js index 497c23c..45cd8a3 100644 --- a/react_app/src/PianoTrans.js +++ b/react_app/src/PianoTrans.js @@ -16,8 +16,8 @@ import { useRef, useEffect, useState } from 'react'; import Slider from '@mui/material/Slider'; import MuiInput from '@mui/material/Input'; -const backendUrl = 'http://127.0.0.1:8000/'; -// const backendUrl = ''; +// const backendUrl = 'http://127.0.0.1:8000/'; +const backendUrl = ''; function InferAlert(props) { //props.inferState:finish|backendError|none|missingParam diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5713c54 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +fastapi +"uvicorn[standard]" +onnxruntime-directml +librosa +mido +python-multipart \ No newline at end of file