Thafx commited on
Commit
d0dc466
1 Parent(s): afd9f43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -62,21 +62,14 @@ def inference(prompt, guidance, steps, width=512, height=512, seed=0, img=None,
62
  return txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator), None
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,
@@ -92,7 +85,7 @@ def img_to_img(prompt, neg_prompt, img, strength, guidance, steps, width, height
92
  img = img.resize((int(img.width * ratio), int(img.height * ratio)), Image.LANCZOS)
93
  result = pipe_i2i(
94
  prompt,
95
- check_safety = dummy,
96
  negative_prompt = neg_prompt,
97
  init_image = img,
98
  num_inference_steps = int(steps),
 
62
  return txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator), None
63
  except Exception as e:
64
  return None, error_str(e)
65
+
66
+ def dummy(images, **kwargs): return result.images,False
67
 
 
 
 
 
 
 
 
 
 
 
68
  def txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator):
69
 
70
  result = pipe(
71
  prompt,
72
+ pipe.safety_checker = dummy,
73
  negative_prompt = neg_prompt,
74
  num_inference_steps = int(steps),
75
  guidance_scale = guidance,
 
85
  img = img.resize((int(img.width * ratio), int(img.height * ratio)), Image.LANCZOS)
86
  result = pipe_i2i(
87
  prompt,
88
+ pipe.safety_checker = dummy,
89
  negative_prompt = neg_prompt,
90
  init_image = img,
91
  num_inference_steps = int(steps),