From bbd99821df4fbf49474610b21c4e9ed5f0016b7a Mon Sep 17 00:00:00 2001
From: Lars Nieradzik
Date: Tue, 13 Feb 2018 01:54:01 +0100
Subject: [PATCH] Added seed and updated readme
---
README.md | 10 +++++++++-
kmeans.py | 2 ++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4e0c2ac..cc9be3e 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,15 @@ However, this didn't seem good enough, because now the algorithm has to run for
![k-medians k = 9](https://i.imgur.com/ly2OGuj.png)
-The end result is about 60.15 for k = 5 and 67.13 for k = 9 on the VOC 2007 data set.
+The end result is about 60.15 for k = 5 and 67.13 for k = 9 on the VOC 2007 data set. If you run the algorithm multiple times, the avg IoU can be higher. I got a few times for example 60.5 for k = 5. The result always depends on the chosen starting points during initialization.
+
+## Usage
+
+To try out the results yourself, download the annotations here: http://host.robots.ox.ac.uk/pascal/VOC/voc2007/. Then change the constant ANNOTATIONS_PATH in test/test_voc2007.py and finally run:
+
+```
+python3 -m unittest discover -s tests/
+```
## References
diff --git a/kmeans.py b/kmeans.py
index a1f1fbe..7cb17e5 100644
--- a/kmeans.py
+++ b/kmeans.py
@@ -58,6 +58,8 @@ def kmeans(boxes, k, dist=np.median):
distances = np.empty((rows, k))
last_clusters = np.zeros((rows,))
+ np.random.seed()
+
# the Forgy method will fail if the whole array contains the same rows
clusters = boxes[np.random.choice(rows, k, replace=False)]
--
GitLab