Anika232 commited on
Commit
08b38b7
·
verified ·
1 Parent(s): 0f270a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -37,29 +37,36 @@ if uploaded_file is not None:
37
 
38
  # Define constants or variables for model execution
39
  MODEL_NAME = 'dsrnet_s'
40
- MODEL_PATH = 'dsrnet_model_sirs'
41
- DATASET = 'sirs_dataset'
42
- NAME = 'dsrnet_s_test'
43
- BASE_DIR = './real45'
44
- WEIGHT_PATH = './weights/dsrnet_s_epoch14.pt'
45
-
46
- # Function to run the command
47
- def run_command(command):
 
48
  process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
49
  stdout, stderr = process.communicate()
50
- return stdout, stderr
 
 
51
 
52
- # Command execution
53
- st.write(f"Running command: python ./DSRNet/test_sirs.py --inet {MODEL_NAME} --model {MODEL_PATH} --dataset {DATASET} --name {NAME} --hyper --if_align --base_dir {BASE_DIR} --resume --weight_path {WEIGHT_PATH}")
54
- stdout, stderr = run_command(f"python ./DSRNet/test_sirs.py --inet {MODEL_NAME} --model {MODEL_PATH} --dataset {DATASET} --name {NAME} --hyper --if_align --base_dir {BASE_DIR} --resume --weight_path {WEIGHT_PATH}")
55
 
56
- # Display command output
57
- st.write("Command Output:")
58
- st.code(stdout.decode('utf-8'))
59
 
60
- # Display error if any
61
- if stderr:
62
- st.error(stderr.decode('utf-8'))
 
 
 
 
 
 
63
 
64
  # Search for image ending with '_l' in subdirectories of 'checkpoints'
65
  checkpoints_dir = './test' # Update this path according to your project structure
 
37
 
38
  # Define constants or variables for model execution
39
  MODEL_NAME = 'dsrnet_s'
40
+ MODEL_PATH = 'dsrnet_model_sirs'
41
+ DATASET = 'sirs_dataset'
42
+ NAME = 'dsrnet_s_test'
43
+ BASE_DIR = './real45'
44
+ WEIGHT_PATH = './weights/dsrnet_s_epoch14.pt'
45
+
46
+ # Function to run the command
47
+ def run_command(command):
48
+ try:
49
  process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
50
  stdout, stderr = process.communicate()
51
+ return stdout.decode('utf-8'), stderr.decode('utf-8')
52
+ except Exception as e:
53
+ return "", str(e)
54
 
55
+ # Command to execute
56
+ command = f"python ./DSRNet/test_sirs.py --inet {MODEL_NAME} --model {MODEL_PATH} --dataset {DATASET} --name {NAME} --hyper --if_align --base_dir {BASE_DIR} --resume --weight_path {WEIGHT_PATH}"
 
57
 
58
+ # Display running command
59
+ st.write(f"Running command: {command}")
 
60
 
61
+ # Execute the command
62
+ stdout, stderr = run_command(command)
63
+
64
+ # Display command output
65
+ st.write("Command Output:")
66
+ if stdout:
67
+ st.code(stdout)
68
+ if stderr:
69
+ st.error(f"Command Error:\n{stderr}")
70
 
71
  # Search for image ending with '_l' in subdirectories of 'checkpoints'
72
  checkpoints_dir = './test' # Update this path according to your project structure