Spaces:
Running
Running
import bpy | |
import gradio as gr | |
# Set up Blender rendering parameters | |
bpy.context.scene.render.engine = 'BLENDER_WORKBENCH' | |
bpy.context.scene.render.resolution_x = 500 | |
bpy.context.scene.render.resolution_y = 200 | |
# Render the image and save it to a file | |
path = "test.png" | |
bpy.ops.render.render() | |
bpy.data.images["Render Result"].save_render(filepath=path) | |
# Function to show the rendered image | |
def show_image(): | |
return path | |
# Create a Gradio interface to display the image | |
demo = gr.Interface( | |
fn=show_image, | |
inputs=None, | |
outputs=gr.Image() | |
) | |
# Launch the Gradio interface | |
demo.launch() |