質問編集履歴
2
以前のエラーは自分で解決できたが別のエラーが発生したため編集した
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
FaceSwap実行の際の
|
1
|
+
FaceSwap実行の際のType Error
|
body
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
FaceSwapをGoogle Colaboratoryで実行したいのです
|
1
|
+
FaceSwapをGoogle Colaboratoryで実行したいのです。以前発生していたpathに関するエラーは解決したのですが、Typeに関するエラーが解決できませんので編集いたしました。
|
2
|
-
https://github.com/matthewearl/faceswap/blob/master/faceswap.py このサイトを
|
2
|
+
[リンク内容](https://github.com/matthewearl/faceswap/blob/master/faceswap.py) このサイトのコードを使用しています。
|
3
|
+
[リンク内容](https://qiita.com/goodboy_max/items/134f80c2bc8a6d83aa33)このサイトの通りにやっています。
|
3
|
-
|
4
|
+
コード内のpathに関してはコピーしたものなのであっているはずです。
|
4
5
|
|
5
6
|
下記がコードです。
|
6
7
|
```
|
7
8
|
import cv2
|
8
9
|
import dlib
|
9
|
-
import numpy
|
10
|
+
import numpy
|
11
|
+
|
10
12
|
import sys
|
11
|
-
import matplotlib.pyplot as plt
|
12
13
|
|
13
|
-
|
14
|
+
PREDICTOR_PATH = "/content/drive/MyDrive/Colab Notebooks/shape_predictor_68_face_landmarks.dat"
|
14
|
-
!bunzip2 "shape_predictor_68_face_landmarks.dat.bz2"
|
15
15
|
|
16
|
-
|
16
|
+
|
17
17
|
SCALE_FACTOR = 1
|
18
18
|
FEATHER_AMOUNT = 11
|
19
19
|
|
@@ -41,8 +41,8 @@
|
|
41
41
|
# pupillary distance.
|
42
42
|
COLOUR_CORRECT_BLUR_FRAC = 0.6
|
43
43
|
|
44
|
-
detector = dlib.get_frontal_face_detector()
|
44
|
+
detector = dlib.get_frontal_face_detector(PREDICTOR_PATH)
|
45
|
-
predictor = dlib.shape_predictor(
|
45
|
+
predictor = dlib.shape_predictor()
|
46
46
|
|
47
47
|
class TooManyFaces(Exception):
|
48
48
|
pass
|
@@ -128,14 +128,6 @@
|
|
128
128
|
|
129
129
|
def read_im_and_landmarks(fname):
|
130
130
|
im = cv2.imread(fname, cv2.IMREAD_COLOR)
|
131
|
-
|
132
|
-
#---追加部分---
|
133
|
-
print(type(im))
|
134
|
-
img_list = np.asarray(im) # 画像を配列に変換
|
135
|
-
plt.imshow(img_list) # 貼り付け
|
136
|
-
plt.show() # 表示
|
137
|
-
#---end---
|
138
|
-
|
139
131
|
im = cv2.resize(im, (im.shape[1] * SCALE_FACTOR,
|
140
132
|
im.shape[0] * SCALE_FACTOR))
|
141
133
|
s = get_landmarks(im)
|
@@ -189,38 +181,16 @@
|
|
189
181
|
|
190
182
|
下記がエラーです
|
191
183
|
```
|
192
|
-
--2021-03-09 10:31:32-- http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
|
193
|
-
Resolving dlib.net (dlib.net)... 107.180.26.78
|
194
|
-
Connecting to dlib.net (dlib.net)|107.180.26.78|:80... connected.
|
195
|
-
HTTP request sent, awaiting response... 200 OK
|
196
|
-
Length: 64040097 (61M)
|
197
|
-
Saving to: ‘shape_predictor_68_face_landmarks.dat.bz2’
|
198
|
-
|
199
|
-
shape_predictor_68_ 100%[===================>] 61.07M 7.39MB/s in 14s
|
200
|
-
|
201
|
-
2021-03-09 10:31:47 (4.26 MB/s) - ‘shape_predictor_68_face_landmarks.dat.bz2’ saved [64040097/64040097]
|
202
|
-
|
203
|
-
<class 'NoneType'>
|
204
|
-
---------------------------------------------------------------------------
|
205
184
|
TypeError Traceback (most recent call last)
|
206
|
-
<ipython-input-
|
185
|
+
<ipython-input-10-1ac12538b634> in <module>()
|
207
|
-
|
186
|
+
35 COLOUR_CORRECT_BLUR_FRAC = 0.6
|
208
|
-
|
187
|
+
36
|
209
|
-
-->
|
188
|
+
---> 37 detector = dlib.get_frontal_face_detector(PREDICTOR_PATH)
|
210
|
-
|
189
|
+
38 predictor = dlib.shape_predictor()
|
211
|
-
|
190
|
+
39
|
212
191
|
|
213
|
-
6 frames
|
214
|
-
/usr/local/lib/python3.7/dist-packages/matplotlib/image.py in set_data(self, A)
|
215
|
-
692 not np.can_cast(self._A.dtype, float, "same_kind")):
|
216
|
-
|
192
|
+
TypeError: get_frontal_face_detector(): incompatible function arguments. The following argument types are supported:
|
217
|
-
|
193
|
+
1. () -> dlib::object_detector<dlib::scan_fhog_pyramid<dlib::pyramid_down<6u>, dlib::default_fhog_feature_extractor> >
|
218
|
-
695
|
219
|
-
696 if not (self._A.ndim == 2
|
220
194
|
|
221
|
-
|
195
|
+
Invoked with: '/content/drive/MyDrive/Colab Notebooks/shape_predictor_68_face_landmarks.dat'
|
222
|
-
```
|
196
|
+
```
|
223
|
-
|
224
|
-
Colabo notebooksの状況は以下写真のようになっています。
|
225
|
-
プログラムの名前はUntitled10です。
|
226
|
-

|
1
言語を記入した
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|