use image::RgbImage;
use std::path::Path;
pub(crate) fn load_vocab(dict_path: &Path) -> Result<Vec<char>, String> {
let raw = std::fs::read(dict_path).map_err(|e| format!("Cannot read {:?}: {e}", dict_path))?;
let text = String::from_utf8_lossy(&raw);
let mut vocab = vec!['\0']; for line in text.lines() {
if let Some(c) = line.chars().next() {
vocab.push(c);
}
}
vocab.push(' '); Ok(vocab)
}
pub(crate) fn load_image(path: &Path) -> Result<RgbImage, String> {
image::open(path)
.map(|i| i.into_rgb8())
.map_err(|e| format!("Cannot open image {:?}: {e}", path))
}