Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
4,284 additions
and
6 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,46 @@ | ||
import cv2 | ||
import os | ||
from sklearn.cluster import MeanShift,KMeans , estimate_bandwidth | ||
import numpy as np | ||
|
||
os.chdir("features") | ||
|
||
|
||
hog = cv2.HOGDescriptor((224,224),(16,16),(8,8),(8,8),9) | ||
|
||
descriptores = [] | ||
nombres = [] | ||
|
||
for directorio in [x[0] for x in os.walk('.')]: | ||
if directorio != '.': | ||
os.chdir(os.path.normpath(directorio)) | ||
if not os.path.isdir("../../descriptores/"+directorio): | ||
os.makedirs("../../descriptores/"+directorio) | ||
#if not os.path.isdir("../../descriptores/"+directorio): | ||
#os.makedirs("../../descriptores/"+directorio) | ||
|
||
for f in os.listdir(): | ||
img = cv2.imread(f) | ||
h = hog.compute(img) | ||
|
||
fs_write = cv2.FileStorage("../../descriptores/"+directorio+'/'+f.split('.')[0]+'.yml', cv2.FILE_STORAGE_WRITE) | ||
fs_write.write("descriptor", h) | ||
fs_write.release() | ||
#fs_write = cv2.FileStorage("../../descriptores/"+directorio+'/'+f.split('.')[0]+'.yml', cv2.FILE_STORAGE_WRITE) | ||
#fs_write.write("descriptor", h) | ||
h = np.transpose(h)[0] | ||
descriptores.append(h) | ||
nombres.append(directorio + "_" + f.split('.')[0]) | ||
|
||
|
||
os.chdir("..") | ||
|
||
os.chdir("..") | ||
|
||
print("Empieza el cluster") | ||
|
||
#clustering = MeanShift() | ||
clustering = KMeans(n_clusters=5) | ||
clustering.fit(descriptores) | ||
|
||
f = open("clusters_k_5.txt", "w") | ||
|
||
for i in range(len(clustering.labels_)): | ||
print(nombres[i] + ": " + str(clustering.labels_[i])) | ||
f.write(nombres[i] + ": " + str(clustering.labels_[i])+"\n") | ||
|
||
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.\block1_conv1_0: 0.\block1_conv1_1: 0.\block1_conv1_10: 0.\block1_conv1_11: 0.\block1_conv1_12: 0.\block1_conv1_13: 0.\block1_conv1_14: 0.\block1_conv1_15: 0.\block1_conv1_16: 0.\block1_conv1_17: 0 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sys | ||
import os | ||
|
||
if not os.path.exists("clusters"): | ||
os.mkdir("clusters") | ||
|
||
os.chdir("clusters") | ||
|
||
if not os.path.exists(sys.argv[1].split('.')[0]): | ||
os.mkdir(sys.argv[1].split('.')[0]) | ||
os.chdir(sys.argv[1].split('.')[0]) | ||
|
||
archivo = sys.argv[1] | ||
|
||
archivo = open(archivo, "r") | ||
|
||
for line in archivo: | ||
filter_name = line.split(':')[0] | ||
cluster_number = line.split(" ")[-1] | ||
if not os.path.exists(cluster_number): | ||
os.mkdir(cluster_number) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import keras | ||
from keras.utils import plot_model | ||
|
||
model1 = keras.applications.vgg16.VGG16() | ||
model2 = keras.applications.inception_v3.InceptionV3() | ||
|
||
plot_model(model1, to_file='vgg.png') | ||
plot_model(model2, to_file='inceptionv3.png') |