aahmed10202 commited on
Commit
9217d81
·
verified ·
1 Parent(s): 01602dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -2,8 +2,12 @@ import torch
2
  import streamlit as st
3
  from diffusers import DiffusionPipeline
4
 
5
- # Load the pre-trained Stable Diffusion model
 
 
 
6
  pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
 
7
 
8
  # Title and description
9
  st.markdown('<div class="title">🔥 Memeify - Text-to-Meme Generator 🔥</div>', unsafe_allow_html=True)
@@ -23,3 +27,4 @@ if st.button("Generate Meme", key="generate", help="Click to generate a meme fro
23
  st.image(image, caption=f"Meme: {input_text}", use_column_width=True)
24
  else:
25
  st.warning("Please enter a description to generate a meme.")
 
 
2
  import streamlit as st
3
  from diffusers import DiffusionPipeline
4
 
5
+ # Hugging Face Spaces may not always have GPU, so we'll check if it's available
6
+ device = "cuda" if torch.cuda.is_available() else "cpu"
7
+
8
+ # Load the pre-trained Stable Diffusion model and move it to the correct device
9
  pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
10
+ pipe.to(device)
11
 
12
  # Title and description
13
  st.markdown('<div class="title">🔥 Memeify - Text-to-Meme Generator 🔥</div>', unsafe_allow_html=True)
 
27
  st.image(image, caption=f"Meme: {input_text}", use_column_width=True)
28
  else:
29
  st.warning("Please enter a description to generate a meme.")
30
+