Skip to content

Commit

Permalink
fix minor problem in example
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwanqq committed Feb 27, 2024
1 parent 61a4c23 commit 84767f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
- name: Run tests
run: cargo test --verbose
- name: Run fmt
run: cargo fmt --check
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
11 changes: 5 additions & 6 deletions examples/text2image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ use erniebot_rs::utils::base64_to_image;
fn main() {
let text2image = Text2ImageEndpoint::new(Text2ImageModel::StableDiffusionXL).unwrap();
let prompt = "A beautiful sunset over the ocean".to_string();
let mut options = Vec::new();
options.push(Text2ImageOpt::Style(Style::DigitalArt));
options.push(Text2ImageOpt::Size(Size::S1024x768));
let options = vec![
Text2ImageOpt::Style(Style::DigitalArt),
Text2ImageOpt::Size(Size::S1024x768),
];
let text2image_response = text2image.invoke(prompt, options).unwrap();
let image_results = text2image_response.get_image_results().unwrap();
let mut index = 0;
for image_string in image_results {
for (index, image_string) in image_results.into_iter().enumerate() {
let image = base64_to_image(image_string).unwrap();
let filepath = format!("./tmp/image_{}.png", index);
image.save(filepath).unwrap();
index += 1;
}
}

0 comments on commit 84767f7

Please sign in to comment.