saliacoel commited on
Commit
72c27b0
·
verified ·
1 Parent(s): 3646226

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -37
app.py CHANGED
@@ -1,44 +1,21 @@
1
  import os
2
  import spaces
3
  import gradio as gr
 
4
 
5
- from detection import EyesDetection, FaceDetection, HeadDetection, PersonDetection, HandDetection, CensorDetection, \
6
- HalfBodyDetection, NudeNetDetection, BooruYOLODetection
7
 
8
- _GLOBAL_CSS = """
9
- .limit-height {
10
- max-height: 55vh;
11
- }
12
- """
13
 
14
- if __name__ == '__main__':
15
- with gr.Blocks(css=_GLOBAL_CSS) as demo:
16
- with gr.Row():
17
- with gr.Column():
18
- gr.HTML('<h2 style="text-align: center;">Object Detections For Anime</h2>')
19
- gr.Markdown('This is the online demo for detection functions of '
20
- '[imgutils.detect](https://dghs-imgutils.deepghs.org/main/api_doc/detect/index.html). '
21
- 'You can try them yourselves with `pip install dghs-imgutils`.')
22
 
23
- with gr.Row():
24
- with gr.Tabs():
25
- with gr.Tab('Face Detection'):
26
- FaceDetection().make_ui()
27
- with gr.Tab('Head Detection'):
28
- HeadDetection().make_ui()
29
- with gr.Tab('Person Detection'):
30
- PersonDetection().make_ui()
31
- with gr.Tab('Half Body Detection'):
32
- HalfBodyDetection().make_ui()
33
- with gr.Tab('Eyes Detection'):
34
- EyesDetection().make_ui()
35
- with gr.Tab('Hand Detection'):
36
- HandDetection().make_ui()
37
- with gr.Tab('Censor Point Detection'):
38
- CensorDetection().make_ui()
39
- with gr.Tab('NudeNet'):
40
- NudeNetDetection().make_ui()
41
- with gr.Tab('BooruYOLO'):
42
- BooruYOLODetection().make_ui()
43
-
44
- demo.queue(os.cpu_count()).launch(share=True)
 
1
  import os
2
  import spaces
3
  import gradio as gr
4
+ from detection import EyesDetection
5
 
6
+ eyes_detector = EyesDetection()
 
7
 
8
+ # expose the heavy work so ZeroGPU sees it
9
+ @spaces.GPU
10
+ def _gpu_detect(img, m="eye_detect_v1.0_s"):
11
+ return eyes_detector.detect(img, model_name=m)
 
12
 
13
+ if __name__ == "__main__":
14
+ with gr.Blocks() as demo:
15
+ with gr.Tabs():
16
+ with gr.Tab("Eyes Detection"):
17
+ # the helper builds an image uploader, button,
18
+ # and nicely formatted results table
19
+ eyes_detector.make_ui(detect_fn=_gpu_detect)
 
20
 
21
+ demo.queue(os.cpu_count()).launch()