forked from andrew/karung-counting-feedmill-semarang
- deploy_to_jetson.py: sync history.html + analytics.html, interfaces.py + streaming.py; drop nonexistent clip_jobs.py - AGENTS.md: active_mode default now G; deploy sync list updated - docs/deployment.md: deploy sync list + engine files updated - docs/models.md: best task bbox (not seg); modes A-G, active_mode default G
108 lines
3.6 KiB
Python
108 lines
3.6 KiB
Python
import paramiko
|
|
import os
|
|
|
|
# Production loads .engine weights from models/ (see models/modelREADME.md).
|
|
# .pt/.onnx stay local-only (dev/export) — not synced to save bandwidth.
|
|
MODEL_ENGINES = [
|
|
"v4-best.engine",
|
|
"yolo11n-bbox-100ep-sack+box-20260909-best.engine",
|
|
"yolo11n-bbox-200ep-sack+box+truck-20261104-best.engine",
|
|
"yolo8n-bbox-100ep-sack+box+truck-imgsz320-20261110.engine",
|
|
"yolo26n-bbox-200ep-sack+box+truck-20261118-best.engine",
|
|
"best.engine",
|
|
"truck-detector.engine",
|
|
"model_karung_truk.engine",
|
|
]
|
|
|
|
SRC_MODULES = [
|
|
"__init__.py",
|
|
"batch.py",
|
|
"clip.py",
|
|
"interfaces.py",
|
|
"streaming.py",
|
|
"config.py",
|
|
"config_loader.py",
|
|
"counting.py",
|
|
"dashboard.py",
|
|
"detection.py",
|
|
"do_batch.py",
|
|
"do_ocr.py",
|
|
"logger.py",
|
|
"main.py",
|
|
"persistence.py",
|
|
"peer_sync.py",
|
|
"pipeline.py",
|
|
"stabilizer.py",
|
|
"tracking.py",
|
|
"truck_roi.py",
|
|
"ui.py",
|
|
"validation.py",
|
|
]
|
|
|
|
files_to_sync = [
|
|
("templates/operator.html", "/home/jetson/karung/templates/operator.html"),
|
|
("templates/monitoring.html", "/home/jetson/karung/templates/monitoring.html"),
|
|
("templates/base.html", "/home/jetson/karung/templates/base.html"),
|
|
("templates/history.html", "/home/jetson/karung/templates/history.html"),
|
|
("templates/analytics.html", "/home/jetson/karung/templates/analytics.html"),
|
|
("counter_dashboard.py", "/home/jetson/karung/counter_dashboard.py"),
|
|
("predict.py", "/home/jetson/karung/predict.py"),
|
|
("config.yaml", "/home/jetson/karung/config.yaml"),
|
|
(".env", "/home/jetson/karung/.env"),
|
|
] + [
|
|
(f"src/{f}", f"/home/jetson/karung/src/{f}") for f in SRC_MODULES
|
|
] + [
|
|
(f"models/{f}", f"/home/jetson/karung/models/{f}") for f in MODEL_ENGINES
|
|
]
|
|
|
|
def run():
|
|
host = os.getenv('JETSON_HOST', '192.168.192.96')
|
|
user = os.getenv('JETSON_USER', 'jetson')
|
|
password = os.getenv('JETSON_PASS', 'jetson')
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(host, username=user, password=password, timeout=10)
|
|
|
|
sftp = client.open_sftp()
|
|
|
|
# Ensure remote models/ and src/ dirs exist (sftp.put fails otherwise)
|
|
for remote_dir in ("/home/jetson/karung/models", "/home/jetson/karung/src"):
|
|
try:
|
|
sftp.stat(remote_dir)
|
|
except FileNotFoundError:
|
|
print(f"Creating remote {remote_dir}/ ...")
|
|
sftp.mkdir(remote_dir)
|
|
|
|
print("Uploading updated files to Jetson...")
|
|
for local_f, remote_f in files_to_sync:
|
|
if not os.path.exists(local_f):
|
|
print(f"SKIP (missing local file): {local_f}")
|
|
continue
|
|
print(f"Uploading {local_f} -> {remote_f}")
|
|
sftp.put(local_f, remote_f)
|
|
|
|
sftp.close()
|
|
print("All files uploaded successfully!")
|
|
|
|
print("Restarting services on Jetson...")
|
|
cmd = f"echo {password} | sudo -S systemctl restart karung-counter karung-counter-dashboard"
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
print("STDOUT:", stdout.read().decode('utf-8', errors='ignore'))
|
|
print("STDERR:", stderr.read().decode('utf-8', errors='ignore'))
|
|
|
|
# Check status
|
|
stdin, stdout, stderr = client.exec_command("systemctl status karung-counter-dashboard karung-counter --no-pager")
|
|
print("=== SERVICE STATUS ===")
|
|
print(stdout.read().decode('utf-8', errors='ignore').encode('ascii', errors='ignore').decode())
|
|
|
|
# Check listening ports
|
|
stdin, stdout, stderr = client.exec_command("netstat -tuln | grep -E '5000|5721'")
|
|
print("=== LISTENING PORTS ===")
|
|
print(stdout.read().decode('utf-8', errors='ignore'))
|
|
|
|
client.close()
|
|
|
|
if __name__ == '__main__':
|
|
run()
|