mirror of
https://github.com/ClovertaTheTrilobita/cellpose-web.git
synced 2026-04-01 23:14:50 +00:00
chore(run):修改接口,为train预留后端接口
This commit is contained in:
parent
6990a1e3c0
commit
a6353d1c37
3 changed files with 22 additions and 3 deletions
|
|
@ -24,6 +24,11 @@ class Cprun:
|
|||
|
||||
@classmethod
|
||||
def run_test(cls):
|
||||
"""
|
||||
仅测试用
|
||||
|
||||
:return:
|
||||
"""
|
||||
model = models.CellposeModel(gpu=True)
|
||||
files = ['test_tif/img.png']
|
||||
imgs = [imread(f) for f in files]
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ def download():
|
|||
print(OUTPUT_DIR)
|
||||
return send_from_directory(f"{OUTPUT_DIR}/tmp/", f"{timestamp}.zip", as_attachment=True)
|
||||
|
||||
@app.post("/upload")
|
||||
def upload():
|
||||
@app.post("/run_upload")
|
||||
def run_upload():
|
||||
"""
|
||||
接收上传的文件,并将其发送给cellpose。
|
||||
:return:
|
||||
|
|
@ -125,6 +125,20 @@ def upload():
|
|||
|
||||
return jsonify({"ok": True, "count": len(saved), "id": ts})
|
||||
|
||||
@app.post("/train_upload")
|
||||
def train_upload():
|
||||
ts = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + f"-{int(time.time()*1000)%1000:03d}"
|
||||
train_files = request.files.getlist("train_files")
|
||||
test_files = request.files.getlist("test_files")
|
||||
saved = []
|
||||
for f in train_files:
|
||||
if not f or f.filename == "":
|
||||
continue
|
||||
name = secure_filename(f.filename)
|
||||
f.save(os.path.join(UPLOAD_DIR, ts, name))
|
||||
saved.append(os.path.join(UPLOAD_DIR, ts, name))
|
||||
|
||||
|
||||
@app.get("/status")
|
||||
def status():
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
crossorigin="anonymous"></script>
|
||||
<script>
|
||||
const API = "http://10.147.18.141:5000/";
|
||||
const APT_UPLOAD = API + "upload";
|
||||
const APT_UPLOAD = API + "run_upload";
|
||||
const API_MODEL = API + "models";
|
||||
|
||||
async function loadModels() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue