Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,16 @@ from transformers import pipeline
|
|
3 |
from diffusers import StableDiffusionPipeline
|
4 |
import torch
|
5 |
|
6 |
-
# Check for GPU availability
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
|
9 |
-
# Set appropriate dtype based on device
|
10 |
torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
11 |
|
12 |
-
#
|
13 |
@st.cache_resource
|
14 |
def load_sentiment_analyzer():
|
15 |
return pipeline("text-classification", model="SamLowe/roberta-base-go_emotions", top_k=5, device=device)
|
16 |
|
17 |
-
#
|
18 |
@st.cache_resource
|
19 |
def load_text2img():
|
20 |
model = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch_dtype, safety_checker = None, requires_safety_checker = False)
|
|
|
3 |
from diffusers import StableDiffusionPipeline
|
4 |
import torch
|
5 |
|
|
|
6 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
|
|
|
8 |
torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
9 |
|
10 |
+
# Sentiment Analysis Model
|
11 |
@st.cache_resource
|
12 |
def load_sentiment_analyzer():
|
13 |
return pipeline("text-classification", model="SamLowe/roberta-base-go_emotions", top_k=5, device=device)
|
14 |
|
15 |
+
# Text-to-image model
|
16 |
@st.cache_resource
|
17 |
def load_text2img():
|
18 |
model = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch_dtype, safety_checker = None, requires_safety_checker = False)
|