<jupyter_start><jupyter_text>Real Time Multi Style Transfer in Pytorch<jupyter_code>%load_ext autoreload
%autoreload 2
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Training Example  Training arguments<jupyter_code>dataset_images = "../dataset/train2017/train2017"
styles_dir = "styles"
num_workers = 2
model_dir="new_style"
eval_image_dir = "../bird.jpg"
eval_dir = "temp_eval"
from trainstylenet import train
class Namespace:
    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)
args = Namespace(content_factor=1,style_factor=1000000,lr=0.0001,eval_dir=None,epochs=2,batch_size=8, dataset_images=dataset_images, styles_dir=styles_dir,num_workers=num_workers,model_dir=model_dir,eval_image_dir=eval_image_dir)
train(args)<jupyter_output><empty_output><jupyter_text>Alternatively training in command line```python multistyle_transfer_net.py --dataset-images {dataset_images} --styles-dir {styles_dir} --num-workers {num_workers} --model-dir {model_dir} --eval-image-dir {eval_image_dir} ```  Inference Example<jupyter_code>import torch
from torchvision import transforms
from inference.Inferencer import Inferencer
from models.PasticheModel import PasticheModel
from PIL import Image
import imageio
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

num_styles = 16
image_size =512
model_save_dir = "model/pastichemodel-FINAL.pth"

pastichemodel = PasticheModel(num_styles)

inference = Inferencer(pastichemodel,device,image_size)
inference.load_model_weights(model_save_dir)
example_image_path = "input_photos/you_me_and_ever.jpg"
im = Image.open(example_image_path).convert('RGB')
%time inference.eval_image(im, 15,2,1.0)
for i in range(0,16):
    out = inference.eval_image(im, i,2,1.0)
    imageio.imwrite('output_photos/'+str(i+1)+'.jpg', out)
device<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11256117455138662, 'fraction_numerical': 0.022838499184339316, 'mean_word_length': 8.246231155778894, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '13390', 'license': 'MIT', 'n_tokens_mistral': 675, 'n_tokens_neox': 643, 'n_words': 110, 'path': 'Example.ipynb', 'repo_name': 'JStuckner/deep_style_transfer', 'size': '1839'}