File size: 1,385 Bytes
21c7197 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
"All the constants used in this repo."
from pathlib import Path
import numpy as np
from PIL import Image
# The repository's directory
REPO_DIR = Path(__file__).parent
# The repository's main directories
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"
# Create the directories if it does not exist yet
KEYS_PATH.mkdir(exist_ok=True)
CLIENT_TMP_PATH.mkdir(exist_ok=True)
SERVER_TMP_PATH.mkdir(exist_ok=True)
# All the filters currently available in the app
AVAILABLE_FILTERS = [
"identity",
"inverted",
"rotate",
"black and white",
"blur",
"sharpen",
"ridge detection",
]
# The input image's shape. Images with larger input shapes will be cropped and/or resized to this
INPUT_SHAPE = (100, 100)
# Generate random images as an inputset for compilation
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"
# List of all image examples suggested in the app
EXAMPLES = [str(image) for image in _INPUTSET_DIR.glob("**/*")]
SERVER_URL = "http://localhost:8000/"
|