Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,28 @@
|
|
| 1 |
-
import
|
| 2 |
import spaces
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
"""
|
| 19 |
-
global _DET
|
| 20 |
-
if "_DET" not in globals(): # lazy-load & cache model weights
|
| 21 |
-
_DET = EyesDetection()
|
| 22 |
-
masks, boxes = _DET.process_image(image)
|
| 23 |
-
return masks, boxes
|
| 24 |
|
| 25 |
-
# -------------------------------------------------------------------
|
| 26 |
-
# 2) API-only Gradio app (no GUI at all)
|
| 27 |
-
with gr.Blocks() as demo:
|
| 28 |
-
demo.api(
|
| 29 |
-
fn=eye_detect,
|
| 30 |
-
inputs=gr.Image(type="pil"),
|
| 31 |
-
outputs=[gr.Gallery(label="Masks"), gr.JSON(label="Boxes")],
|
| 32 |
-
name="eye_detect"
|
| 33 |
-
)
|
| 34 |
|
| 35 |
-
demo.queue(
|
|
|
|
| 1 |
+
import os
|
| 2 |
import spaces
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
from detection import EyesDetection
|
| 6 |
+
|
| 7 |
+
_GLOBAL_CSS = """
|
| 8 |
+
.limit-height {
|
| 9 |
+
max-height: 55vh;
|
| 10 |
+
}
|
| 11 |
+
"""
|
| 12 |
|
| 13 |
+
if __name__ == '__main__':
|
| 14 |
+
with gr.Blocks(css=_GLOBAL_CSS) as demo:
|
| 15 |
+
with gr.Row():
|
| 16 |
+
with gr.Column():
|
| 17 |
+
gr.HTML('<h2 style="text-align: center;">Object Detections For Anime</h2>')
|
| 18 |
+
gr.Markdown('This is the online demo for detection functions of '
|
| 19 |
+
'[imgutils.detect](https://dghs-imgutils.deepghs.org/main/api_doc/detect/index.html). '
|
| 20 |
+
'You can try them yourselves with `pip install dghs-imgutils`.')
|
| 21 |
|
| 22 |
+
with gr.Row():
|
| 23 |
+
with gr.Tabs():
|
| 24 |
+
with gr.Tab('Eyes Detection'):
|
| 25 |
+
EyesDetection().make_ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
demo.queue(os.cpu_count()).launch()
|