Skip to content
Snippets Groups Projects
Commit c67fc9cf authored by las1g21's avatar las1g21
Browse files

Merge branch 'GDP_4.4.5' into 'master'

GDP 4.4.5

See merge request !9
parents e74103c3 9184edeb
No related branches found
No related tags found
1 merge request!9GDP 4.4.5
scripts/360monodepthexecution/rgb.jpg
scripts/shifted_t.png
scripts/config.ini
*.pyc
\ No newline at end of file
*.pyc
.env
\ No newline at end of file
mona-ssc @ a0816610
Subproject commit a0816610da9fa1ed52674240d8343b5643f0e25c
import paramiko
from dotenv import load_dotenv
from scp import SCPClient
import os
import subprocess
import time
load_dotenv()
hostname = os.getenv("HOSTNAME")
username = os.getenv("USERNAME")
password = os.getenv("PASSWORD")
def send_files(shifted_disparity_path, shifted_t_path):
# sends two files needed to iridis
# files keep their names. NAMES MUST BE shifted_disparity.png AND shifted_t.png
command = [
"scp",
shifted_disparity_path,
f"{username}@{hostname}:{os.getenv("REMOTE_INPUT_PATH")}"
]
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"Error during SCP: {e}")
return False, False
command = [
"scp",
shifted_t_path,
f"{username}@{hostname}:{os.getenv("REMOTE_INPUT_PATH")}"
]
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"Error during SCP: {e}")
return False, False
return True
def get_completed_scene(shifted_disparity_path, shifted_t_path):
if send_files(shifted_disparity_path, shifted_t_path):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# Connect to the server
try:
client.connect(hostname, username=username, password=password)
print("SSH connection established.")
# Check if the connection is active
if client.get_transport().is_active():
print("Connection is active.")
else:
print("Connection is not active.")
return False, False
except Exception as e:
print(f"Failed to connect to {hostname}: {e}")
return False, False
stdin, stdout, stderr = client.exec_command(
"cd mona/MDBNet360_GDP/" +
" && module load conda" +
" && source activate" +
" && conda activate ssc_env" +
" && sbatch --partition=ecsstudents --account=ecsstudents run_enhance360_job.sh"
)
output = stdout.read().decode()
print(output)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
time.sleep(30)
while "RUNNING" in output:
print("Sleeping for 30")
time.sleep(30)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
print("Finish Enhancing")
stdin, stdout, stderr = client.exec_command(
"cd mona/MDBNet360_GDP/" +
" && module load conda" +
" && source activate" +
" && conda activate ssc_env" +
" && sbatch --partition=ecsstudents --account=ecsstudents run_obj_job.sh"
)
output = stdout.read().decode()
print(output)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
time.sleep(30)
while "RUNNING" in output:
print("Sleeping for 30")
time.sleep(30)
stdin, stdout, stderr = client.exec_command("squeue -lu kproject")
output = stdout.read().decode()
print(output)
remote_file_path = "/mainfs/ECShome/kproject/mona/MDBNet360_GDP/output/scene_completed_prediction.obj"
local_file_path = "edgenet-360/Data/Input/scene_completed_prediction.obj"
with SCPClient(client.get_transport()) as scp:
scp.get(remote_file_path, local_file_path) # Download file
print("OUTPUT DOWNLOADED")
# Close the SSH connection
client.close()
return True, local_file_path
else:
return False, False
# out = get_completed_scene("C:\\Project\\AVVR-Pipeline-GDP4\\edgenet-360\\Data\\Courtyard\\shifted-disparity.png", "C:\\Project\\AVVR-Pipeline-GDP4\\edgenet-360\\Data\\Courtyard\\shifted_t.png")
# print(out)
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python shifter.py <shifted_disparity_path> <shifted_t_path>")
sys.exit(1)
shifted_disparity_path = sys.argv[1]
shifted_t_path = sys.argv[2]
saved_path = get_completed_scene(shifted_disparity_path, shifted_t_path)
print(f"Shifted image saved as {saved_path}")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment