Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
|
|
| 1 |
import torch
|
| 2 |
-
from diffusers import FluxPipeline
|
| 3 |
import streamlit as st
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
-
|
| 7 |
-
pipe
|
|
|
|
| 8 |
|
| 9 |
st.set_page_config(page_title="π₯ MemeForge - Text-to-Meme Generator π₯", page_icon="π₯", layout="wide")
|
|
|
|
|
|
|
| 10 |
st.markdown("""
|
| 11 |
<style>
|
| 12 |
.title {
|
|
@@ -54,28 +57,20 @@ st.markdown("""
|
|
| 54 |
|
| 55 |
st.markdown('<div class="title">π₯ MemeForge - Text-to-Meme Generator π₯</div>', unsafe_allow_html=True)
|
| 56 |
st.markdown('<div class="description">Enter a description, and the AI will generate a meme image for you!</div>', unsafe_allow_html=True)
|
|
|
|
| 57 |
input_text = st.text_input("Enter meme description:", key="input", placeholder="e.g., A funny dog looking confused.")
|
|
|
|
| 58 |
if st.button("Generate Meme", key="generate", help="Click to generate a meme from your description"):
|
| 59 |
if input_text:
|
| 60 |
modified_prompt = "MEME of an Image of " + input_text
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
height=1024,
|
| 65 |
-
width=1024,
|
| 66 |
-
guidance_scale=3.5,
|
| 67 |
-
num_inference_steps=50,
|
| 68 |
-
max_sequence_length=512,
|
| 69 |
-
generator=torch.Generator("cpu").manual_seed(0)
|
| 70 |
-
).images[0]
|
| 71 |
|
|
|
|
| 72 |
st.image(image, caption="Your Generated Meme", use_column_width=True)
|
| 73 |
|
| 74 |
# Save the image
|
| 75 |
image.save("generated_meme.png")
|
| 76 |
else:
|
| 77 |
st.warning("Please enter a description to generate a meme.")
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 1 |
+
from diffusers import StableDiffusionPipeline
|
| 2 |
import torch
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 8 |
+
pipe.to("cpu")
|
| 9 |
|
| 10 |
st.set_page_config(page_title="π₯ MemeForge - Text-to-Meme Generator π₯", page_icon="π₯", layout="wide")
|
| 11 |
+
|
| 12 |
+
# Custom styling for the page
|
| 13 |
st.markdown("""
|
| 14 |
<style>
|
| 15 |
.title {
|
|
|
|
| 57 |
|
| 58 |
st.markdown('<div class="title">π₯ MemeForge - Text-to-Meme Generator π₯</div>', unsafe_allow_html=True)
|
| 59 |
st.markdown('<div class="description">Enter a description, and the AI will generate a meme image for you!</div>', unsafe_allow_html=True)
|
| 60 |
+
|
| 61 |
input_text = st.text_input("Enter meme description:", key="input", placeholder="e.g., A funny dog looking confused.")
|
| 62 |
+
|
| 63 |
if st.button("Generate Meme", key="generate", help="Click to generate a meme from your description"):
|
| 64 |
if input_text:
|
| 65 |
modified_prompt = "MEME of an Image of " + input_text
|
| 66 |
|
| 67 |
+
# Generate image
|
| 68 |
+
image = pipe(modified_prompt, num_inference_steps=10).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
# Display the generated image
|
| 71 |
st.image(image, caption="Your Generated Meme", use_column_width=True)
|
| 72 |
|
| 73 |
# Save the image
|
| 74 |
image.save("generated_meme.png")
|
| 75 |
else:
|
| 76 |
st.warning("Please enter a description to generate a meme.")
|
|
|
|
|
|
|
|
|
|
|
|