TensorFlow图像分类教程图像计数异常及CUDA警告问题求助
Hey there! Let's work through your two issues step by step:
1. Image Count Mismatch (492 instead of 3670)
This is most likely caused by incomplete dataset files or incorrect path configuration. Try these fixes:
- Verify your dataset is fully downloaded: The official tutorial uses the
flower_photosdataset, which has 5 subfolders (daisy,dandelion,roses,sunflowers,tulips) with a total of 3670 images. Check if all subfolders are present and have the correct number of images (e.g.,daisyshould have 633 images,dandelion898). If any are missing, re-download and extract the dataset properly. - Double-check your
data_dirpath: Make suredata_dirpoints to the root folder offlower_photos, not a subfolder. For example, if you accidentally setdata_dirto./flower_photos/daisy, it will only count images in that single subfolder. Print the path to confirm:print(data_dir) - Match all image file extensions: Some images might use uppercase extensions like
.JPGor.JPEGwhich aren't captured by*.jpg. Modify your glob pattern to cover all variations:image_count = len(list(data_dir.glob('*/*.[jJ][pP][gG]'))) # Or use a more flexible pattern: # image_count = len(list(data_dir.glob('*/*.jp*g')))
2. CUDA Dynamic Library Warning
Don't worry about this warning—it's completely harmless if you don't have an NVIDIA GPU set up:
- The message tells you that TensorFlow couldn't find the CUDA runtime library (
cudart64_110.dll), which is required for GPU acceleration. Since you don't have a GPU configured, TensorFlow will automatically fall back to using your CPU, and your code will run normally. - If you do have an NVIDIA GPU and want to enable GPU acceleration, you'll need to install the correct version of CUDA Toolkit (11.0) and matching cuDNN library for your TensorFlow version. After installation, add the CUDA
bindirectory to your system'sPATHenvironment variable.
内容的提问来源于stack exchange,提问作者SRT
相关产品推荐
相关产品推荐

