Spaces:
Running
Running
Add example to Gradio app
Browse files- .gitignore +1 -1
- app.py +14 -2
- notes.txt → examples/notes.txt +0 -0
- examples/potatoes_and_molasses.mid +0 -0
.gitignore
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
.venv
|
| 2 |
.idea
|
| 3 |
-
|
| 4 |
*.scad
|
| 5 |
__pycache__
|
| 6 |
notes_*.txt
|
|
|
|
| 1 |
.venv
|
| 2 |
.idea
|
| 3 |
+
/*.mid
|
| 4 |
*.scad
|
| 5 |
__pycache__
|
| 6 |
notes_*.txt
|
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import io
|
| 2 |
import os
|
|
|
|
| 3 |
import tempfile
|
| 4 |
|
| 5 |
import gradio
|
|
@@ -9,7 +10,7 @@ from midi_convert import convert_midi_to_scad, InternalStructureType
|
|
| 9 |
temporary_directory = tempfile.TemporaryDirectory()
|
| 10 |
|
| 11 |
OPENSCAD_BINARY = os.getenv('OPENSCAD_BINARY', 'openscad')
|
| 12 |
-
with open('notes.txt') as f:
|
| 13 |
DEFAULT_NOTES = f.read()
|
| 14 |
|
| 15 |
|
|
@@ -43,6 +44,16 @@ article = '''
|
|
| 43 |
</p>
|
| 44 |
'''
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
iface = gradio.Interface(
|
| 48 |
fn=run_app,
|
|
@@ -67,9 +78,10 @@ iface = gradio.Interface(
|
|
| 67 |
(v.value.title(), v) for _, v in
|
| 68 |
InternalStructureType.__members__.items()
|
| 69 |
],
|
| 70 |
-
value=InternalStructureType.HOLLOW,
|
| 71 |
)
|
| 72 |
],
|
| 73 |
outputs=[gradio.Model3D()],
|
|
|
|
| 74 |
allow_flagging='never',
|
| 75 |
).launch(debug=True, show_error=True)
|
|
|
|
| 1 |
import io
|
| 2 |
import os
|
| 3 |
+
import pathlib
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
import gradio
|
|
|
|
| 10 |
temporary_directory = tempfile.TemporaryDirectory()
|
| 11 |
|
| 12 |
OPENSCAD_BINARY = os.getenv('OPENSCAD_BINARY', 'openscad')
|
| 13 |
+
with open('examples/notes.txt') as f:
|
| 14 |
DEFAULT_NOTES = f.read()
|
| 15 |
|
| 16 |
|
|
|
|
| 44 |
</p>
|
| 45 |
'''
|
| 46 |
|
| 47 |
+
examples_root = pathlib.Path(__file__).parent.joinpath("examples")
|
| 48 |
+
|
| 49 |
+
examples = [
|
| 50 |
+
[
|
| 51 |
+
str(examples_root.joinpath("potatoes_and_molasses.mid")),
|
| 52 |
+
DEFAULT_NOTES,
|
| 53 |
+
'RIBS',
|
| 54 |
+
],
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
|
| 58 |
iface = gradio.Interface(
|
| 59 |
fn=run_app,
|
|
|
|
| 78 |
(v.value.title(), v) for _, v in
|
| 79 |
InternalStructureType.__members__.items()
|
| 80 |
],
|
| 81 |
+
value=InternalStructureType.HOLLOW.value,
|
| 82 |
)
|
| 83 |
],
|
| 84 |
outputs=[gradio.Model3D()],
|
| 85 |
+
examples=examples,
|
| 86 |
allow_flagging='never',
|
| 87 |
).launch(debug=True, show_error=True)
|
notes.txt → examples/notes.txt
RENAMED
|
File without changes
|
examples/potatoes_and_molasses.mid
ADDED
|
Binary file (682 Bytes). View file
|
|
|