Spaces:
Paused
Paused
minor improvements, allow more freedom for gradio and spaces versions
Browse files- app.py +29 -46
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -28,13 +28,12 @@ def run_on_gpu(input_point_cloud: gr.utils.NamedString,
|
|
| 28 |
|
| 29 |
in_file = '{}'.format(input_point_cloud.name)
|
| 30 |
|
| 31 |
-
# append 'rec' to the input file name
|
| 32 |
-
# splitext_result = os.path.splitext(in_file)
|
| 33 |
rand_hash = uuid.uuid4().hex
|
| 34 |
out_dir = '/tmp/outputs/{}'.format(rand_hash)
|
| 35 |
out_file_basename = os.path.basename(in_file) + '.ply'
|
| 36 |
out_file = os.path.join(out_dir, os.path.basename(in_file), out_file_basename)
|
| 37 |
os.makedirs(out_dir, exist_ok=True)
|
|
|
|
| 38 |
model_path = 'models/ppsurf_50nn/version_0/checkpoints/last.ckpt'
|
| 39 |
|
| 40 |
args = [
|
|
@@ -57,20 +56,17 @@ def run_on_gpu(input_point_cloud: gr.utils.NamedString,
|
|
| 57 |
try:
|
| 58 |
subprocess.run(['python', 'ppsurf/pps.py'] + args[1:]) # need subprocess to spawn workers
|
| 59 |
except Exception as e:
|
| 60 |
-
|
| 61 |
-
gr.Warning("Reconstruction failed, see console log for details.") # notify user
|
| 62 |
|
| 63 |
print('Finished inference at {}'.format(datetime.datetime.now()))
|
| 64 |
-
|
| 65 |
result_3d_model = out_file
|
| 66 |
-
|
| 67 |
return result_3d_model
|
| 68 |
|
| 69 |
|
| 70 |
def main():
|
| 71 |
-
description_header = '# PPSurf
|
| 72 |
|
| 73 |
-
description_col0 = '''
|
| 74 |
Supported file formats:
|
| 75 |
- PLY, STL, OBJ and other mesh files,
|
| 76 |
- XYZ as whitespace-separated text file,
|
|
@@ -79,7 +75,7 @@ def main():
|
|
| 79 |
Best results for 50k-250k points.
|
| 80 |
'''
|
| 81 |
|
| 82 |
-
description_col1 = '''
|
| 83 |
This method is meant for scans of single and few objects.
|
| 84 |
Quality for scenes and landscapes will be lower.
|
| 85 |
|
|
@@ -128,23 +124,30 @@ def main():
|
|
| 128 |
f'src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>')
|
| 129 |
|
| 130 |
with gr.Blocks(css='style.css') as demo:
|
|
|
|
| 131 |
gr.Markdown(description_header)
|
| 132 |
with gr.Row():
|
| 133 |
with gr.Column():
|
| 134 |
gr.Markdown(description_col0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
# with gr.Tabs() as input_tabs: # re-enable when Gradio supports point clouds
|
| 136 |
# with gr.TabItem(label='Input Point Cloud Upload', id='pc_upload'):
|
| 137 |
-
input_point_cloud_upload
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
# input_point_cloud_viewer = gr.Model3D(show_label=False)
|
| 148 |
gen_resolution_global = gr.Slider(
|
| 149 |
label='Grid Resolution (larger for more details)',
|
| 150 |
minimum=17, maximum=513, value=129, step=2)
|
|
@@ -158,33 +161,13 @@ def main():
|
|
| 158 |
label='Edge Refinement Iterations (larger for more details)',
|
| 159 |
minimum=3, maximum=30, value=10, step=1)
|
| 160 |
with gr.Column():
|
| 161 |
-
gr.
|
| 162 |
# progress_text = gr.Text(label='Progress')
|
| 163 |
-
with gr.Tabs():
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
# with gr.Row():
|
| 169 |
-
# examples = [
|
| 170 |
-
# ['shapes/dragon1.obj', 'a photo of a dragon', 0, 7.5],
|
| 171 |
-
# ['shapes/dragon2.obj', 'a photo of a dragon', 0, 7.5],
|
| 172 |
-
# ['shapes/eagle.obj', 'a photo of an eagle', 0, 7.5],
|
| 173 |
-
# ['shapes/napoleon.obj', 'a photo of Napoleon Bonaparte', 3, 7.5],
|
| 174 |
-
# ['shapes/nascar.obj', 'A next gen nascar', 2, 10],
|
| 175 |
-
# ]
|
| 176 |
-
# gr.Examples(examples=examples,
|
| 177 |
-
# inputs=[
|
| 178 |
-
# input_point_cloud_viewer,
|
| 179 |
-
# text,
|
| 180 |
-
# seed,
|
| 181 |
-
# guidance_scale,
|
| 182 |
-
# ],
|
| 183 |
-
# outputs=[
|
| 184 |
-
# result_3d_model,
|
| 185 |
-
# output_file,
|
| 186 |
-
# ],
|
| 187 |
-
# cache_examples=False)
|
| 188 |
|
| 189 |
with gr.Row():
|
| 190 |
run_button = gr.Button('Reconstruct with PPSurf')
|
|
|
|
| 28 |
|
| 29 |
in_file = '{}'.format(input_point_cloud.name)
|
| 30 |
|
|
|
|
|
|
|
| 31 |
rand_hash = uuid.uuid4().hex
|
| 32 |
out_dir = '/tmp/outputs/{}'.format(rand_hash)
|
| 33 |
out_file_basename = os.path.basename(in_file) + '.ply'
|
| 34 |
out_file = os.path.join(out_dir, os.path.basename(in_file), out_file_basename)
|
| 35 |
os.makedirs(out_dir, exist_ok=True)
|
| 36 |
+
|
| 37 |
model_path = 'models/ppsurf_50nn/version_0/checkpoints/last.ckpt'
|
| 38 |
|
| 39 |
args = [
|
|
|
|
| 56 |
try:
|
| 57 |
subprocess.run(['python', 'ppsurf/pps.py'] + args[1:]) # need subprocess to spawn workers
|
| 58 |
except Exception as e:
|
| 59 |
+
gr.Warning("Reconstruction failed:\n{}".format(e))
|
|
|
|
| 60 |
|
| 61 |
print('Finished inference at {}'.format(datetime.datetime.now()))
|
|
|
|
| 62 |
result_3d_model = out_file
|
|
|
|
| 63 |
return result_3d_model
|
| 64 |
|
| 65 |
|
| 66 |
def main():
|
| 67 |
+
description_header = '# PPSurf: Combining Patches and Point Convolutions for Detailed Surface Reconstruction'
|
| 68 |
|
| 69 |
+
description_col0 = '''## [Github](https://github.com/cg-tuwien/ppsurf)
|
| 70 |
Supported file formats:
|
| 71 |
- PLY, STL, OBJ and other mesh files,
|
| 72 |
- XYZ as whitespace-separated text file,
|
|
|
|
| 75 |
Best results for 50k-250k points.
|
| 76 |
'''
|
| 77 |
|
| 78 |
+
description_col1 = '''## [Project Info](https://www.cg.tuwien.ac.at/research/publications/2024/erler_2024_ppsurf/)
|
| 79 |
This method is meant for scans of single and few objects.
|
| 80 |
Quality for scenes and landscapes will be lower.
|
| 81 |
|
|
|
|
| 124 |
f'src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>')
|
| 125 |
|
| 126 |
with gr.Blocks(css='style.css') as demo:
|
| 127 |
+
# descriptions
|
| 128 |
gr.Markdown(description_header)
|
| 129 |
with gr.Row():
|
| 130 |
with gr.Column():
|
| 131 |
gr.Markdown(description_col0)
|
| 132 |
+
with gr.Column():
|
| 133 |
+
gr.Markdown(description_col1)
|
| 134 |
+
|
| 135 |
+
# inputs and outputs
|
| 136 |
+
with gr.Row():
|
| 137 |
+
with gr.Column():
|
| 138 |
+
input_point_cloud_upload = gr.File(show_label=False, file_count='single')
|
| 139 |
# with gr.Tabs() as input_tabs: # re-enable when Gradio supports point clouds
|
| 140 |
# with gr.TabItem(label='Input Point Cloud Upload', id='pc_upload'):
|
| 141 |
+
# input_point_cloud_upload.upload(
|
| 142 |
+
# fn=convert_to_ply,
|
| 143 |
+
# inputs=[
|
| 144 |
+
# input_point_cloud_upload,
|
| 145 |
+
# ],
|
| 146 |
+
# outputs=[
|
| 147 |
+
# # input_point_cloud_viewer, # not available here
|
| 148 |
+
# ])
|
| 149 |
+
# with gr.TabItem(label='Input Point Cloud Viewer', id='pc_viewer'):
|
| 150 |
+
# input_point_cloud_viewer = gr.Model3D(show_label=False)
|
|
|
|
| 151 |
gen_resolution_global = gr.Slider(
|
| 152 |
label='Grid Resolution (larger for more details)',
|
| 153 |
minimum=17, maximum=513, value=129, step=2)
|
|
|
|
| 161 |
label='Edge Refinement Iterations (larger for more details)',
|
| 162 |
minimum=3, maximum=30, value=10, step=1)
|
| 163 |
with gr.Column():
|
| 164 |
+
result_3d_model = gr.Model3D(label='Reconstructed 3D model')
|
| 165 |
# progress_text = gr.Text(label='Progress')
|
| 166 |
+
# with gr.Tabs():
|
| 167 |
+
# with gr.TabItem(label='Reconstructed 3D model'):
|
| 168 |
+
# result_3d_model = gr.Model3D(show_label=False)
|
| 169 |
+
# with gr.TabItem(label='Output mesh file'):
|
| 170 |
+
# output_file = gr.File(show_label=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
with gr.Row():
|
| 173 |
run_button = gr.Button('Reconstruct with PPSurf')
|
requirements.txt
CHANGED
|
@@ -19,5 +19,5 @@ trimesh>=3.23.5
|
|
| 19 |
pysdf>=0.1.9
|
| 20 |
jsonargparse[signatures]>=4.27.5
|
| 21 |
|
| 22 |
-
spaces>=0.23
|
| 23 |
-
gradio>=4.19
|
|
|
|
| 19 |
pysdf>=0.1.9
|
| 20 |
jsonargparse[signatures]>=4.27.5
|
| 21 |
|
| 22 |
+
spaces>=0.23
|
| 23 |
+
gradio>=4.19
|