tombetthauser commited on
Commit
7ca5f13
Β·
1 Parent(s): d16b6a3

Try readding canny with imports only

Browse files
Files changed (1) hide show
  1. app.py +30 -31
app.py CHANGED
@@ -375,46 +375,45 @@ 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 = gr.TabbedInterface([new_welcome, advanced_tab, beta], ["Artists", "Advanced", "Beta"])
420
  tabbed_interface.launch()
 
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
+ output_image = input_image # For example, just return the input image
388
+ numpy_image = np.array(output_image)
389
+ # Return the processed image
390
 
391
+ # low_threshold = 100
392
+ # high_threshold = 200
393
+ canny_1 = cv2.Canny(numpy_image, input_low_threshold, input_high_threshold)
394
+ canny_1 = canny_1[:, :, None]
395
+ canny_1 = np.concatenate([canny_1, canny_1, canny_1], axis=2)
396
+ if input_invert:
397
+ canny_1 = 255 - canny_1
398
+ canny_2 = Image.fromarray(canny_1)
399
 
400
+ return np.array(canny_2)
401
 
402
+ # Define the input and output interfaces
403
+ canny_input_image = gr.inputs.Image()
404
+ canny_input_low_threshold = gr.inputs.Slider(minimum=0, maximum=1000, step=1, label="Lower Threshold:", default=100)
405
+ canny_input_high_threshold = gr.inputs.Slider(minimum=0, maximum=1000, step=1, label="Upper Threshold:", default=200)
406
+ canny_input_invert = gr.inputs.Checkbox(label="Invert Image")
407
 
408
+ canny_outputs = gr.outputs.Image(type="numpy")
409
 
410
+ # Create the Gradio interface
411
+ 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')
412
 
413
 
414
 
415
  # ----- Launch Tabs -----------------------------------------------------------------
416
 
417
+ tabbed_interface = gr.TabbedInterface([new_welcome, advanced_tab, beta, canny_interface], ["Artists", "Advanced", "Beta", "Edges"])
418
+ # tabbed_interface = gr.TabbedInterface([new_welcome, advanced_tab, beta], ["Artists", "Advanced", "Beta"])
419
  tabbed_interface.launch()