Ashrafb commited on
Commit
013f6fb
·
verified ·
1 Parent(s): ee4c1f6

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -5
main.py CHANGED
@@ -35,14 +35,34 @@ app = FastAPI()
35
 
36
  MODEL_REPO = 'PKUWilliamYang/VToonify'
37
 
38
- class Model:
39
  def __init__(self, device):
40
  super().__init__()
41
 
42
  self.device = device
43
  self.style_types = {
44
  'cartoon1': ['vtoonify_d_cartoon/vtoonify_s026_d0.5.pt', 26],
45
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  self.landmarkpredictor = self._create_dlib_landmark_model()
@@ -50,15 +70,15 @@ class Model:
50
  self.pspencoder = self._load_encoder()
51
  self.transform = transforms.Compose([
52
  transforms.ToTensor(),
53
- transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
54
- ])
55
 
56
  self.vtoonify, self.exstyle = self._load_default_model()
57
  self.color_transfer = False
58
  self.style_name = 'cartoon1'
59
  self.video_limit_cpu = 100
60
  self.video_limit_gpu = 300
61
-
62
  def _create_dlib_landmark_model(self):
63
  return dlib.shape_predictor(huggingface_hub.hf_hub_download(MODEL_REPO, 'models/shape_predictor_68_face_landmarks.dat'))
64
 
 
35
 
36
  MODEL_REPO = 'PKUWilliamYang/VToonify'
37
 
38
+ class Model():
39
  def __init__(self, device):
40
  super().__init__()
41
 
42
  self.device = device
43
  self.style_types = {
44
  'cartoon1': ['vtoonify_d_cartoon/vtoonify_s026_d0.5.pt', 26],
45
+ 'cartoon1-d': ['vtoonify_d_cartoon/vtoonify_s_d.pt', 26],
46
+ 'cartoon2-d': ['vtoonify_d_cartoon/vtoonify_s_d.pt', 64],
47
+ 'cartoon3-d': ['vtoonify_d_cartoon/vtoonify_s_d.pt', 153],
48
+ 'cartoon4': ['vtoonify_d_cartoon/vtoonify_s299_d0.5.pt', 299],
49
+ 'cartoon4-d': ['vtoonify_d_cartoon/vtoonify_s_d.pt', 299],
50
+ 'cartoon5-d': ['vtoonify_d_cartoon/vtoonify_s_d.pt', 8],
51
+ 'comic1-d': ['vtoonify_d_comic/vtoonify_s_d.pt', 28],
52
+ 'comic2-d': ['vtoonify_d_comic/vtoonify_s_d.pt', 18],
53
+ 'arcane1': ['vtoonify_d_arcane/vtoonify_s000_d0.5.pt', 0],
54
+ 'arcane1-d': ['vtoonify_d_arcane/vtoonify_s_d.pt', 0],
55
+ 'arcane2': ['vtoonify_d_arcane/vtoonify_s077_d0.5.pt', 77],
56
+ 'arcane2-d': ['vtoonify_d_arcane/vtoonify_s_d.pt', 77],
57
+ 'caricature1': ['vtoonify_d_caricature/vtoonify_s039_d0.5.pt', 39],
58
+ 'caricature2': ['vtoonify_d_caricature/vtoonify_s068_d0.5.pt', 68],
59
+ 'pixar': ['vtoonify_d_pixar/vtoonify_s052_d0.5.pt', 52],
60
+ 'pixar-d': ['vtoonify_d_pixar/vtoonify_s_d.pt', 52],
61
+ 'illustration1-d': ['vtoonify_d_illustration/vtoonify_s054_d_c.pt', 54],
62
+ 'illustration2-d': ['vtoonify_d_illustration/vtoonify_s004_d_c.pt', 4],
63
+ 'illustration3-d': ['vtoonify_d_illustration/vtoonify_s009_d_c.pt', 9],
64
+ 'illustration4-d': ['vtoonify_d_illustration/vtoonify_s043_d_c.pt', 43],
65
+ 'illustration5-d': ['vtoonify_d_illustration/vtoonify_s086_d_c.pt', 86],
66
  }
67
 
68
  self.landmarkpredictor = self._create_dlib_landmark_model()
 
70
  self.pspencoder = self._load_encoder()
71
  self.transform = transforms.Compose([
72
  transforms.ToTensor(),
73
+ transforms.Normalize(mean=[0.5, 0.5, 0.5],std=[0.5,0.5,0.5]),
74
+ ])
75
 
76
  self.vtoonify, self.exstyle = self._load_default_model()
77
  self.color_transfer = False
78
  self.style_name = 'cartoon1'
79
  self.video_limit_cpu = 100
80
  self.video_limit_gpu = 300
81
+
82
  def _create_dlib_landmark_model(self):
83
  return dlib.shape_predictor(huggingface_hub.hf_hub_download(MODEL_REPO, 'models/shape_predictor_68_face_landmarks.dat'))
84