diff options
author | xAlpharax <42233094+xAlpharax@users.noreply.github.com> | 2023-05-06 03:30:43 +0300 |
---|---|---|
committer | xAlpharax <42233094+xAlpharax@users.noreply.github.com> | 2023-05-06 03:30:43 +0300 |
commit | f27b568a77580cacd45510f554dd1998445beb75 (patch) | |
tree | c0f773e4ff75e7a94d14f974f7d0083d8b132366 /neuralart.py | |
parent | cf395a0190a709fb3a44e2c42b2f401e434cb037 (diff) |
Testing and Userland Changes
Changes to be committed:
renamed: Images/colorful.jpg -> Images/Colorful.jpg
new file: Images/Abstract.jpg
new file: Images/Shade.jpg
new file: all.sh
modified: README.md
modified: neuralart.py
modified: stylize.sh
Diffstat (limited to 'neuralart.py')
-rw-r--r-- | neuralart.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/neuralart.py b/neuralart.py index aee66b9..d556d2f 100644 --- a/neuralart.py +++ b/neuralart.py @@ -27,6 +27,16 @@ from PIL import Image model_path = 'weights/vgg_conv_weights.pth' image_path = '' # root (neural-art) directory +### userland testing for multiple instances, a big nono currently + +n_instances = os.popen('ps aux | grep "python neuralart.py" | wc -l').read() +if int(n_instances) > 3: print("Woah, running 2 or more instances of neural-art at the same time?\nThis is an experimental feature as of now... try it later favorably :3") + +### check if there are any weights to use, if not, download the default provided ones +if int(os.popen('ls -l weights | wc -l').read()) == 1: os.system('wget -O "weights/vgg_conv_weights.pth" "https://m1.afileditch.ch/ajjMsHrRhnikrrCiUXgY.pth"') + +### Defining neural architecture + ### VGG was trained on IMAGENET ### although old at this point ### it still achieves good results @@ -63,6 +73,7 @@ class VGG(nn.Module): self.pool3 = nn.MaxPool2d(kernel_size = 2, stride = 2) self.pool4 = nn.MaxPool2d(kernel_size = 2, stride = 2) self.pool5 = nn.MaxPool2d(kernel_size = 2, stride = 2) + elif pool == 'avg': self.pool1 = nn.AvgPool2d(kernel_size = 2, stride = 2) self.pool2 = nn.AvgPool2d(kernel_size = 2, stride = 2) @@ -99,7 +110,6 @@ class VGG(nn.Module): out['r54'] = F.relu(self.conv5_4(out['r53'])) out['p5'] = self.pool5(out['r54']) - # RETURN DESIRED ACTIVATIONS return [out[key] for key in out_keys] @@ -200,7 +210,7 @@ style_img, content_img = imgs_torch # CAN BE INITIALIZED RANDOMLY # OR AS A CLONE OF CONTENT IMAGE opt_img = Variable(content_img.clone(), requires_grad = True) -print("Content size:", content_img.size()) +print("Content size:", content_img.size(), sys.argv[2], "in", sys.argv[1]) print("Target size:", opt_img.size(), end="\n\n") |