updated documentation and added “None” option for image description
This commit is contained in:
parent
67a1bd8835
commit
a560797f20
7 changed files with 79 additions and 20 deletions
|
@ -41,21 +41,27 @@ struct LlamaModel {
|
|||
pub fn get_description_from_file(
|
||||
image_name: String,
|
||||
file_config: FileConfig,
|
||||
) -> Result<String, Box<dyn super::Error>> {
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
//read image caption from a local file that
|
||||
//has the same name than the image with the extension ".caption.txt"
|
||||
let caption_extension = file_config.caption_extension;
|
||||
let captionname = format!("{}{}", &image_name, caption_extension);
|
||||
|
||||
debug!("Looking for {}", &captionname);
|
||||
let caption_data = std::fs::read_to_string(captionname);
|
||||
let caption_data = match std::fs::read_to_string(captionname) {
|
||||
Ok(caption) => caption,
|
||||
Err(e) => {
|
||||
error!("Failed to find caption file: {}", &e.to_string());
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
println!(
|
||||
"Description fetched successfully from FILE for {}",
|
||||
&image_name
|
||||
);
|
||||
|
||||
Ok(caption_data.unwrap())
|
||||
Ok(caption_data)
|
||||
}
|
||||
|
||||
// fetch image description from ChatGPT
|
||||
|
|
|
@ -42,6 +42,8 @@ enum Mode {
|
|||
File,
|
||||
/// Local LLM
|
||||
Local,
|
||||
// No Image Description
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
|
@ -129,6 +129,11 @@ pub fn bulk_upload_images(
|
|||
info!("Description generated by OLLAMA: {}", &description.clone());
|
||||
media_descriptions.push(description.clone());
|
||||
}
|
||||
super::Mode::None => {
|
||||
// No impage description wanted
|
||||
description = "".to_string();
|
||||
media_descriptions.push(description.clone())
|
||||
}
|
||||
}
|
||||
|
||||
println!("Uploading image {} to Pixelfed", &image_path.to_string());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue