teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

以前のエラーは自分で解決できたが別のエラーが発生したため編集した

2021/03/19 02:36

投稿

xeno
xeno

スコア16

title CHANGED
@@ -1,1 +1,1 @@
1
- FaceSwap実行の際のpathに関連したエラー
1
+ FaceSwap実行の際のType Error
body CHANGED
@@ -1,19 +1,19 @@
1
- FaceSwapをGoogle Colaboratoryで実行したいのですがpathが上手く通っていないのか<class 'NoneType'>なってしまいま
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 as np
10
+ import numpy
11
+
10
12
  import sys
11
- import matplotlib.pyplot as plt
12
13
 
13
- !wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
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
- PREDICTOR_PATH = "./shape_predictor_68_face_landmarks.dat"
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(PREDICTOR_PATH)
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-1-a235536e2913> in <module>()
185
+ <ipython-input-10-1ac12538b634> in <module>()
207
- 160 im2_blur.astype(numpy.float64))
186
+ 35 COLOUR_CORRECT_BLUR_FRAC = 0.6
208
- 161
187
+ 36
209
- --> 162 im1, landmarks1 = read_im_and_landmarks(sys.argv[1])
188
+ ---> 37 detector = dlib.get_frontal_face_detector(PREDICTOR_PATH)
210
- 163 im2, landmarks2 = read_im_and_landmarks(sys.argv[2])
189
+ 38 predictor = dlib.shape_predictor()
211
- 164
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
- 693 raise TypeError("Image data of dtype {} cannot be converted to "
192
+ TypeError: get_frontal_face_detector(): incompatible function arguments. The following argument types are supported:
217
- --> 694 "float".format(self._A.dtype))
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
- TypeError: Image data of dtype object cannot be converted to float
195
+ Invoked with: '/content/drive/MyDrive/Colab Notebooks/shape_predictor_68_face_landmarks.dat'
222
- ```
196
+ ```
223
-
224
- Colabo notebooksの状況は以下写真のようになっています。
225
- プログラムの名前はUntitled10です。
226
- ![イメージ説明](9832523a9e397bc09d3b8b10418d8f3a.png)

1

言語を記入した

2021/03/19 02:36

投稿

xeno
xeno

スコア16

title CHANGED
File without changes
body CHANGED
File without changes