Spaces:
Running
on
A10G
Running
on
A10G
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,18 @@ import re
|
|
7 |
from gradio_client import Client
|
8 |
|
9 |
is_shared_ui = True if "fffiloni/consistent-character" in os.environ['SPACE_ID'] else False
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
from utils.gradio_helpers import parse_outputs, process_outputs
|
12 |
|
13 |
names = ['prompt', 'negative_prompt', 'subject', 'number_of_outputs', 'number_of_images_per_pose', 'randomise_poses', 'output_format', 'output_quality', 'seed']
|
@@ -23,31 +34,21 @@ def predict(request: gr.Request, *args, progress=gr.Progress(track_tqdm=True)):
|
|
23 |
try:
|
24 |
if is_shared_ui:
|
25 |
hf_token = os.environ.get("HF_TOKEN")
|
26 |
-
|
27 |
-
def safety_check(user_prompt):
|
28 |
-
|
29 |
-
client = Client("fffiloni/safety-checker-bot", hf_token=hf_token)
|
30 |
-
response = client.predict(
|
31 |
-
source_space="consistent-character space",
|
32 |
-
user_prompt=user_prompt,
|
33 |
-
api_name="/infer"
|
34 |
-
)
|
35 |
-
print(response)
|
36 |
-
|
37 |
-
return response
|
38 |
-
|
39 |
is_safe = safety_check(args[0])
|
40 |
print(is_safe)
|
41 |
-
|
42 |
match = re.search(r'\bYes\b', is_safe)
|
43 |
-
|
44 |
if match:
|
45 |
status = 'Yes'
|
46 |
else:
|
47 |
status = None
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
else:
|
52 |
|
53 |
headers = {'Content-Type': 'application/json'}
|
|
|
7 |
from gradio_client import Client
|
8 |
|
9 |
is_shared_ui = True if "fffiloni/consistent-character" in os.environ['SPACE_ID'] else False
|
10 |
+
def safety_check(user_prompt):
|
11 |
+
|
12 |
+
client = Client("fffiloni/safety-checker-bot", hf_token=hf_token)
|
13 |
+
response = client.predict(
|
14 |
+
source_space="consistent-character space",
|
15 |
+
user_prompt=user_prompt,
|
16 |
+
api_name="/infer"
|
17 |
+
)
|
18 |
+
print(response)
|
19 |
+
|
20 |
+
return response
|
21 |
+
|
22 |
from utils.gradio_helpers import parse_outputs, process_outputs
|
23 |
|
24 |
names = ['prompt', 'negative_prompt', 'subject', 'number_of_outputs', 'number_of_images_per_pose', 'randomise_poses', 'output_format', 'output_quality', 'seed']
|
|
|
34 |
try:
|
35 |
if is_shared_ui:
|
36 |
hf_token = os.environ.get("HF_TOKEN")
|
37 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
is_safe = safety_check(args[0])
|
39 |
print(is_safe)
|
40 |
+
|
41 |
match = re.search(r'\bYes\b', is_safe)
|
42 |
+
|
43 |
if match:
|
44 |
status = 'Yes'
|
45 |
else:
|
46 |
status = None
|
47 |
+
else:
|
48 |
+
status = None
|
49 |
+
|
50 |
+
if status == "Yes" :
|
51 |
+
raise gr.Error("Do not ask for such things.")
|
52 |
else:
|
53 |
|
54 |
headers = {'Content-Type': 'application/json'}
|