Spaces:
Sleeping
Sleeping
Add application file
Browse files- Dockerfile +13 -0
- app.py +73 -0
- requirements.txt +1 -0
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
5 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
6 |
+
|
7 |
+
WORKDIR /app
|
8 |
+
|
9 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
11 |
+
|
12 |
+
COPY --chown=user . /app
|
13 |
+
CMD ["marimo", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# dependencies = [
|
3 |
+
# "bpy==4.2.0",
|
4 |
+
# "marimo",
|
5 |
+
# "numpy==2.1.2",
|
6 |
+
# ]
|
7 |
+
# ///
|
8 |
+
|
9 |
+
import marimo
|
10 |
+
|
11 |
+
__generated_with = "0.9.9"
|
12 |
+
app = marimo.App(width="medium")
|
13 |
+
|
14 |
+
|
15 |
+
@app.cell
|
16 |
+
def __():
|
17 |
+
import numpy
|
18 |
+
import bpy
|
19 |
+
import time
|
20 |
+
import random
|
21 |
+
import marimo as mo
|
22 |
+
import sys
|
23 |
+
import tempfile
|
24 |
+
print(sys.version)
|
25 |
+
return bpy, mo, numpy, random, sys, tempfile, time
|
26 |
+
|
27 |
+
|
28 |
+
@app.cell
|
29 |
+
def __(mo):
|
30 |
+
w = mo.ui.file(kind="area")
|
31 |
+
w
|
32 |
+
return (w,)
|
33 |
+
|
34 |
+
|
35 |
+
@app.cell
|
36 |
+
def __(tempfile, w):
|
37 |
+
file_content = w.contents()
|
38 |
+
|
39 |
+
# Create a temporary file to save the content
|
40 |
+
if file_content:
|
41 |
+
with tempfile.NamedTemporaryFile(suffix=".blend", delete=False) as temp_file:
|
42 |
+
temp_file.write(file_content)
|
43 |
+
temp_file_path = temp_file.name
|
44 |
+
return file_content, temp_file, temp_file_path
|
45 |
+
|
46 |
+
|
47 |
+
@app.cell
|
48 |
+
def __(bpy, file_content, mo, temp_file_path, time):
|
49 |
+
start_time = time.time()
|
50 |
+
|
51 |
+
# Load the temporary .blend file into Blender
|
52 |
+
if file_content:
|
53 |
+
bpy.ops.wm.open_mainfile(filepath=temp_file_path)
|
54 |
+
|
55 |
+
# Set render engine and resolution
|
56 |
+
bpy.context.scene.render.engine = 'BLENDER_WORKBENCH'
|
57 |
+
bpy.context.scene.render.resolution_x = 500
|
58 |
+
bpy.context.scene.render.resolution_y = 200
|
59 |
+
|
60 |
+
# Render and save the image without any rotation
|
61 |
+
bpy.ops.render.render()
|
62 |
+
bpy.data.images["Render Result"].save_render(filepath="test.png")
|
63 |
+
|
64 |
+
end_time = time.time()
|
65 |
+
print(f"Script execution time: {end_time - start_time:.4f} seconds")
|
66 |
+
|
67 |
+
# Display the image
|
68 |
+
mo.image(src="test.png") # Uncomment this line if you have a way to display images
|
69 |
+
return end_time, start_time
|
70 |
+
|
71 |
+
|
72 |
+
if __name__ == "__main__":
|
73 |
+
app.run()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
marimo>=0.9.9
|