jutaporn37678 commited on
Commit
885b90a
1 Parent(s): 8c372d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -4,4 +4,25 @@ def greet(name):
4
  return "results " + name + "!!"
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  return "results " + name + "!!"
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ iface.launch()
8
+
9
+ #When running locally, you won`t have access to this, so you can remove this part
10
+ word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt", use_auth_token=True)
11
+ word_list = word_list_dataset["train"]['text']
12
+
13
+ is_gpu_busy = False
14
+ def infer(prompt):
15
+ global is_gpu_busy
16
+ samples = 4
17
+ steps = 50
18
+ scale = 7.5
19
+ #When running locally you can also remove this filter
20
+ for filter in word_list:
21
+ if re.search(rf"\b{filter}\b", prompt):
22
+ raise gr.Error("Unsafe content found. Please try again with different prompts.")
23
+
24
+ #generator = torch.Generator(device=device).manual_seed(seed)
25
+ #print("Is GPU busy? ", is_gpu_busy)
26
+ images = []
27
+ #if(not is_gpu_busy):
28
+ # is_gpu_busy = True