-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.py
50 lines (31 loc) · 1.39 KB
/
interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import streamlit as st
from yume import Yume
from yume.config import yume_small
def main():
st.set_page_config(page_title="夢の生成器", page_icon="🌙", layout="wide")
st.title("夢の生成器")
st.write("Welcome to our Dream Generator! 🌙")
st.sidebar.header("Select a Dream Theme")
theme = st.sidebar.selectbox(
"Choose a theme", ["Fantasy", "Adventure", "Romance", "Horror"]
)
st.sidebar.header("Customize Your Dream")
prompt = st.sidebar.text_input("Enter a prompt or keyword")
num_sentences = st.sidebar.slider("Number of sentences to generate", 1, 10, 5)
temperature = st.sidebar.slider("Creativity of LLM (Temperature)", 0.1, 1.0, 0.5)
generate_button = st.sidebar.button("Generate Dream")
st.header("Your Dream")
if generate_button:
with st.spinner("Generating dream..."):
dream_text = generate_dream_text(theme, prompt, num_sentences, temperature)
st.text_area("", value=dream_text, height=600)
else:
st.text_area("", height=600, placeholder="Your dream will appear here...")
def generate_dream_text(theme, prompt, num_sentences, temperature):
yume = Yume(config=yume_small)
yume.load_pretrained("zaibutcooler/yume")
full_prompt = f"{theme} - {prompt}"
# Generate text using the Yume model
return yume.sample(full_prompt)
if __name__ == "__main__":
main()