Spaces:
Running
on
Zero
Running
on
Zero
John Ho
commited on
Commit
Β·
0119d95
1
Parent(s):
a083e2f
added doc string and turn on fastapi doc
Browse files
app.py
CHANGED
|
@@ -19,6 +19,16 @@ def load_model():
|
|
| 19 |
def detect(
|
| 20 |
im: Image.Image, object_name: str, mode: Literal["point", "object_detection"]
|
| 21 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
model = load_model()
|
| 23 |
if mode == "point":
|
| 24 |
return model.point(im, object_name)["points"]
|
|
@@ -35,4 +45,6 @@ demo = gr.Interface(
|
|
| 35 |
],
|
| 36 |
outputs=gr.Textbox(label="Output Text"),
|
| 37 |
)
|
| 38 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
| 19 |
def detect(
|
| 20 |
im: Image.Image, object_name: str, mode: Literal["point", "object_detection"]
|
| 21 |
):
|
| 22 |
+
"""
|
| 23 |
+
Open Vocabulary Detection using moondream2
|
| 24 |
+
|
| 25 |
+
Args:
|
| 26 |
+
im: Pillow Image
|
| 27 |
+
object_name: the object you would like to detect
|
| 28 |
+
mode: point or object_detection
|
| 29 |
+
Returns:
|
| 30 |
+
list: a list of bounding boxes (xyxy) or points (xy) coordinates that are normalized
|
| 31 |
+
"""
|
| 32 |
model = load_model()
|
| 33 |
if mode == "point":
|
| 34 |
return model.point(im, object_name)["points"]
|
|
|
|
| 45 |
],
|
| 46 |
outputs=gr.Textbox(label="Output Text"),
|
| 47 |
)
|
| 48 |
+
demo.launch(
|
| 49 |
+
mcp_server=True, app_kwargs={"docs_url": "/docs"} # add FastAPI Swagger API Docs
|
| 50 |
+
)
|