|
"All the constants used in this repo." |
|
|
|
from pathlib import Path |
|
|
|
import numpy as np |
|
from PIL import Image |
|
|
|
|
|
REPO_DIR = Path(__file__).parent |
|
|
|
|
|
FILTERS_PATH = REPO_DIR / "filters" |
|
KEYS_PATH = REPO_DIR / ".fhe_keys" |
|
CLIENT_TMP_PATH = REPO_DIR / "client_tmp" |
|
SERVER_TMP_PATH = REPO_DIR / "server_tmp" |
|
|
|
|
|
KEYS_PATH.mkdir(exist_ok=True) |
|
CLIENT_TMP_PATH.mkdir(exist_ok=True) |
|
SERVER_TMP_PATH.mkdir(exist_ok=True) |
|
|
|
|
|
AVAILABLE_FILTERS = [ |
|
"identity", |
|
"inverted", |
|
"rotate", |
|
"black and white", |
|
"blur", |
|
"sharpen", |
|
"ridge detection", |
|
] |
|
|
|
|
|
INPUT_SHAPE = (100, 100) |
|
|
|
|
|
np.random.seed(42) |
|
INPUTSET = tuple( |
|
np.random.randint(0, 255, size=(INPUT_SHAPE + (3,)), dtype=np.int64) for _ in range(10) |
|
) |
|
|
|
|
|
def load_image(image_path): |
|
image = Image.open(image_path).convert("RGB").resize(INPUT_SHAPE) |
|
image = np.asarray(image, dtype="int64") |
|
return image |
|
|
|
|
|
_INPUTSET_DIR = REPO_DIR / "input_examples" |
|
|
|
|
|
EXAMPLES = [str(image) for image in _INPUTSET_DIR.glob("**/*")] |
|
|
|
SERVER_URL = "http://localhost:8000/" |
|
|