wemab39501 commited on
Commit
45d6f90
1 Parent(s): e8b8fc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
- #import torch
3
  #from torch import autocast
4
- #from diffusers import StableDiffusionPipeline
5
  from datasets import load_dataset
6
  from PIL import Image
7
  #from io import BytesIO
@@ -17,9 +17,9 @@ model_id = "CompVis/stable-diffusion-v1-4"
17
  device = "cuda"
18
 
19
  #If you are running this code locally, you need to either do a 'huggingface-cli login` or paste your User Access Token from here https://huggingface.co/settings/tokens into the use_auth_token field below.
20
- #pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True, revision="fp16", torch_dtype=torch.float16)
21
- #pipe = pipe.to(device)
22
- #torch.backends.cudnn.benchmark = True
23
 
24
  ##When running locally, you won`t have access to this, so you can remove this part
25
  #word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt", use_auth_token=True)
@@ -31,10 +31,10 @@ def infer(prompt):
31
  samples = 4
32
  steps = 50
33
  scale = 7.5
34
- #When running locally you can also remove this filter
35
- for filter in word_list:
36
- if re.search(rf"\b{filter}\b", prompt):
37
- raise gr.Error("Unsafe content found. Please try again with different prompts.")
38
 
39
  #generator = torch.Generator(device=device).manual_seed(seed)
40
  #print("Is GPU busy? ", is_gpu_busy)
 
1
  import gradio as gr
2
+ import torch
3
  #from torch import autocast
4
+ from diffusers import StableDiffusionPipeline
5
  from datasets import load_dataset
6
  from PIL import Image
7
  #from io import BytesIO
 
17
  device = "cuda"
18
 
19
  #If you are running this code locally, you need to either do a 'huggingface-cli login` or paste your User Access Token from here https://huggingface.co/settings/tokens into the use_auth_token field below.
20
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True, revision="fp16", torch_dtype=torch.float16)
21
+ pipe = pipe.to(device)
22
+ torch.backends.cudnn.benchmark = True
23
 
24
  ##When running locally, you won`t have access to this, so you can remove this part
25
  #word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt", use_auth_token=True)
 
31
  samples = 4
32
  steps = 50
33
  scale = 7.5
34
+ ##When running locally you can also remove this filter
35
+ #for filter in word_list:
36
+ # if re.search(rf"\b{filter}\b", prompt):
37
+ # raise gr.Error("Unsafe content found. Please try again with different prompts.")
38
 
39
  #generator = torch.Generator(device=device).manual_seed(seed)
40
  #print("Is GPU busy? ", is_gpu_busy)