-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinference.py
45 lines (34 loc) · 1.16 KB
/
inference.py
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
import os
from tqdm import tqdm
import glob
import random
import numpy as np
import matplotlib.pyplot as plt
import torch
from torch.utils.data import Dataset, DataLoader
from styleaug.text_embedder import TextEmbedder
from FastCLIPstyler import FastCLIPStyler
mapping = {
"Thawan Duchanee style": "red swirly fire and scary",
"Chakrabhand Posayakrit style": "style of mild colorful pastels",
"Chalermchai Kositpipat style": "blue color canvas painting",
"Vasan Sitthiket style": "fauvism style",
"Fua Haripitak style": "crayon style painting",
"Mit Jai Inn style": "colorful pointillism style"
}
class params:
img_width=512
img_height=512
num_crops=16
text_encoder='fastclipstyler' # can be either fastclipstyler or edgeclipstyler
class TrainStylePredictor():
def __init__(self):
self.trainer = FastCLIPStyler(params)
# pass
def test(self, content_img, style_desc):
# trainer = FastCLIPStyler(params)
self.trainer.content_image = content_img
if style_desc in mapping.keys():
style_desc = mapping[style_desc]
params.text = style_desc
return self.trainer.test()