Skip to content

Commit

Permalink
add requirements,fix backend url
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyily committed Jul 24, 2023
1 parent d356a9e commit 65ab2a8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
23 changes: 21 additions & 2 deletions backend.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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)
port = 8612
t1 = Thread(target=run_server, args=[port])
t2 = Thread(target=open_browser, args=[port])

t1.start()
t2.start()

t1.join()
t2.join()
4 changes: 2 additions & 2 deletions react_app/src/PianoTrans.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastapi
"uvicorn[standard]"
onnxruntime-directml
librosa
mido
python-multipart

0 comments on commit 65ab2a8

Please sign in to comment.