Spaces:
Running
Running
Shabbir-Anjum
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,31 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import
|
3 |
|
4 |
-
# Load the Diffusion pipeline
|
5 |
-
|
6 |
|
7 |
def generate_prompt(prompt_text):
|
8 |
# Generate response using the Diffusion model
|
9 |
-
response =
|
10 |
return response
|
11 |
|
12 |
-
|
13 |
-
st.title('Diffusion Model Prompt Generator')
|
14 |
-
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
#
|
19 |
-
if st.button(
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load the Diffusion pipeline for text generation
|
5 |
+
generator = pipeline("text-generation", model="stabilityai/stable-diffusion-3-medium")
|
6 |
|
7 |
def generate_prompt(prompt_text):
|
8 |
# Generate response using the Diffusion model
|
9 |
+
response = generator(prompt_text, top_p=0.9, max_length=100)[0]['generated_text']
|
10 |
return response
|
11 |
|
12 |
+
def main():
|
13 |
+
st.title('Diffusion Model Prompt Generator')
|
14 |
+
|
15 |
+
# Text input for the prompt
|
16 |
+
prompt_text = st.text_area("Enter your prompt here:", height=200)
|
17 |
+
|
18 |
+
# Button to generate prompt
|
19 |
+
if st.button("Generate"):
|
20 |
+
if prompt_text:
|
21 |
+
with st.spinner('Generating...'):
|
22 |
+
generated_text = generate_prompt(prompt_text)
|
23 |
+
st.success('Generation complete!')
|
24 |
+
st.text_area('Generated Text:', value=generated_text, height=400)
|
25 |
+
else:
|
26 |
+
st.warning('Please enter a prompt.')
|
27 |
+
|
28 |
+
if __name__ == '__main__':
|
29 |
+
main()
|
30 |
|
31 |
|