MCPcopy
hub / github.com/llmware-ai/llmware / text_to_image_gen

Method text_to_image_gen

llmware/models.py:4505–4525  ·  view source on GitHub ↗

Specialized generation function for image generating models.

(self, prompt, image_name)

Source from the content-addressed store, hash-verified

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

Callers 2

image_gen_botFunction · 0.80
image_gen_botFunction · 0.80

Calls 3

LLMWareConfigClass · 0.90
get_tmp_pathMethod · 0.80
generateMethod · 0.45

Tested by

no test coverage detected