nakamura196
commited on
Commit
•
33e0298
1
Parent(s):
6a86152
feat: initial commit
Browse files- .gitattributes +1 -0
- .gitignore +3 -0
- best.pt +3 -0
- index.ipynb +80 -0
- requirements.txt +2 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.ipynb filter=nbstripout
|
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
results*
|
2 |
+
.DS_Store
|
3 |
+
.venv
|
best.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:497dd54a738a54abfc938507c16b77e4e46930372e6e189ae87895aa5bba0b7c
|
3 |
+
size 173348189
|
index.ipynb
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"## How tu use\n",
|
8 |
+
"\n",
|
9 |
+
"- Install [yolov5](https://github.com/fcakyon/yolov5-pip):\n",
|
10 |
+
"\n",
|
11 |
+
"```bash\n",
|
12 |
+
"pip install -U yolov5\n",
|
13 |
+
"```\n",
|
14 |
+
"\n",
|
15 |
+
"- Load model and perform prediction:"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"cell_type": "code",
|
20 |
+
"execution_count": null,
|
21 |
+
"metadata": {},
|
22 |
+
"outputs": [],
|
23 |
+
"source": [
|
24 |
+
"import yolov5\n",
|
25 |
+
"\n",
|
26 |
+
"# load model\n",
|
27 |
+
"model = yolov5.load('best.pt')\n",
|
28 |
+
" \n",
|
29 |
+
"# set model parameters\n",
|
30 |
+
"model.conf = 0.25 # NMS confidence threshold\n",
|
31 |
+
"model.iou = 0.45 # NMS IoU threshold\n",
|
32 |
+
"model.agnostic = False # NMS class-agnostic\n",
|
33 |
+
"model.multi_label = False # NMS multiple labels per box\n",
|
34 |
+
"model.max_det = 1000 # maximum number of detections per image\n",
|
35 |
+
"\n",
|
36 |
+
"# set image\n",
|
37 |
+
"img = 'https://dl.ndl.go.jp/api/iiif/2534020/T0000001/full/full/0/default.jpg'\n",
|
38 |
+
"\n",
|
39 |
+
"# perform inference\n",
|
40 |
+
"results = model(img, size=640)\n",
|
41 |
+
"\n",
|
42 |
+
"# inference with test time augmentation\n",
|
43 |
+
"results = model(img, augment=True)\n",
|
44 |
+
"\n",
|
45 |
+
"# parse results\n",
|
46 |
+
"predictions = results.pred[0]\n",
|
47 |
+
"boxes = predictions[:, :4] # x1, y1, x2, y2\n",
|
48 |
+
"scores = predictions[:, 4]\n",
|
49 |
+
"categories = predictions[:, 5]\n",
|
50 |
+
"\n",
|
51 |
+
"# show detection bounding boxes on image\n",
|
52 |
+
"results.show()\n",
|
53 |
+
"\n",
|
54 |
+
"# save results into \"results/\" folder\n",
|
55 |
+
"results.save(save_dir='results/')\n"
|
56 |
+
]
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"metadata": {
|
60 |
+
"kernelspec": {
|
61 |
+
"display_name": ".venv",
|
62 |
+
"language": "python",
|
63 |
+
"name": "python3"
|
64 |
+
},
|
65 |
+
"language_info": {
|
66 |
+
"codemirror_mode": {
|
67 |
+
"name": "ipython",
|
68 |
+
"version": 3
|
69 |
+
},
|
70 |
+
"file_extension": ".py",
|
71 |
+
"mimetype": "text/x-python",
|
72 |
+
"name": "python",
|
73 |
+
"nbconvert_exporter": "python",
|
74 |
+
"pygments_lexer": "ipython3",
|
75 |
+
"version": "3.9.11"
|
76 |
+
}
|
77 |
+
},
|
78 |
+
"nbformat": 4,
|
79 |
+
"nbformat_minor": 2
|
80 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
yolov5
|
2 |
+
nbstripout
|