| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,6 +58,7 @@ public IDatasetV2 image_dataset_from_directory(string directory, | |||
| 58 | 58 | if (shuffle) | |
| 59 | 59 | dataset = dataset.shuffle(batch_size * 8, seed: seed); | |
| 60 | 60 | dataset = dataset.batch(batch_size); | |
| 61 | + dataset.class_names = class_name_list; | ||
| 61 | 62 | return dataset; | |
| 62 | 63 | } | |
| 63 | 64 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,31 @@ namespace Tensorflow.Keras | |||
| 6 | 6 | { | |
| 7 | 7 | public partial class Preprocessing | |
| 8 | 8 | { | |
| 9 | + | ||
| 10 | + /// <summary> | ||
| 11 | + /// 图片路径转为数据处理用的dataset | ||
| 12 | + /// </summary> | ||
| 13 | + /// <param name="image_paths"></param> | ||
| 14 | + /// <param name="image_size"></param> | ||
| 15 | + /// <param name="num_channels"></param> | ||
| 16 | + /// <param name="interpolation"> | ||
| 17 | + /// 用于调整大小的插值方法。支持`bilinear`、`nearest`、`bicubic`、`area`、`lanczos3`、`lanczos5`、`gaussian`、`mitchellcubic`。 | ||
| 18 | + /// 默认为`'bilinear'`。 | ||
| 19 | + /// </param> | ||
| 20 | + /// <returns></returns> | ||
| 21 | + public IDatasetV2 paths_to_dataset(string[] image_paths, | ||
| 22 | + Shape image_size, | ||
| 23 | + int num_channels = 3, | ||
| 24 | + int num_classes = 6, | ||
| 25 | + string interpolation = "bilinear") | ||
| 26 | + { | ||
| 27 | + var path_ds = tf.data.Dataset.from_tensor_slices(image_paths); | ||
| 28 | + var img_ds = path_ds.map(x => path_to_image(x, image_size, num_channels, interpolation)); | ||
| 29 | + var label_ds = dataset_utils.labels_to_dataset(new int[num_classes] , "", num_classes); | ||
| 30 | + | ||
| 31 | + return img_ds; | ||
| 32 | + } | ||
| 33 | + | ||
| 9 | 34 | public IDatasetV2 paths_and_labels_to_dataset(string[] image_paths, | |
| 10 | 35 | Shape image_size, | |
| 11 | 36 | int num_channels, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments