cellpose-app / scripts /smoke.py
katospiegel's picture
Deploy cellpose-app as an imaging-plaza Gradio Space (SDSC)
52c8b2c
Raw
History Blame Contribute Delete
809 Bytes
"""Contract smoke test: segment the example, check cells + F1, save the overlay."""
from __future__ import annotations
import json
import sys
from PIL import Image
from core.io import APP_TMP_DIR
from core.processing import simulate_full
def main() -> int:
tif = APP_TMP_DIR / "example.tif"
if not tif.exists():
import scripts.make_example as me
me.main()
r = simulate_full(str(tif), engine="fast")
rep = r["report"]
assert r["summary"].ndim == 3 and r["summary"].shape[2] == 3
assert rep["n_cells"] > 0, "no cells segmented"
assert rep.get("f1", 0) > 0.5, f"low F1: {rep.get('f1')}"
Image.fromarray(r["summary"]).save(APP_TMP_DIR / "smoke_summary.png")
print("REPORT:", json.dumps(rep))
return 0
if __name__ == "__main__":
sys.exit(main())