Update app.py
Browse files
app.py
CHANGED
@@ -63,14 +63,20 @@ def inference(prompt, guidance, steps, width=512, height=512, seed=0, img=None,
|
|
63 |
except Exception as e:
|
64 |
return None, error_str(e)
|
65 |
|
66 |
-
def
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
def txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator):
|
70 |
|
71 |
result = pipe(
|
72 |
prompt,
|
73 |
-
check_safety = dummy,
|
74 |
negative_prompt = neg_prompt,
|
75 |
num_inference_steps = int(steps),
|
76 |
guidance_scale = guidance,
|
|
|
63 |
except Exception as e:
|
64 |
return None, error_str(e)
|
65 |
|
66 |
+
def check_safety(x_image):
|
67 |
+
# safety_checker_input = safety_feature_extractor(numpy_to_pil(x_image), return_tensors="pt")
|
68 |
+
# x_checked_image, has_nsfw_concept = safety_checker(images=x_image, clip_input=safety_checker_input.pixel_values)
|
69 |
+
# x_checked_image = x_image
|
70 |
+
# assert x_checked_image.shape[0] == len(has_nsfw_concept)
|
71 |
+
# for i in range(len(has_nsfw_concept)):
|
72 |
+
# if has_nsfw_concept[i]:
|
73 |
+
# x_checked_image[i] = load_replacement(x_checked_image[i])
|
74 |
+
return x_image, False # has_nsfw_concept
|
75 |
|
76 |
def txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator):
|
77 |
|
78 |
result = pipe(
|
79 |
prompt,
|
|
|
80 |
negative_prompt = neg_prompt,
|
81 |
num_inference_steps = int(steps),
|
82 |
guidance_scale = guidance,
|