Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,17 @@ import torch
|
|
2 |
import streamlit as st
|
3 |
from diffusers import StableDiffusion3Pipeline
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
|
|
|
|
|
10 |
|
11 |
def generate_prompt(prompt_text):
|
12 |
# Generate response using the Diffusion model
|
@@ -32,4 +38,3 @@ def main():
|
|
32 |
if __name__ == '__main__':
|
33 |
main()
|
34 |
|
35 |
-
|
|
|
2 |
import streamlit as st
|
3 |
from diffusers import StableDiffusion3Pipeline
|
4 |
|
5 |
+
# Retry mechanism for loading the model
|
6 |
+
def retry_load_model():
|
7 |
+
try:
|
8 |
+
return StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)
|
9 |
+
except EnvironmentError as e:
|
10 |
+
st.error(f"Error loading model: {e}")
|
11 |
+
st.warning("Retrying to load the model...")
|
12 |
+
retry_load_model()
|
13 |
|
14 |
+
# Load the Diffusion pipeline
|
15 |
+
pipeline = retry_load_model()
|
16 |
|
17 |
def generate_prompt(prompt_text):
|
18 |
# Generate response using the Diffusion model
|
|
|
38 |
if __name__ == '__main__':
|
39 |
main()
|
40 |
|
|