Skip to content

Commit 4254734

Browse files
committed
adds classification model
1 parent 3295a6f commit 4254734

File tree

4 files changed

+11
-39
lines changed

4 files changed

+11
-39
lines changed

helpers.py

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from PIL import ImageDraw
2-
from typing import Tuple
1+
"""
2+
Helper utilities.
3+
"""
4+
35

46
def read_coco_labels(file_path):
57
"""
@@ -12,40 +14,3 @@ def read_coco_labels(file_path):
1214
pair = line.strip().split(maxsplit=1)
1315
ret[int(pair[0])] = pair[1].strip()
1416
return ret
15-
16-
def draw_box(
17-
draw: ImageDraw,
18-
box: Tuple[float, float, float, float],
19-
img_width: int,
20-
img_height: int,
21-
text: str = "",
22-
color: Tuple[int, int, int] = (255, 255, 0),
23-
) -> None:
24-
"""
25-
Draw a bounding box on and image.
26-
The bounding box is defined by the tuple (y_min, x_min, y_max, x_max)
27-
where the coordinates are floats in the range [0.0, 1.0] and
28-
relative to the width and height of the image.
29-
For example, if an image is 100 x 200 pixels (height x width) and the bounding
30-
box is `(0.1, 0.2, 0.5, 0.9)`, the upper-left and bottom-right coordinates of
31-
the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates).
32-
"""
33-
34-
line_width = 3
35-
font_height = 8
36-
y_min, x_min, y_max, x_max = box
37-
(left, right, top, bottom) = (
38-
x_min * img_width,
39-
x_max * img_width,
40-
y_min * img_height,
41-
y_max * img_height,
42-
)
43-
draw.line(
44-
[(left, top), (left, bottom), (right, bottom), (right, top), (left, top)],
45-
width=line_width,
46-
fill=color,
47-
)
48-
if text:
49-
draw.text(
50-
(left + line_width, abs(top - line_width - font_height)), text, fill=color
51-
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## dogs vs cats
2+
* Custom model trained on [teachable machine image classification](https://teachablemachine.withgoogle.com/train/image)
3+
* Dataset: 30 cat and 30 dog images from [kaggle dogs vs cats](https://www.kaggle.com/c/dogs-vs-cats)
4+
* Input size: TBC
5+
* Type: tensorflow lite quantized
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0 dog
2+
1 cat
722 KB
Binary file not shown.

0 commit comments

Comments
 (0)