Specialized generation function for image generating models.
(self, prompt, image_name)
| 4503 | return True |
| 4504 | |
| 4505 | def text_to_image_gen(self, prompt, image_name): |
| 4506 | |
| 4507 | """ Specialized generation function for image generating models. """ |
| 4508 | |
| 4509 | from PIL import Image |
| 4510 | |
| 4511 | # experiment with different step numbers |
| 4512 | # will expose as parameter in future releases |
| 4513 | |
| 4514 | number_of_inference_steps_per_image = 10 |
| 4515 | |
| 4516 | tmp_path = LLMWareConfig().get_tmp_path() |
| 4517 | img_path = os.path.join(tmp_path, str(image_name) + ".bmp") |
| 4518 | |
| 4519 | image_tensor = self.pipe.generate(prompt, |
| 4520 | num_inference_steps=number_of_inference_steps_per_image) |
| 4521 | |
| 4522 | image = Image.fromarray(image_tensor.data[0]) |
| 4523 | image.save(img_path) |
| 4524 | |
| 4525 | return img_path |
| 4526 | |
| 4527 | def ov_token_counter(self, text): |
| 4528 |
no test coverage detected