コード例 #1
0
def deletar(name):
    all_face_encodings = {}
    pickle_file = 'dataset_faces.pickle'
    try:
        all_face_encodings = pickle.load(pickle_file)
    except:
        print("Arquivo vazio")
    try:
        all_face_encodings.pop(name)
        pickle.safe_dump(all_face_encodings, pickle_file)
        print("Depois : " + str(all_face_encodings))

    except:
        return "Ocorreu um erro ao salvar os dados"

    return "Usuário removido com sucesso."
コード例 #2
0
def atualizar(file, name):
    all_face_encodings = {}
    pickle_file = 'dataset_faces.pickle'
    load_image = face_recognition.load_image_file(file)
    image_encoding = face_recognition.face_encodings(load_image)[0]
    try:
        all_face_encodings = pickle.load(pickle_file)
    except:
        print("Arquivo vazio")
    try:
        all_face_encodings[name] = image_encoding
        pickle.safe_dump(all_face_encodings, pickle_file)

    except:
        raise
        return "Ocorreu um erro ao salvar os dados"

    return "Foto atualizada com sucesso"
コード例 #3
0
def cadastrar(file, name):
    all_face_encodings = {}
    pickle_file = 'dataset_faces.pickle'
    load_image = face_recognition.load_image_file(file)
    image_encoding = face_recognition.face_encodings(load_image)[0]
    try:
        all_face_encodings = pickle.load(pickle_file)
    except:
        print("Arquivo vazio")
        print("Depois : " + str(all_face_encodings))
    try:
        all_face_encodings[name] = image_encoding
        pickle.safe_dump(all_face_encodings, pickle_file)

    except:
        raise
        return "Ocorreu um erro ao salvar os dados"

    return image_encoding
コード例 #4
0
ファイル: test_pk.py プロジェクト: tinachou28/dataIO-project
def test_compress():
    """Test whether data compression is working.
    """
    pk.safe_dump({"value": 1}, path_gz, enable_verbose=False)
    assert pk.load(path_gz, enable_verbose=False) == {"value": 1}
    os.remove(path_gz)
コード例 #5
0
ファイル: example.py プロジェクト: tinachou28/dataIO-project
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
from dataIO import js
from dataIO import pk
from dataIO import textfile

data = {
    "name": "John",
    "age": 18,
    "favorite number": 3.1415926535,
    "hobby": ["Music", "Sport"]
}

js.safe_dump(data,
             "data.json",
             indent_format=True,
             float_precision=2,
             enable_verbose=True)
pk.safe_dump(data, "data.pickle", enable_verbose=True)

s = "This\nis\nPython!"
textfile.write(s, "text.txt")