Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/preview_renderer/nerfstudio_renderer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import subprocess
import os
import json

class NerfstudioRenderer:
def __init__(self, render_script_path: str, output_dir: str):
self.render_script_path = render_script_path
self.output_dir = output_dir

def render_images(self, input_data: dict):
try:
# Prepare the command to run Nerfstudio rendering
command = [
'python3',
self.render_script_path,
'--input', json.dumps(input_data),
'--output', self.output_dir
]

# Execute the command
result = subprocess.run(command, check=True, capture_output=True)

if result.returncode == 0:
print('Rendering completed successfully!')
return True
else:
print('Rendering failed:', result.stderr.decode())
return False
except subprocess.CalledProcessError as e:
print('Error during rendering:', e)
return False

def upload_rendered_images(self):
# Add logic to upload rendered images
print('Uploading rendered images...')
# Here you can use an API or cloud storage integration to upload files
pass

# Example usage
if __name__ == '__main__':
renderer = NerfstudioRenderer(render_script_path='/path/to/nerfstudio/render_script.py', output_dir='/path/to/output')
input_data = {
'viewpoints': ['viewpoint1', 'viewpoint2'],
'parameters': {'param1': 'value1', 'param2': 'value2'}
}
if renderer.render_images(input_data):
renderer.upload_rendered_images()