Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,37 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
|
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
|
7 |
-
model = GPT2LMHeadModel.from_pretrained(model_name)
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
# Decode the generated text
|
17 |
-
text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
18 |
-
return text
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
-
if st.button("Generate"):
|
27 |
-
|
28 |
-
|
29 |
-
st.write(generated_text)
|
|
|
1 |
import streamlit as st
|
2 |
+
from text_generation import generate_text
|
3 |
+
from image_generation import generate_image_from_text
|
4 |
+
from video_generation import generate_simple_video
|
5 |
+
from PIL import Image
|
6 |
|
7 |
+
# Main Streamlit app
|
8 |
+
st.title("Multifunction AI App")
|
|
|
|
|
9 |
|
10 |
+
# Ability Selection
|
11 |
+
option = st.sidebar.selectbox("Select Functionality", ("Text Generation", "Image Generation", "Video Generation"))
|
12 |
+
|
13 |
+
# Text Generation
|
14 |
+
if option == "Text Generation":
|
15 |
+
prompt = st.text_area("Input", "Type a prompt for text generation...")
|
16 |
+
max_length = st.slider("Max Length", min_value=10, max_value=100, value=50)
|
|
|
|
|
|
|
17 |
|
18 |
+
if st.button("Generate Text"):
|
19 |
+
generated_text = generate_text(prompt, max_length)
|
20 |
+
st.subheader("Generated Text")
|
21 |
+
st.write(generated_text)
|
22 |
+
|
23 |
+
# Image Generation
|
24 |
+
elif option == "Image Generation":
|
25 |
+
prompt = st.text_area("Input", "Type a prompt for image generation...")
|
26 |
+
|
27 |
+
if st.button("Generate Image"):
|
28 |
+
image = generate_image_from_text(prompt)
|
29 |
+
st.image(image, caption="Generated Image", use_column_width=True)
|
30 |
|
31 |
+
# Video Generation
|
32 |
+
elif option == "Video Generation":
|
33 |
+
prompt = st.text_area("Input", "Type a prompt for video generation...")
|
34 |
|
35 |
+
if st.button("Generate Video"):
|
36 |
+
video_path = generate_simple_video(prompt)
|
37 |
+
st.video(video_path)
|
|