broyang commited on
Commit
fa2c390
·
1 Parent(s): 2d0e5bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import cv2
2
- import os
3
  import numpy as np
4
  from PIL import Image
5
  Image.MAX_IMAGE_PIXELS = None
@@ -25,24 +24,20 @@ def freemium_watermark(img, sb_logo):
25
 
26
  sb_logo = Image.open("./SB_logo_horizontal.png")
27
 
28
- examples = [
29
- os.path.join(os.path.dirname(__file__), "trailer.jpg"),
30
- os.path.join(os.path.dirname(__file__), "road.jpg"),
31
- ]
32
-
33
  with gr.Blocks() as demo:
34
  with gr.Row():
35
  with gr.Column():
36
- input = gr.Image(type="filepath", label="Upload Image", sources=["upload"])
37
  with gr.Column():
38
  image = gr.Image(label="Sketch Drawing", show_share_button=False)
39
- examples = gr.Examples(examples=["road.jpg", "trailer.jpg"], inputs=[input])
40
  @gr.on(inputs=[input], outputs=[image], show_progress="minimal")
41
  def sketch(input_path):
42
  if input_path is None:
43
  return None
44
- with Image.open(input_path) as img:
45
- img_array = np.array(img)
 
46
  # Line processing
47
  blurred = cv2.GaussianBlur(img_array, (7, 7), 0)
48
  edges = cv2.Canny(blurred, 100, 180)
 
1
  import cv2
 
2
  import numpy as np
3
  from PIL import Image
4
  Image.MAX_IMAGE_PIXELS = None
 
24
 
25
  sb_logo = Image.open("./SB_logo_horizontal.png")
26
 
 
 
 
 
 
27
  with gr.Blocks() as demo:
28
  with gr.Row():
29
  with gr.Column():
30
+ input = gr.Image(type="pil", label="Upload Image", sources=["upload"])
31
  with gr.Column():
32
  image = gr.Image(label="Sketch Drawing", show_share_button=False)
33
+ examples = gr.Examples(examples=["road_small.jpg", "preview_small.jpg", "trailer.jpg"], inputs=[input], cache_examples=True)
34
  @gr.on(inputs=[input], outputs=[image], show_progress="minimal")
35
  def sketch(input_path):
36
  if input_path is None:
37
  return None
38
+ # with Image.open(input_path) as img:
39
+ # img_array = np.array(img)
40
+ img_array = np.array(input_path)
41
  # Line processing
42
  blurred = cv2.GaussianBlur(img_array, (7, 7), 0)
43
  edges = cv2.Canny(blurred, 100, 180)