tombetthauser commited on
Commit
a068157
Β·
1 Parent(s): 8a71431

Re-Added bad words filter for spam / bot traffic

Browse files
Files changed (1) hide show
  1. app.py +30 -29
app.py CHANGED
@@ -45,7 +45,7 @@ my_token = os.environ['api_key']
45
  pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", revision="fp16", torch_dtype=torch.float16, use_auth_token=my_token).to("cuda")
46
 
47
  def check_prompt(prompt):
48
- SPAM_WORDS = [] # phasing this out
49
  for spam_word in SPAM_WORDS:
50
  if spam_word in prompt:
51
  return False
@@ -375,45 +375,46 @@ with gr.Blocks() as beta:
375
 
376
  # ----- Canny Edge Tab -----------------------------------------------------------------
377
 
378
- from PIL import Image
379
  # import gradio as gr
380
- import numpy as np
381
- import cv2
382
 
383
- # Define a function to process the uploaded image
384
- def canny_process_image(input_image, input_low_threshold, input_high_threshold, input_invert):
385
- # Convert the input image to a NumPy array
386
- np_image = np.array(input_image)
387
 
388
- output_image = input_image # For example, just return the input image
389
- numpy_image = np.array(output_image)
390
- # Return the processed image
391
 
392
- low_threshold = 100
393
- high_threshold = 200
394
- canny_1 = cv2.Canny(numpy_image, input_low_threshold, input_high_threshold)
395
- canny_1 = canny_1[:, :, None]
396
- canny_1 = np.concatenate([canny_1, canny_1, canny_1], axis=2)
397
- if input_invert:
398
- canny_1 = 255 - canny_1
399
- canny_2 = Image.fromarray(canny_1)
400
 
401
- return np.array(canny_2)
402
 
403
- # Define the input and output interfaces
404
- canny_input_image = gr.inputs.Image()
405
- canny_input_low_threshold = gr.inputs.Slider(minimum=0, maximum=1000, step=1, label="Lower Threshold:", default=100)
406
- canny_input_high_threshold = gr.inputs.Slider(minimum=0, maximum=1000, step=1, label="Upper Threshold:", default=200)
407
- canny_input_invert = gr.inputs.Checkbox(label="Invert Image")
408
 
409
- canny_outputs = gr.outputs.Image(type="numpy")
410
 
411
- # Create the Gradio interface
412
- canny_interface = gr.Interface(fn=canny_process_image, inputs=[canny_input_image, canny_input_low_threshold, canny_input_high_threshold, canny_input_invert], outputs=canny_outputs, title='Canny Edge Tracing', allow_flagging='never')
413
 
414
 
415
 
416
  # ----- Launch Tabs -----------------------------------------------------------------
417
 
418
- tabbed_interface = gr.TabbedInterface([new_welcome, advanced_tab, beta, canny_interface], ["Artists", "Advanced", "Beta", "Edges"])
 
419
  tabbed_interface.launch()
 
45
  pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", revision="fp16", torch_dtype=torch.float16, use_auth_token=my_token).to("cuda")
46
 
47
  def check_prompt(prompt):
48
+ SPAM_WORDS = ['Π”', 'boob', 'boobs', 'breast', 'breasts'] # phasing this out
49
  for spam_word in SPAM_WORDS:
50
  if spam_word in prompt:
51
  return False
 
375
 
376
  # ----- Canny Edge Tab -----------------------------------------------------------------
377
 
378
+ # from PIL import Image
379
  # import gradio as gr
380
+ # import numpy as np
381
+ # import cv2
382
 
383
+ # # Define a function to process the uploaded image
384
+ # def canny_process_image(input_image, input_low_threshold, input_high_threshold, input_invert):
385
+ # # Convert the input image to a NumPy array
386
+ # np_image = np.array(input_image)
387
 
388
+ # output_image = input_image # For example, just return the input image
389
+ # numpy_image = np.array(output_image)
390
+ # # Return the processed image
391
 
392
+ # low_threshold = 100
393
+ # high_threshold = 200
394
+ # canny_1 = cv2.Canny(numpy_image, input_low_threshold, input_high_threshold)
395
+ # canny_1 = canny_1[:, :, None]
396
+ # canny_1 = np.concatenate([canny_1, canny_1, canny_1], axis=2)
397
+ # if input_invert:
398
+ # canny_1 = 255 - canny_1
399
+ # canny_2 = Image.fromarray(canny_1)
400
 
401
+ # return np.array(canny_2)
402
 
403
+ # # Define the input and output interfaces
404
+ # canny_input_image = gr.inputs.Image()
405
+ # canny_input_low_threshold = gr.inputs.Slider(minimum=0, maximum=1000, step=1, label="Lower Threshold:", default=100)
406
+ # canny_input_high_threshold = gr.inputs.Slider(minimum=0, maximum=1000, step=1, label="Upper Threshold:", default=200)
407
+ # canny_input_invert = gr.inputs.Checkbox(label="Invert Image")
408
 
409
+ # canny_outputs = gr.outputs.Image(type="numpy")
410
 
411
+ # # Create the Gradio interface
412
+ # canny_interface = gr.Interface(fn=canny_process_image, inputs=[canny_input_image, canny_input_low_threshold, canny_input_high_threshold, canny_input_invert], outputs=canny_outputs, title='Canny Edge Tracing', allow_flagging='never')
413
 
414
 
415
 
416
  # ----- Launch Tabs -----------------------------------------------------------------
417
 
418
+ # tabbed_interface = gr.TabbedInterface([new_welcome, advanced_tab, beta, canny_interface], ["Artists", "Advanced", "Beta", "Edges"])
419
+ tabbed_interface = gr.TabbedInterface([new_welcome, advanced_tab, beta], ["Artists", "Advanced", "Beta"])
420
  tabbed_interface.launch()