質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

2回答

1807閲覧

TensorFlowとAndroid Studioで画像分類を利用したスマートフォンアプリが作りたい

baruterute

総合スコア9

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/02/01 14:01

編集2020/02/02 05:56

なんども編集してすみません

現在

リンク内容

こちらのサイトを参考にさせていただきながらTensorFlowを用いてAIに画像分類の機械学習を行い、それをAndroid StudioでAndroidアプリにしようと挑戦しています。

tensorflowのtransfer learningのtutorialを使用という部分のURL
リンク内容
上記を開き、Playgroundで開くを押してから上から順に実行していこうと思っているのですが

二つ目の

from google.colab import drive drive.mount('/content/drive')

という部分を

from google.colab import drive drive.mount('/content/drive') PATH = '/content/drive/'+'google drive上の自分のデータセットのある場所までのパス'

と言う風に書き換え

from google.colab import drive drive.mount('/content/drive') PATH = '/content/drive/'+'My Drive'

と書き直し、My Driveまでのパスを設定しました。

Enter your authorization code: ·········· Mounted at /content/drive

このような結果が返ってきたのでマウントはできていると思っています

その後

base_dir = '/content/drive保存したフォルダのパス'

というのも私の場合Google Driveに学習用とテスト用の画像フォルダを保存したimagesというフォルダがあるので

base_dir = '/content/drive/My Drive/images' ```だと思い入力して実行したのですが そこから二つ下の ```ここに言語を入力 image_size = 224 # All images will be resized to 160x160 batch_size = 64 # Rescale all images by 1./255 and apply image augmentation train_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255,rotation_range=20,horizontal_flip=True) validation_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255, validation_split=0.9) # Flow training images in batches of 20 using train_datagen generator train_generator = train_datagen.flow_from_directory( train_dir, # Source directory for the training images target_size=(image_size, image_size), batch_size=batch_size, # Since we use binary_crossentropy loss, we need binary labels #class_mode='binary' subset='training' ) # Flow validation images in batches of 20 using test_datagen generator validation_generator = validation_datagen.flow_from_directory( validation_dir, # Source directory for the validation images target_size=(image_size, image_size), batch_size=batch_size, #class_mode='binary' subset='validation' ) print(train_generator.image_shape)

という部分を実行したところ下記のエラーが出てしまいました。

Found 9266 images belonging to 50 classes. --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-7-31fe6a302292> in <module>() 23 batch_size=batch_size, 24 #class_mode='binary' ---> 25 subset='validation' 26 ) 27 1 frames /usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/image_data_generator.py in flow_from_directory(self, directory, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format, follow_links, subset, interpolation) 538 follow_links=follow_links, 539 subset=subset, --> 540 interpolation=interpolation 541 ) 542 /usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/directory_iterator.py in __init__(self, directory, image_data_generator, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, data_format, save_to_dir, save_prefix, save_format, follow_links, subset, interpolation, dtype) 104 if not classes: 105 classes = [] --> 106 for subdir in sorted(os.listdir(directory)): 107 if os.path.isdir(os.path.join(directory, subdir)): 108 classes.append(subdir) FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/My Drive/images/val'

回答者様方のおかげで自分のgoogle drive上の自分のデータセットまでの場所のパスの設定はクリアできたと思うのですが

その後がやはり詰まってしまっている状態です。

わかる方がおられましたらお力添えいただけると幸いです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mistn

2020/02/01 14:45

全く同じエラーだったとしてもエラーの出るコードとエラー内容は質問に書いておいてほしいです。
baruterute

2020/02/02 00:53

失礼いたしました、自分の中で可能な限りわかりやすく現状のエラーを記述し直しました。 お力添えいただけると幸いです。
meg_

2020/02/02 03:04

google driveにはマウントされてますよね?
baruterute

2020/02/02 03:21

「from google.colab import drive drive.mount('/content/drive') PATH = '/content/drive/'+'google drive上の自分のデータセットのある場所までのパス'」 を実行したところマウントは取れてるというふうな結果が返ってきているのですが google drive上の自分のデータセットのある場所までのパスと言うのが上に書かせていただいたマイドライブのhttps://から始まるURLであっているのかがわからない状態です。
baruterute

2020/02/02 05:28

文章の書き方の間違いを訂正させていただきました、申し訳ありません。
guest

回答2

0

みなさん回答いただきありがとうございました。

教えていただいた内容で書き換えた後

自分のimagesフォルダの中のtrainフォルダはいいのですがvalフォルダだけvalidationという名前になっていたので上記のエラーが出たようです

フォルダ名をvalにしたところ
Found 9266 images belonging to 50 classes.
Found 449 images belonging to 50 classes.
(224, 224, 3)
このように返ってきたため先に進めています

現在その後の部分でまた止まってしまっているのですが新しい質問で書かせていただきたいと思います。

ご協力ありがとうございました。

投稿2020/02/02 06:15

baruterute

総合スコア9

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

/content/driveにマウントした際、マイドライブの中身は/content/drive/My Driveにあります。

エラーを見たところ名前を間違えてるだけだと思うのでmy-driveMy Driveとしてみてください。

投稿2020/02/02 04:14

編集2020/02/02 04:32
mistn

総合スコア1191

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

baruterute

2020/02/02 05:51

回答ありがとうございます、教えていただいた通り ソースコードの from google.colab import drive drive.mount('/content/drive') を from google.colab import drive drive.mount('/content/drive') PATH = '/content/drive/'+'google drive上の自分のデータセットのある場所までのパス' のように置き換えた上で from google.colab import drive drive.mount('/content/drive') PATH = '/content/drive/'+'My Drive' としました その後 base_dir = '/content/drive保存したフォルダのパス' を base_dir = '/content/drive/My Drive/images' と言う風に書き換え実行したのですが やはり image_size = 224〜 の部分を実行させたところ やはり次のようなエラーが出てしまいました Found 9266 images belonging to 50 classes. --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-7-31fe6a302292> in <module>() 23 batch_size=batch_size, 24 #class_mode='binary' ---> 25 subset='validation' 26 ) 27 1 frames /usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/image_data_generator.py in flow_from_directory(self, directory, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format, follow_links, subset, interpolation) 538 follow_links=follow_links, 539 subset=subset, --> 540 interpolation=interpolation 541 ) 542 /usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/directory_iterator.py in __init__(self, directory, image_data_generator, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, data_format, save_to_dir, save_prefix, save_format, follow_links, subset, interpolation, dtype) 104 if not classes: 105 classes = [] --> 106 for subdir in sorted(os.listdir(directory)): 107 if os.path.isdir(os.path.join(directory, subdir)): 108 classes.append(subdir) FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/My Drive/images/val' この後質問を編集して上記の内容を質問に書かせていただきたいと思います
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問