Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,13 +20,27 @@ def move_uploaded_files(files, temp_dir):
|
|
| 20 |
|
| 21 |
|
| 22 |
def process_images(files):
|
|
|
|
| 23 |
files_str = ','.join([f.name for f in files])
|
| 24 |
hashdir = hashlib.md5(files_str.encode('utf8')).hexdigest()
|
| 25 |
hashdir_path = os.path.join(TMP_DIR, hashdir)
|
| 26 |
os.makedirs(hashdir_path, exist_ok=True)
|
| 27 |
saved_files = move_uploaded_files(files, hashdir_path)
|
| 28 |
saved_files_str = ' '.join(saved_files)
|
| 29 |
-
return 'Before: {}\nAfter: {}'.format(files_str, saved_files_str), saved_files[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
def run():
|
| 32 |
with gr.Blocks() as demo:
|
|
@@ -35,7 +49,8 @@ def run():
|
|
| 35 |
inputs = gr.File(file_count="multiple", file_types=["image"], label="Upload Images")
|
| 36 |
btn = gr.Button(value="Run")
|
| 37 |
# outputs = [gr.Image(type="numpy", label="Processed Images", interactive=False), gr.Video(label="Output Video")]
|
| 38 |
-
outputs = [gr.Textbox(label="Log"), gr.Image(type="filepath", label="Processed Images", interactive=False)]
|
|
|
|
| 39 |
btn.click(fn=process_images, inputs=inputs, outputs=outputs)
|
| 40 |
|
| 41 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
def process_images(files):
|
| 23 |
+
n_view = len(files)
|
| 24 |
files_str = ','.join([f.name for f in files])
|
| 25 |
hashdir = hashlib.md5(files_str.encode('utf8')).hexdigest()
|
| 26 |
hashdir_path = os.path.join(TMP_DIR, hashdir)
|
| 27 |
os.makedirs(hashdir_path, exist_ok=True)
|
| 28 |
saved_files = move_uploaded_files(files, hashdir_path)
|
| 29 |
saved_files_str = ' '.join(saved_files)
|
| 30 |
+
# return 'Before: {}\nAfter: {}'.format(files_str, saved_files_str), saved_files[0]
|
| 31 |
+
|
| 32 |
+
command = [
|
| 33 |
+
"python",
|
| 34 |
+
"-W", "ignore",
|
| 35 |
+
"./coarse_init_infer.py",
|
| 36 |
+
"--img_base_path", hashdir,
|
| 37 |
+
"--n_views", n_view,
|
| 38 |
+
"--focal_avg",
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
result = subprocess.run(command, capture_output=True, text=True)
|
| 42 |
+
|
| 43 |
+
return result.stdout, result.stderr
|
| 44 |
|
| 45 |
def run():
|
| 46 |
with gr.Blocks() as demo:
|
|
|
|
| 49 |
inputs = gr.File(file_count="multiple", file_types=["image"], label="Upload Images")
|
| 50 |
btn = gr.Button(value="Run")
|
| 51 |
# outputs = [gr.Image(type="numpy", label="Processed Images", interactive=False), gr.Video(label="Output Video")]
|
| 52 |
+
# outputs = [gr.Textbox(label="Log"), gr.Image(type="filepath", label="Processed Images", interactive=False)]
|
| 53 |
+
outputs = [gr.Textbox(label="Log (stdout)"), gr.Textbox(label="Log (stderr)")]
|
| 54 |
btn.click(fn=process_images, inputs=inputs, outputs=outputs)
|
| 55 |
|
| 56 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|