Jan-Hendrik Müller commited on
Commit
70f1d25
·
1 Parent(s): 2dab737
Files changed (10) hide show
  1. .gitattributes +0 -34
  2. .gitignore +162 -0
  3. Dockerfile +21 -95
  4. README.md +6 -9
  5. login.html +0 -69
  6. on_startup.sh +0 -5
  7. packages.txt +0 -1
  8. pages/01_app.ipynb +70 -0
  9. requirements.txt +3 -3
  10. start_server.sh +0 -19
.gitattributes DELETED
@@ -1,34 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tflite filter=lfs diff=lfs merge=lfs -text
29
- *.tgz filter=lfs diff=lfs merge=lfs -text
30
- *.wasm filter=lfs diff=lfs merge=lfs -text
31
- *.xz filter=lfs diff=lfs merge=lfs -text
32
- *.zip filter=lfs diff=lfs merge=lfs -text
33
- *.zst filter=lfs diff=lfs merge=lfs -text
34
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.png
6
+
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/#use-with-ide
112
+ .pdm.toml
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
Dockerfile CHANGED
@@ -1,105 +1,31 @@
1
- FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
 
2
 
3
- ENV DEBIAN_FRONTEND=noninteractive \
4
- TZ=Europe/Paris
5
 
6
- # Remove any third-party apt sources to avoid issues with expiring keys.
7
- # Install some basic utilities
8
- RUN rm -f /etc/apt/sources.list.d/*.list && \
9
- apt-get update && apt-get install -y --no-install-recommends \
10
- curl \
11
- ca-certificates \
12
- sudo \
13
- git \
14
- wget \
15
- procps \
16
- git-lfs \
17
- zip \
18
- unzip \
19
- htop \
20
- vim \
21
- nano \
22
- bzip2 \
23
- libx11-6 \
24
- build-essential \
25
- libsndfile-dev \
26
- software-properties-common \
27
- && rm -rf /var/lib/apt/lists/*
28
-
29
- RUN add-apt-repository ppa:flexiondotorg/nvtop && \
30
- apt-get upgrade -y && \
31
- apt-get install -y --no-install-recommends nvtop
32
-
33
- RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
34
- apt-get install -y nodejs && \
35
- npm install -g configurable-http-proxy
36
-
37
- # Create a working directory
38
- WORKDIR /app
39
-
40
- # Create a non-root user and switch to it
41
- RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
42
- && chown -R user:user /app
43
- RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
44
- USER user
45
-
46
- # All users can use /home/user as their home directory
47
- ENV HOME=/home/user
48
- RUN mkdir $HOME/.cache $HOME/.config \
49
- && chmod -R 777 $HOME
50
-
51
- # Set up the Conda environment
52
- ENV CONDA_AUTO_UPDATE_CONDA=false \
53
- PATH=$HOME/miniconda/bin:$PATH
54
- RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
55
- && chmod +x ~/miniconda.sh \
56
- && ~/miniconda.sh -b -p ~/miniconda \
57
- && rm ~/miniconda.sh \
58
- && conda clean -ya
59
-
60
- WORKDIR $HOME/app
61
-
62
- #######################################
63
- # Start root user section
64
- #######################################
65
 
 
66
  USER root
67
 
68
- # User Debian packages
69
- ## Security warning : Potential user code executed as root (build time)
70
- RUN --mount=target=/root/packages.txt,source=packages.txt \
71
- apt-get update && \
72
- xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
73
- && rm -rf /var/lib/apt/lists/*
74
-
75
- RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
76
- bash /root/on_startup.sh
77
-
78
- RUN mkdir /data && chown user:user /data
79
-
80
- #######################################
81
- # End root user section
82
- #######################################
83
-
84
- USER user
85
-
86
- # Python packages
87
- RUN --mount=target=requirements.txt,source=requirements.txt \
88
- pip install --no-cache-dir --upgrade -r requirements.txt
89
 
90
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
91
- COPY --chown=user . $HOME/app
 
92
 
93
- RUN chmod +x start_server.sh
 
94
 
95
- COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
 
 
96
 
97
- ENV PYTHONUNBUFFERED=1 \
98
- GRADIO_ALLOW_FLAGGING=never \
99
- GRADIO_NUM_PORTS=1 \
100
- GRADIO_SERVER_NAME=0.0.0.0 \
101
- GRADIO_THEME=huggingface \
102
- SYSTEM=spaces \
103
- SHELL=/bin/bash
104
 
105
- CMD ["./start_server.sh"]
 
 
1
+ # Use a base image with Python 3.11
2
+ FROM jupyter/base-notebook:python-3.11.6
3
 
4
+ # Copy the requirements file into the container
5
+ COPY requirements.txt .
6
 
7
+ # Install the required Python packages
8
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ # Switch to root user to install system packages
11
  USER root
12
 
13
+ # Install required system packages
14
+ RUN apt-get update && apt-get install -y xorg libgomp1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ # Create directory for pages and copy content
17
+ RUN mkdir -p /home/jovyan/pages
18
+ COPY /pages /home/jovyan/pages
19
 
20
+ # Set environment variables for PROJ_LIB if necessary
21
+ ENV PROJ_LIB='/opt/conda/share/proj'
22
 
23
+ # Ensure the notebook user has access to the content
24
+ RUN chown -R ${NB_UID} /home/jovyan
25
+ USER ${NB_USER}
26
 
27
+ # Expose the necessary port
28
+ EXPOSE 8765
 
 
 
 
 
29
 
30
+ # Define the command to run the application
31
+ CMD ["solara", "run", "/home/jovyan/pages", "--host=0.0.0.0"]
README.md CHANGED
@@ -1,13 +1,10 @@
1
  ---
2
- title: Bpy4.2.0 Solara
3
- emoji: 💻🐳
4
- colorFrom: gray
5
- colorTo: green
6
  sdk: docker
7
  pinned: false
8
- tags:
9
- - jupyterlab
10
- suggested_storage: small
11
  ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Blender4.2 with Solara
3
+ emoji: 🌞
4
+ colorFrom: orange
5
+ colorTo: yellow
6
  sdk: docker
7
  pinned: false
8
+ license: mit
9
+ app_port: 8765
 
10
  ---
 
 
login.html DELETED
@@ -1,69 +0,0 @@
1
- {% extends "page.html" %}
2
-
3
-
4
- {% block stylesheet %}
5
- {% endblock %}
6
-
7
- {% block site %}
8
-
9
- <div id="jupyter-main-app" class="container">
10
-
11
- <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="Hugging Face Logo">
12
- <h4>You must duplicate this Space to use it.</h4>
13
- <br>
14
- <a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/DockerTemplates/jupyterlab?duplicate=true">
15
- <img style="margin: 0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&amp;style=flat&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&amp;logoWidth=14" alt="Duplicate Space"></a>
16
- <br>
17
- <br>
18
- <h4>The default token is <span style="color:orange;">huggingface</span></h4>
19
- <h4>Duplicate the Space to run your own instance</h4>
20
-
21
- {% if login_available %}
22
- {# login_available means password-login is allowed. Show the form. #}
23
- <div class="row">
24
- <div class="navbar col-sm-8">
25
- <div class="navbar-inner">
26
- <div class="container">
27
- <div class="center-nav">
28
- <form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
29
- {{ xsrf_form_html() | safe }}
30
- {% if token_available %}
31
- <label for="password_input"><strong>{% trans %}Token:{% endtrans
32
- %}</strong></label>
33
- {% else %}
34
- <label for="password_input"><strong>{% trans %}Password:{% endtrans %}</strong></label>
35
- {% endif %}
36
- <input type="password" name="password" id="password_input" class="form-control">
37
- <button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
38
- %}</button>
39
- </form>
40
- </div>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
45
- {% else %}
46
- <p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
47
- {% endif %}
48
- <p>This template was created by <a href="https://twitter.com/camenduru" target="_blank" >camenduru</a> and <a href="https://huggingface.co/nateraw" target="_blank" >nateraw</a>, with contributions of <a href="https://huggingface.co/osanseviero" target="_blank" >osanseviero</a> and <a href="https://huggingface.co/azzr" target="_blank" >azzr</a> </p>
49
- {% if message %}
50
- <div class="row">
51
- {% for key in message %}
52
- <div class="message {{key}}">
53
- {{message[key]}}
54
- </div>
55
- {% endfor %}
56
- </div>
57
- {% endif %}
58
- {% if token_available %}
59
- {% block token_message %}
60
-
61
- {% endblock token_message %}
62
- {% endif %}
63
- </div>
64
-
65
- {% endblock %}
66
-
67
-
68
- {% block script %}
69
- {% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
on_startup.sh DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
- # Write some commands here that will run on root user before startup.
3
- # For example, to clone transformers and install it in dev mode:
4
- # git clone https://github.com/huggingface/transformers.git
5
- # cd transformers && pip install -e ".[dev]"
 
 
 
 
 
 
packages.txt DELETED
@@ -1 +0,0 @@
1
- tree
 
 
pages/01_app.ipynb ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 3,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "application/vnd.jupyter.widget-view+json": {
11
+ "model_id": "bcaaa2ad743e4593816871bb9612d10e",
12
+ "version_major": 2,
13
+ "version_minor": 0
14
+ },
15
+ "text/html": [
16
+ "Cannot show widget. You probably want to rerun the code cell above (<i>Click in the code cell, and press Shift+Enter <kbd>⇧</kbd>+<kbd>↩</kbd></i>)."
17
+ ],
18
+ "text/plain": [
19
+ "Cannot show ipywidgets in text"
20
+ ]
21
+ },
22
+ "metadata": {},
23
+ "output_type": "display_data"
24
+ }
25
+ ],
26
+ "source": [
27
+ "import solara\n",
28
+ "import bpy\n",
29
+ "\n",
30
+ "from pathlib import Path\n",
31
+ "\n",
32
+ "@solara.component\n",
33
+ "def Page():\n",
34
+ " bpy.context.scene.render.engine = 'BLENDER_WORKBENCH'\n",
35
+ " bpy.context.scene.render.resolution_x = 500\n",
36
+ " bpy.context.scene.render.resolution_y = 200\n",
37
+ "\n",
38
+ " path = \"test.png\"\n",
39
+ " bpy.ops.render.render()\n",
40
+ " bpy.data.images[\"Render Result\"].save_render(filepath=path)\n",
41
+ " image_path = Path.cwd() / \"test.png\"\n",
42
+ "\n",
43
+ " solara.Image(image_path)\n",
44
+ "\n",
45
+ "Page()"
46
+ ]
47
+ }
48
+ ],
49
+ "metadata": {
50
+ "kernelspec": {
51
+ "display_name": ".venv",
52
+ "language": "python",
53
+ "name": "python3"
54
+ },
55
+ "language_info": {
56
+ "codemirror_mode": {
57
+ "name": "ipython",
58
+ "version": 3
59
+ },
60
+ "file_extension": ".py",
61
+ "mimetype": "text/x-python",
62
+ "name": "python",
63
+ "nbconvert_exporter": "python",
64
+ "pygments_lexer": "ipython3",
65
+ "version": "3.11.10"
66
+ }
67
+ },
68
+ "nbformat": 4,
69
+ "nbformat_minor": 2
70
+ }
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- jupyterlab==4.2.5
2
- tornado==6.2
3
- ipywidgets
 
1
+ bpy==4.2.0
2
+ solara
3
+ #anywidget_3dviewer
start_server.sh DELETED
@@ -1,19 +0,0 @@
1
- #!/bin/bash
2
- JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
3
-
4
- NOTEBOOK_DIR="/data"
5
-
6
- jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
7
-
8
- jupyter-lab \
9
- --ip 0.0.0.0 \
10
- --port 7860 \
11
- --no-browser \
12
- --allow-root \
13
- --ServerApp.token="$JUPYTER_TOKEN" \
14
- --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
15
- --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
16
- --ServerApp.disable_check_xsrf=True \
17
- --LabApp.news_url=None \
18
- --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
19
- --notebook-dir=$NOTEBOOK_DIR