Spaces:
Runtime error
Runtime error
import os | |
import subprocess | |
import gradio as gr | |
def setup_blender(): | |
if not os.path.exists('blender-3.0.0-linux-x64.tar.xz'): | |
subprocess.run(['wget', 'https://download.blender.org/release/Blender3.0/blender-3.0.0-linux-x64.tar.xz']) | |
if not os.path.exists('blender-3.0.0-linux-x64'): | |
subprocess.run(['tar', '-xf', 'blender-3.0.0-linux-x64.tar.xz']) | |
os.environ['PATH'] += os.pathsep + os.path.abspath('./blender-3.0.0-linux-x64/blender') | |
def render_model(): | |
setup_blender() | |
# Path to your .blend file | |
blend_file = "path/to/your/model.blend" | |
# Output file | |
output_file = "output.png" | |
# Render command | |
render_command = f"blender -b {blend_file} -o //{output_file} -f 1" | |
subprocess.run(render_command.split()) | |
return output_file | |
def render_interface(): | |
with gr.Blocks() as demo: | |
gr.Markdown("# Blender Rendering with Gradio") | |
with gr.Row(): | |
blend_file_input = gr.File(label="Upload your .blend file") | |
render_button = gr.Button("Render") | |
output_image = gr.Image(label="Rendered Image") | |
render_button.click( | |
fn=render_model, | |
inputs=[], | |
outputs=[output_image] | |
) | |
return demo | |
if __name__ == "__main__": | |
render_interface().launch() | |