ChenWu98 commited on
Commit
3728d9c
•
1 Parent(s): 6d4c3f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -3,7 +3,6 @@ import gradio as gr
3
  import torch
4
  from PIL import Image
5
  import utils
6
- import streamlit as st
7
  import ptp_utils
8
  import seq_aligner
9
  import torch.nn.functional as nnf
@@ -16,18 +15,18 @@ MAX_NUM_WORDS = 77
16
  is_colab = utils.is_google_colab()
17
 
18
 
19
- if True:
20
- model_id_or_path = "CompVis/stable-diffusion-v1-4"
21
- scheduler = DDIMScheduler.from_config(model_id_or_path,
22
- use_auth_token=st.secrets["USER_TOKEN"],
23
- subfolder="scheduler")
24
- pipe = CycleDiffusionPipeline.from_pretrained(model_id_or_path,
25
- use_auth_token=st.secrets["USER_TOKEN"],
26
- scheduler=scheduler)
27
- tokenizer = pipe.tokenizer
28
 
29
- if torch.cuda.is_available():
30
- pipe = pipe.to("cuda")
31
 
32
  device_print = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
33
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
3
  import torch
4
  from PIL import Image
5
  import utils
 
6
  import ptp_utils
7
  import seq_aligner
8
  import torch.nn.functional as nnf
 
15
  is_colab = utils.is_google_colab()
16
 
17
 
18
+ model_id_or_path = "CompVis/stable-diffusion-v1-4"
19
+ if is_colab:
20
+ scheduler = DDIMScheduler.from_config(model_id_or_path, subfolder="scheduler")
21
+ pipe = CycleDiffusionPipeline.from_pretrained(model_id_or_path, scheduler=scheduler)
22
+ else:
23
+ import streamlit as st
24
+ scheduler = DDIMScheduler.from_config(model_id_or_path, use_auth_token=st.secrets["USER_TOKEN"], subfolder="scheduler")
25
+ pipe = CycleDiffusionPipeline.from_pretrained(model_id_or_path, use_auth_token=st.secrets["USER_TOKEN"], scheduler=scheduler)
26
+ tokenizer = pipe.tokenizer
27
 
28
+ if torch.cuda.is_available():
29
+ pipe = pipe.to("cuda")
30
 
31
  device_print = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
32
  device = "cuda" if torch.cuda.is_available() else "cpu"