Created
April 22, 2021 06:19
-
-
Save seisvelas/10b57ca0a6ed03f8cb48e2a921cc6003 to your computer and use it in GitHub Desktop.
Acquire Fashion MNIST and verify that images + labels work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate cifar_10_loader; | |
extern crate image; | |
use cifar_10_loader::CifarDataset; | |
use std::fs::File; | |
use std::collections::HashMap; | |
fn main() { | |
let mut label_ids = HashMap::new(); | |
label_ids.insert(0, "airplane"); | |
label_ids.insert(1, "automobile"); | |
label_ids.insert(2, "bird"); | |
label_ids.insert(3, "cat"); | |
label_ids.insert(4, "deer"); | |
label_ids.insert(5, "dog"); | |
label_ids.insert(6, "frog"); | |
label_ids.insert(7, "horse"); | |
label_ids.insert(8, "ship"); | |
label_ids.insert(9, "truck"); | |
let cifar10_path = "./cifar-10-batches-bin/"; | |
let cifar_dataset = CifarDataset::new(cifar10_path).unwrap(); | |
let mut buffer = File::create("foo.jpg").unwrap(); | |
cifar_dataset.train_dataset[0].image.save(&mut buffer, image::ImageFormat::JPEG); | |
println!("{}", label_ids.get(&cifar_dataset.train_dataset[0].label).unwrap()); | |
// correctly prints ship and creates jpeg of ship :D | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unwrap()
s everywhere like a noob, but it works!