From a6353d1c37ebe0ee5ecbb8afee5fe36fc871230a Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Mon, 22 Sep 2025 18:51:29 +0000 Subject: [PATCH] =?UTF-8?q?chore(run):=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E4=B8=BAtrain=E9=A2=84=E7=95=99=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/cp_run.py | 5 +++++ backend/flaskApp.py | 18 ++++++++++++++++-- frontend/index.html | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/backend/cp_run.py b/backend/cp_run.py index 68e9b91..dfcb4ab 100644 --- a/backend/cp_run.py +++ b/backend/cp_run.py @@ -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] diff --git a/backend/flaskApp.py b/backend/flaskApp.py index 9c1fb48..5671347 100644 --- a/backend/flaskApp.py +++ b/backend/flaskApp.py @@ -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(): """ diff --git a/frontend/index.html b/frontend/index.html index 2bea590..2ae0aeb 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -59,7 +59,7 @@ crossorigin="anonymous">