Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,26 @@
|
|
1 |
-
import torch
|
2 |
import streamlit as st
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
|
8 |
-
# Load the pre-trained
|
9 |
-
pipe =
|
10 |
-
pipe.
|
11 |
|
12 |
-
#
|
13 |
-
st.
|
14 |
-
st.markdown('<div class="description">Enter a description, and the AI will generate a meme image for you!</div>', unsafe_allow_html=True)
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
|
19 |
-
#
|
20 |
-
if st.button("Generate Meme"
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
image = pipe(modified_prompt).images[0]
|
28 |
-
|
29 |
-
# Display the generated image in the Streamlit app
|
30 |
-
st.image(image, caption=f"Meme: {input_text}", use_column_width=True)
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
else:
|
35 |
-
st.warning("Please enter a description to generate a meme.")
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from diffusers import DiffusionPipeline
|
4 |
+
from PIL import Image
|
|
|
5 |
|
6 |
+
# Load the pre-trained model and LoRA weights
|
7 |
+
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
|
8 |
+
pipe.load_lora_weights("prithivMLmods/Flux-Meme-Xd-LoRA")
|
9 |
|
10 |
+
# Streamlit app
|
11 |
+
st.title("Memeify")
|
|
|
12 |
|
13 |
+
# Input field for the meme prompt
|
14 |
+
prompt = st.text_area("Enter your meme prompt:", "meme, A medium-sized painting of a white T-rex in the middle of a dark, stormy night. The t-rex is facing towards the left side of the frame, its head turned towards the right. Its mouth is open, revealing its sharp teeth. A rooster is standing in the foreground of the painting, with a red cap on its head. The roosters head is turned to the right, and the word \"Remember who you are\" is written in white text above it. The background is a deep blue, with dark gray clouds and a crescent moon in the upper left corner of the image. There are mountains in the background, and a few other animals can be seen in the lower right corner.")
|
15 |
|
16 |
+
# Button to generate the meme
|
17 |
+
if st.button("Generate Meme"):
|
18 |
+
with st.spinner("Generating meme..."):
|
19 |
+
# Generate the image using the provided prompt
|
20 |
+
image = pipe(prompt).images[0]
|
21 |
+
|
22 |
+
# Convert the image to PIL format
|
23 |
+
pil_image = Image.fromarray(image.astype('uint8'))
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
# Display the generated image
|
26 |
+
st.image(pil_image, caption="Generated Meme", use_column_width=True)
|
|
|
|