Commit 903649a2 authored by Claire Lemoine's avatar Claire Lemoine
Browse files

Merge branch 'master' of https://gitlab.ensimag.fr/lemoincl/tp3-image into master

parents c4b0f674 b6c2fa12
......@@ -17,6 +17,7 @@ import cv2
import glob
import numpy as np
import os
import random
import time
class Objects:
......@@ -1052,10 +1053,12 @@ class Objects:
# Preparation de la session.
self.sess = tf.Session()
self.softmax_tensor = self.sess.graph.get_tensor_by_name("softmax:0")
# tf.disable_eager_execution()
# self.images_placeholder = tf.placeholder(tf.int32)
def predict(self, im_data):
return np.squeeze(self.sess.run(self.softmax_tensor, {'DecodeJpeg/contents:0': im_data}))
# return np.squeeze(self.sess.run(self.softmax_tensor, {self.images_placeholder: image}))
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" # Pour eviter les messages de la part de tensorflow.
try:
......@@ -1186,7 +1189,6 @@ class Critere:
return np.sum((self.get_hog() - other.get_hog())**2) / (2 * 255**2)
@timer
def dist_objects(self, other):
"""
Compare les objet presents entre les 2 images.
......@@ -1235,21 +1237,27 @@ class Critere:
def main():
import time
criters = [
Critere(chemin)
for chemin in glob.iglob("../../labsessions/lab1/input/*.jpg")]
ref, others = criters[0], criters[1:]
rang = random.randint(0, len(criters)-1)
ref, others = criters[rang], criters[:rang] + criters[rang+1:]
# for im in criters:
# if im.is_natural():
# im.show()
ref.show()
ti = time.time()
import matplotlib.pyplot as plt
plt.subplot(2, 3, 1)
plt.imshow(ref.image[..., ::-1], vmin=0, vmax=255)
bests = sorted(others, key=lambda other: ref.dist_global(other, objects=1))[:5]
print(time.time() - ti)
bests[0].show()
for i, best in enumerate(bests):
plt.subplot(2, 3, i+2)
plt.imshow(best.image[..., ::-1], vmin=0, vmax=255)
plt.show()
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment