tuan2308 commited on
Commit
83d1a88
1 Parent(s): 7a9df1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,10 +1,10 @@
 
1
  import os
2
  import gc
3
  import gradio as gr
4
  import numpy as np
5
  import torch
6
  import json
7
- import spaces
8
  import config
9
  import utils
10
  import logging
@@ -21,7 +21,7 @@ if not torch.cuda.is_available():
21
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU. </p>"
22
  IS_COLAB = utils.is_google_colab() or os.getenv("IS_COLAB") == "1"
23
  HF_TOKEN = os.getenv("HF_TOKEN")
24
- CACHE_EXAMPLES = 'lazy' if torch.cuda.is_available() and os.getenv("CACHE_EXAMPLES") == "1" else False
25
  MIN_IMAGE_SIZE = int(os.getenv("MIN_IMAGE_SIZE", "512"))
26
  MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "2048"))
27
  USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE") == "1"
@@ -30,11 +30,12 @@ OUTPUT_DIR = os.getenv("OUTPUT_DIR", "./outputs")
30
 
31
  MODEL = os.getenv(
32
  "MODEL",
33
- "https://huggingface.co/cagliostrolab/animagine-xl-3.1/blob/main/animagine-xl-3.1.safetensors",
34
  )
35
 
36
  torch.backends.cudnn.deterministic = True
37
  torch.backends.cudnn.benchmark = False
 
38
 
39
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
40
 
@@ -49,7 +50,7 @@ def load_pipeline(model_name):
49
  if MODEL.endswith(".safetensors")
50
  else StableDiffusionXLPipeline.from_pretrained
51
  )
52
-
53
  pipe = pipeline(
54
  model_name,
55
  vae=vae,
@@ -392,4 +393,4 @@ with gr.Blocks(css="style.css", theme="NoCrypt/[email protected]") as demo:
392
  )
393
 
394
  if __name__ == "__main__":
395
- demo.queue(max_size=20).launch(debug=IS_COLAB, share=IS_COLAB)
 
1
+ import spaces
2
  import os
3
  import gc
4
  import gradio as gr
5
  import numpy as np
6
  import torch
7
  import json
 
8
  import config
9
  import utils
10
  import logging
 
21
  DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU. </p>"
22
  IS_COLAB = utils.is_google_colab() or os.getenv("IS_COLAB") == "1"
23
  HF_TOKEN = os.getenv("HF_TOKEN")
24
+ CACHE_EXAMPLES = torch.cuda.is_available() and os.getenv("CACHE_EXAMPLES") == "0"
25
  MIN_IMAGE_SIZE = int(os.getenv("MIN_IMAGE_SIZE", "512"))
26
  MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "2048"))
27
  USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE") == "1"
 
30
 
31
  MODEL = os.getenv(
32
  "MODEL",
33
+ "cagliostrolab/animagine-xl-3.1",
34
  )
35
 
36
  torch.backends.cudnn.deterministic = True
37
  torch.backends.cudnn.benchmark = False
38
+ torch.backends.cuda.matmul.allow_tf32 = True
39
 
40
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
41
 
 
50
  if MODEL.endswith(".safetensors")
51
  else StableDiffusionXLPipeline.from_pretrained
52
  )
53
+
54
  pipe = pipeline(
55
  model_name,
56
  vae=vae,
 
393
  )
394
 
395
  if __name__ == "__main__":
396
+ demo.queue(max_size=20).launch(debug=IS_COLAB, share=IS_COLAB)