Beispiel #1
0
my_reconstructed = reconstructed_matrix[chosen].values
my_contribution = contribution_matrix[chosen].values

# Initialize fireworks display for the first input column

diameter_max = 100
diameter_min = 15

myDisplay = fireworks.Display(firework_count=15, dimensions=30, dimension_min=0, dimension_max=1000,
                              diameter_min=15, diameter_max=100, spark_min=10, spark_max=50, gaussian_spark_count=10,
                              fitness_function=fitness.fitness_manhattan_similarity_sum, catalog=my_catalog,
                              mutational_data=my_input, spark_dimension_count=10, dimension_limit=False)
myDisplay.create_fireworks(None)
myDisplay.showtime()

watcher = Watcher(iterations=15, threshold=0.001, starting_iteration=10, fw_display=myDisplay)

watcher.iterate(for_range=range(0, 200), reduction=0.99)

logging.info("Finished iterating. Comparing solutions.")

new_reconstructed = np.dot(np.array(my_catalog), np.array(myDisplay.best_spark.position))

FW_result = np.average(paired_distances(
    np.array(new_reconstructed).reshape(-1, 1), np.array(my_input).reshape(-1, 1), metric='manhattan'))
MP_result = np.average(paired_distances(
    np.array(my_reconstructed).reshape(-1, 1), np.array(my_input).reshape(-1, 1), metric='manhattan'))
FW_result2 = np.average(paired_distances(
    np.array(new_reconstructed).reshape(1, -1), np.array(my_input).reshape(1, -1), metric='cosine'))
MP_resul2 = np.average(paired_distances(
    np.array(my_reconstructed).reshape(1, -1), np.array(my_input).reshape(1, -1), metric='cosine'))
Beispiel #2
0
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            faces = face_detector.detectMultiScale(gray, 1.3, 5)
            for (x, y, w, h) in faces:
                cv2.rectangle(gray, (x, y), (x + w, y + h), (255, 0, 0), 2)
                count += 1
                dir1 = os.path.join(dir, face_id)
                if not os.path.exists(dir1):
                    os.makedirs(dir1)
                # Save the captured image into the datasets folder
                cv2.imwrite(dir1 + "/" + str(count) + ".jpg", gray[y:y + h,
                                                                   x:x + w])
                cv2.imshow('frame', gray)
            if count >= 10:
                print("10 face sample and stop dataset")
                break
        else:
            break
    capt.release()
    cv2.destroyAllWindows()
    encode_faces.encoding()
    print("encoded images")


def custom_action():
    capture_encode_faces()


watch1 = Watcher(watch_file, custom_action)  # also call custom action function
watch1.watch()  # start the watch going
watch1.look()
Beispiel #3
0
from logging import getLogger, INFO, basicConfig

logger = getLogger(__name__)
format_ = "[%(asctime)s]:%(filename)s:%(lineno)s:%(message)s"
basicConfig(format=format_, level=INFO, filename="c4N4Re.log", filemode='w')

if __name__ == "__main__":
    config = ConfigParser()
    config.read("config.ini")

    if (not config.has_section("login")
            or not config.has_option("login", "email")
            or not config.has_option("login", "app_pass")):
        login = Login(config=config)
        try:
            login.env_login()
        except:
            logger.critical(
                "Unable to retrieve email or app password values from config file."
            )

    try:
        watcher = Watcher(config=config)
        watcher.watch()
    except KeyboardInterrupt:
        logger.info("Captured KeyboardInterrupt exception. Exiting program")
        exit(1)
    except Exception as e:
        logger.critical(f"Exception -> {e}")
        exit(1)
Beispiel #4
0
 def setUp(self) -> None:
     self.mock_api_helper: TwitterApiHandler = MagicMock()
     self.mock_os_timer: OsTimer = MagicMock()
     self.watcher = Watcher(self.mock_api_helper, self.mock_os_timer)