Skip to content

Commit

Permalink
Update text2image genai notebook (openvinotoolkit#2660)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Jan 16, 2025
1 parent 383cfbd commit 231f963
Show file tree
Hide file tree
Showing 2 changed files with 406 additions and 35 deletions.
10 changes: 10 additions & 0 deletions notebooks/text-to-image-genai/gradio_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import gradio as gr
import numpy as np
from tqdm.auto import tqdm
import sys

import openvino_genai as ov_genai

Expand Down Expand Up @@ -30,6 +32,13 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, num_infe

generator = generator_cls(seed)

pbar = tqdm(total=num_inference_steps)

def callback(step, num_steps, latent):
pbar.update(1)
sys.stdout.flush()
return False

image_tensor = pipeline.generate(
prompt=prompt,
negative_prompt=negative_prompt,
Expand All @@ -38,6 +47,7 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, num_infe
height=height,
generator=generator,
adapters=adapter_config if use_lora else ov_genai.AdapterConfig(),
callback=callback,
)

return image_tensor.data[0], seed
Expand Down
Loading

0 comments on commit 231f963

Please sign in to comment.