Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,7 +17,8 @@ def move_uploaded_files(files, temp_dir):
|
|
| 17 |
for file in files:
|
| 18 |
target_file_path = os.path.join(temp_dir, os.path.basename(file.name))
|
| 19 |
saved_files.append(target_file_path)
|
| 20 |
-
|
|
|
|
| 21 |
return saved_files
|
| 22 |
|
| 23 |
|
|
@@ -30,12 +31,9 @@ def process_images(files):
|
|
| 30 |
os.makedirs(hashdir_path_img, exist_ok=True)
|
| 31 |
saved_files = move_uploaded_files(files, hashdir_path_img)
|
| 32 |
saved_files_str = ' '.join(saved_files)
|
| 33 |
-
# return 'Before: {}\nAfter: {}'.format(files_str, saved_files_str), saved_files[0]
|
| 34 |
|
| 35 |
command = [
|
| 36 |
-
|
| 37 |
-
"python",
|
| 38 |
-
"-W", "ignore",
|
| 39 |
"./coarse_init_infer.py",
|
| 40 |
"--img_base_path", hashdir_path,
|
| 41 |
"--n_views", str(n_view),
|
|
@@ -43,8 +41,9 @@ def process_images(files):
|
|
| 43 |
]
|
| 44 |
|
| 45 |
result = subprocess.run(command, capture_output=True, text=True)
|
|
|
|
| 46 |
|
| 47 |
-
return result.stdout, result.stderr
|
| 48 |
|
| 49 |
def run():
|
| 50 |
with gr.Blocks() as demo:
|
|
@@ -54,7 +53,10 @@ def run():
|
|
| 54 |
btn = gr.Button(value="Run")
|
| 55 |
# outputs = [gr.Image(type="numpy", label="Processed Images", interactive=False), gr.Video(label="Output Video")]
|
| 56 |
# outputs = [gr.Textbox(label="Log"), gr.Image(type="filepath", label="Processed Images", interactive=False)]
|
| 57 |
-
outputs = [
|
|
|
|
|
|
|
|
|
|
| 58 |
btn.click(fn=process_images, inputs=inputs, outputs=outputs)
|
| 59 |
|
| 60 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 17 |
for file in files:
|
| 18 |
target_file_path = os.path.join(temp_dir, os.path.basename(file.name))
|
| 19 |
saved_files.append(target_file_path)
|
| 20 |
+
if os.path.exists(file.name):
|
| 21 |
+
shutil.move(file.name, target_file_path)
|
| 22 |
return saved_files
|
| 23 |
|
| 24 |
|
|
|
|
| 31 |
os.makedirs(hashdir_path_img, exist_ok=True)
|
| 32 |
saved_files = move_uploaded_files(files, hashdir_path_img)
|
| 33 |
saved_files_str = ' '.join(saved_files)
|
|
|
|
| 34 |
|
| 35 |
command = [
|
| 36 |
+
"python", "-W", "ignore",
|
|
|
|
|
|
|
| 37 |
"./coarse_init_infer.py",
|
| 38 |
"--img_base_path", hashdir_path,
|
| 39 |
"--n_views", str(n_view),
|
|
|
|
| 41 |
]
|
| 42 |
|
| 43 |
result = subprocess.run(command, capture_output=True, text=True)
|
| 44 |
+
result_tree = subprocess.run(["tree", hashdir_path], capture_output=True, text=True)
|
| 45 |
|
| 46 |
+
return result_tree.stdout, result.stdout, result.stderr
|
| 47 |
|
| 48 |
def run():
|
| 49 |
with gr.Blocks() as demo:
|
|
|
|
| 53 |
btn = gr.Button(value="Run")
|
| 54 |
# outputs = [gr.Image(type="numpy", label="Processed Images", interactive=False), gr.Video(label="Output Video")]
|
| 55 |
# outputs = [gr.Textbox(label="Log"), gr.Image(type="filepath", label="Processed Images", interactive=False)]
|
| 56 |
+
outputs = [
|
| 57 |
+
gr.Textbox(label="Output dirs"),
|
| 58 |
+
gr.Textbox(label="Log (stdout)"),
|
| 59 |
+
gr.Textbox(label="Log (stderr)")]
|
| 60 |
btn.click(fn=process_images, inputs=inputs, outputs=outputs)
|
| 61 |
|
| 62 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|