예제 #1
0
 def test_process_image(self, m):
     m.return_value = None
     event = {
         'bucket': 'sample-bucket',
         'name': 'sample-file'
     }
     context = {}
     main.process_image(event, context)
예제 #2
0
 def post(self):
     """The Post method for the web page actions responsible for images"""
     data = request.files["image_file"]
     if data.filename != '':
         results = main.process_image(data)
         headers = {'Content-Type': 'text/html', 'Cache-Control': 'no-store'}
         return make_response(render_template('results.html', images = results),200,headers)
def manual_processing():
    file_records = upload_collection.find()
    file_urls = []

    for record in file_records:
        file_urls.append(record["url"])
        if "formats" in record:
            try:
                for size in ["thumbnail", "small", "medium", "large"]:
                    file_urls.append(record["formats"][size]["url"])
            except:
                # For very small images (e.g. flags there is no large or even no medium version
                # For these one there is a intentional key error
                pass

    for i in range(len(file_urls)):
        url = file_urls[i][
            len("https://storage.googleapis.com/i14-worlds-2021-upload/"):]
        print(f"\n{i+1}/{len(file_urls)}: {url}")
        main.process_image('i14-worlds-2021-upload', url)
예제 #4
0
import os

import torchvision.utils as vutils
from PIL import Image

import main

opt = main.get_app_arguments()

valid_ext = ['.jpg', '.png']
if not os.path.exists(opt.output_dir):
    os.mkdir(opt.output_dir)

# load pretrained model
model = main.load_model()

for files in os.listdir(opt.input_dir):
    ext = os.path.splitext(files)[1]
    if ext not in valid_ext:
        continue
    # load image
    input_image = Image.open(os.path.join(opt.input_dir, files)).convert("RGB")
    output_image = main.process_image(input_image)
    # save
    vutils.save_image(
        output_image,
        os.path.join(opt.output_dir, files[:-4] + '_' + opt.style + '.jpg'))

print('Done!')
예제 #5
0
 def test_process_image(self, m):
     m.return_value = None
     event = {'bucket': 'sample-bucket', 'name': 'sample-file'}
     context = {}
     main.process_image(event, context)
def test_process_image():
    bucket_name = 'i14-worlds-2021-upload'
    src_file_name = 'AC75AmericanMagic_d41dbb268a/Int-14-Day-7-5b.jpg'
    main.process_image(bucket_name, src_file_name)
예제 #7
0
def call_code(image_url, image_name):
    process_image(image_url, image_name, True, True, False, False)