hysts HF Staff commited on
Commit
b685f81
·
1 Parent(s): 6940ae6
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -14,6 +14,11 @@ import gradio as gr
14
  import huggingface_hub
15
  import numpy as np
16
 
 
 
 
 
 
17
  TOKEN = os.environ['TOKEN']
18
 
19
 
@@ -63,8 +68,7 @@ def detect(image, detector: cv2.CascadeClassifier) -> np.ndarray:
63
  res = image.copy()
64
  for x, y, w, h in preds:
65
  cv2.rectangle(res, (x, y), (x + w, y + h), (0, 255, 0), 2)
66
- res = cv2.cvtColor(res, cv2.COLOR_BGR2RGB)
67
- return res
68
 
69
 
70
  def main():
@@ -79,20 +83,15 @@ def main():
79
  func = functools.partial(detect, detector=detector)
80
  func = functools.update_wrapper(func, detect)
81
 
82
- repo_url = 'https://github.com/nagadomi/lbpcascade_animeface'
83
- title = 'nagadomi/lbpcascade_animeface'
84
- description = f'A demo for {repo_url}'
85
- article = None
86
-
87
  gr.Interface(
88
  func,
89
  gr.inputs.Image(type='file', label='Input'),
90
- gr.outputs.Image(label='Output'),
91
- theme=args.theme,
92
- title=title,
93
- description=description,
94
- article=article,
95
  examples=examples,
 
 
 
 
96
  allow_screenshot=args.allow_screenshot,
97
  allow_flagging=args.allow_flagging,
98
  live=args.live,
 
14
  import huggingface_hub
15
  import numpy as np
16
 
17
+ ORIGINAL_REPO_URL = 'https://github.com/nagadomi/lbpcascade_animeface'
18
+ TITLE = 'nagadomi/lbpcascade_animeface'
19
+ DESCRIPTION = f'A demo for {ORIGINAL_REPO_URL}'
20
+ ARTICLE = None
21
+
22
  TOKEN = os.environ['TOKEN']
23
 
24
 
 
68
  res = image.copy()
69
  for x, y, w, h in preds:
70
  cv2.rectangle(res, (x, y), (x + w, y + h), (0, 255, 0), 2)
71
+ return res[:, :, ::-1]
 
72
 
73
 
74
  def main():
 
83
  func = functools.partial(detect, detector=detector)
84
  func = functools.update_wrapper(func, detect)
85
 
 
 
 
 
 
86
  gr.Interface(
87
  func,
88
  gr.inputs.Image(type='file', label='Input'),
89
+ gr.outputs.Image(type='numpy', label='Output'),
 
 
 
 
90
  examples=examples,
91
+ title=TITLE,
92
+ description=DESCRIPTION,
93
+ article=ARTICLE,
94
+ theme=args.theme,
95
  allow_screenshot=args.allow_screenshot,
96
  allow_flagging=args.allow_flagging,
97
  live=args.live,