Spaces:
Runtime error
Runtime error
add pages mode
Browse files
app.py
CHANGED
@@ -1,8 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from pathlib import Path
|
2 |
import sys
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
from riffusion.streamlit.pages.text_to_audio import render_text_to_audio
|
7 |
|
8 |
-
|
|
|
1 |
+
"""
|
2 |
+
Shim layer for using the riffusion playground streamlit app with huggingface spaces.
|
3 |
+
|
4 |
+
It doesn't support the pages feature of streamlit yet.
|
5 |
+
"""
|
6 |
+
import importlib
|
7 |
from pathlib import Path
|
8 |
import sys
|
9 |
|
10 |
+
import streamlit as st
|
11 |
+
|
12 |
+
|
13 |
+
def render_main():
|
14 |
+
RIFFUSION_PATH = Path(__file__).parent / "riffusion"
|
15 |
+
sys.path.append(str(RIFFUSION_PATH))
|
16 |
+
|
17 |
+
st.set_page_config(layout="wide", page_icon="🎸")
|
18 |
+
|
19 |
+
# Disable the rest of the setting
|
20 |
+
st.set_page_config = lambda **kwargs: None
|
21 |
+
|
22 |
+
# Find all pages in the riffusion directory
|
23 |
+
pages = sorted(
|
24 |
+
p.name[:-3] for p in (RIFFUSION_PATH / "riffusion" / "streamlit" / "pages").glob("*.py")
|
25 |
+
)
|
26 |
+
|
27 |
+
# Add the pages to the sidebar
|
28 |
+
page = st.sidebar.selectbox("Page", pages)
|
29 |
+
assert page is not None
|
30 |
+
|
31 |
+
module = importlib.import_module(f"riffusion.streamlit.pages.{page}")
|
32 |
+
render_func = getattr(module, f"render_{page}")
|
33 |
+
render_func()
|
34 |
|
|
|
35 |
|
36 |
+
render_main()
|