質問編集履歴

2

プレビューを見ておかしな部分が多々あったので正しい文章に書き替えました。

2018/11/27 05:13

投稿

julia
julia

スコア10

test CHANGED
File without changes
test CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  今まででは国旗の画像をクラスタリングするプログラムを用いて国旗のクラスタリングを行っていました。
4
4
 
5
- 実現したいことは顔画像をクラスタリングできるようにプログラムを改良したいです
5
+ 実現したいことは顔画像をクラスタリングできるようにプログラムを改良したいです
6
6
 
7
- ここに質問の内容を詳しく書いてください。
7
+
8
8
 
9
9
  Pythonの付属モジュール(Jupyter notebook)を用いています。OSはWindows 10です
10
10
 
@@ -82,25 +82,13 @@
82
82
 
83
83
  ### 発生している問題・エラーメッセージ
84
84
 
85
- クラスタリングした画像をフォルダ分けする際にエラーが発生します。
86
-
87
- ```
88
-
89
85
  No such file or directory: 'C:/Clustering2/human_origin/img_136'
90
86
 
91
87
  ```
92
88
 
93
89
 
94
90
 
95
- ### 該当のソースコード
96
91
 
97
-
98
-
99
- ```Python
100
-
101
- shutil.copyfile(f"C:/Clustering2/human_origin/{path.replace('.jpg','')}",f"C:/Clustering2/human_group/{label}/{path.replace('.jpg','')}")
102
-
103
- ```
104
92
 
105
93
 
106
94
 
@@ -111,6 +99,12 @@
111
99
  エラー文をみて、画像が問題だと思い、画像を変えてみましたが改善されませんでした。
112
100
 
113
101
 
102
+
103
+ 追記(27/11/2018)
104
+
105
+ 国旗画像の場合では問題なく行えています。
106
+
107
+ 私の場合は顔画像をクラスタリングしたいのですが顔画像の場合だと上記エラーによりうまくいかなくなります。
114
108
 
115
109
  ### 補足情報(FW/ツールのバージョンなど)
116
110
 

1

回答ありがとうございます。 プログラムが正常に動くVersionのままだったのでエラーが起こっているプログラムに修正いたしました。 また、<code>のなかにプログラムを挿入しました。

2018/11/27 05:13

投稿

julia
julia

スコア10

test CHANGED
File without changes
test CHANGED
@@ -9,6 +9,8 @@
9
9
  Pythonの付属モジュール(Jupyter notebook)を用いています。OSはWindows 10です
10
10
 
11
11
  以下がソースコードです
12
+
13
+ ``````Python
12
14
 
13
15
  import os
14
16
 
@@ -28,21 +30,21 @@
28
30
 
29
31
 
30
32
 
31
- for path in os.listdir('C:/Clustering/flag_origin'):
33
+ for path in os.listdir('C:/Clustering2/human_origin'):
32
34
 
33
- img=Image.open(f'C:/Clustering/flag_origin/{path}')
35
+ img=Image.open(f'C:/Clustering2/human_origin/{path}')
34
36
 
35
37
  img=img.convert('RGB')
36
38
 
37
- img_resize=img.resize((200,100))
39
+ img_resize=img.resize((400,400))
38
40
 
39
- img_resize.save(f'C:/Clustering/flag_convert/{path}.jpg')
41
+ img_resize.save(f'C:/Clustering2/human_convert/{path}.jpg')
40
42
 
41
43
 
42
44
 
43
45
 
44
46
 
45
- feature=np.array([data.imread(f'C:/Clustering/flag_convert/{path}') for path in os.listdir('C:/Clustering/flag_convert')])
47
+ feature=np.array([data.imread(f'C:/Clustering2/human_convert/{path}') for path in os.listdir('C:/Clustering2/human_convert')])
46
48
 
47
49
  feature=feature.reshape(len(feature),-1).astype(np.float64)
48
50
 
@@ -62,15 +64,19 @@
62
64
 
63
65
 
64
66
 
65
- for label,path in zip(labels,os.listdir('C:/Clustering/flag_convert')):
67
+ for label,path in zip(labels,os.listdir('C:/Clustering2/human_convert')):
66
68
 
67
- os.makedirs(f"C:/Clustering/flag_group/{label}",exist_ok=True)
69
+ os.makedirs(f"C:/Clustering2/human_group/{label}",exist_ok=True)
68
70
 
69
- shutil.copyfile(f"C:/Clustering/flag_origin/{path.replace('.jpg','')}",f"C:/Clustering/flag_group/{label}/{path.replace('.jpg','')}")
71
+ shutil.copyfile(f"C:/Clustering2/human_origin/{path.replace('.jpg','')}",f"C:/Clustering2/human_group/{label}/{path.replace('.jpg','')}")
70
72
 
71
73
  print(label,path)
72
74
 
75
+
76
+
77
+ ```
78
+
73
- ■■な機能を実装中に以下のエラーメッセージが発生しました。
79
+ ```■■な機能を実装中に以下のエラーメッセージが発生しました。
74
80
 
75
81
 
76
82