예제 #1
0
def split(matrix, uploaded_file_path, timestamp):
    split_image(uploaded_file_path, matrix)

    os.remove(uploaded_file_path)

    json_res = jsonify({
        'dirname':
        timestamp,
        'files':
        os.listdir(app.config['UPLOAD_FOLDER'] + timestamp)
    })
    json_res.status_code = HTTPStatus.CREATED
    return json_res
예제 #2
0
파일: modify.py 프로젝트: kleon1024/images
import os
import sys
import json
import subprocess
from utils import STATUS, PREFIX
from utils import load_yaml, save_yaml, load_images, split_image, gen_tag

folder = sys.argv[1]

image_dict = {}
image_set = set()

for image in load_images():
    if image.get(STATUS, None) is not None:
        image_set.add(image['name'])
        image_repo, image_tag = split_image(image['name'])
        image_dict[image_repo] = {
            "full": image['name'],
            "repo": image_repo,
            "tag": image_tag,
        }

replaces = {}
current = ""


def reg(s):
    return s.replace('/', '\/')


def replace_container(c):
예제 #3
0
파일: sync.py 프로젝트: kleon1024/images
from utils import AUTH_CONFIG, STATUS, PREFIX
from utils import gen_tag, split_image, load_images

client = docker.from_env()

images = load_images()

for entry in images:
    image = entry['name']
    status = entry.get(STATUS, None)
    if status is not None:
        continue
    relabel = gen_tag(image)
    relabel_image = PREFIX + ":" + relabel
    image_repo, image_tag = split_image(image)

    print("Remapping {} to {}".format(image, relabel_image))
    cmd = ['sudo', 'docker', 'pull', image]
    subprocess.run(cmd)
    cmd = ['sudo', 'docker', 'tag', image, relabel_image]
    subprocess.run(cmd)
    cmd = [
        'sudo', 'docker', 'login', '--username='******'username'],
        '--password='******'password'],
        PREFIX.split('/')[0]
    ]
    subprocess.run(cmd)
    cmd = ['sudo', 'docker', 'push', PREFIX + ":" + relabel]
    subprocess.run(cmd)
    #client.images.push(PREFIX, tag=relabel, auth_config=AUTH_CONFIG)
예제 #4
0
from utils import split_image, pack_sequences
from chars import *
import matplotlib.pyplot as plt

if __name__ == '__main__':
    model_f, img_f = sys.argv[1:]

    model = OCRModel(num_chars=NUM_TOKENS)
    device = torch.device('cpu')
    model.load_state_dict(torch.load(model_f, map_location=device))
    model.eval()

    img = cv2.imread(img_f)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    images = split_image(img)
    logits = model.encoder(pack_sequences([images], device), device)
    logits, input_lengths = nn.utils.rnn.pad_packed_sequence(logits,
                                                             batch_first=False)

    probs, ids = logits.view(len(images), -1).softmax(dim=1).max(dim=1)
    chars = [ids2chars[int(i)] for i in ids]

    h, w = img.shape
    ratio = 2
    img = cv2.resize(img, (int(w * ratio), int(h * ratio)),
                     interpolation=cv2.INTER_NEAREST)
    plt.imshow(img, cmap='gray')

    x = [14 * i + 7 / 2 for i in range(len(images))]
    heights = probs.detach().numpy()
예제 #5
0
from PIL import Image
from utils import key, encryptChannel, decryptChannel, split_image

keySpace=256

imgPath='input.jpeg'

# Open the image using PIL
im = Image.open(imgPath, 'r')

# Resize the image to 256*256 pixels
# im = im.resize((256, 256), Image.ANTIALIAS)

# Extract pizel values

img0, img1 = split_image(im.getdata())

rVal, gVal, bVal = zip(*im.getdata())
rVal0, gVal0, bVal0 = zip(*img0)
rVal1, gVal1, bVal1 = zip(*img1)

partImg = Image.new(im.mode, im.size)
partImg.putdata(list(zip(rVal0, gVal0, bVal0)))
partImg.save("part1.jpg")

partImg = Image.new(im.mode, im.size)
partImg.putdata(list(zip(rVal1, gVal1, bVal1)))
partImg.save("part2.jpg")

newImg = Image.new(im.mode, im.size)
newImg.putdata(list(zip(rVal, gVal, bVal)))