danielkorat commited on
Commit
328babc
·
verified ·
1 Parent(s): 4c36c35

Update tool.py

Browse files
Files changed (1) hide show
  1. tool.py +7 -3
tool.py CHANGED
@@ -7,11 +7,15 @@ from huggingface_hub import InferenceClient
7
  class TextToImageTool(Tool):
8
  description = "This tool creates an image according to a prompt, which is a text description."
9
  name = "image_generator"
10
- inputs = {"prompt": {"type": "string", "description": "The image generator prompt. Don't hesitate to add details in the prompt to make the image look better, like 'high-res, photorealistic', etc."}}
 
 
11
  output_type = "image"
12
  model_sdxl = "black-forest-labs/FLUX.1-schnell"
13
  client = InferenceClient(model_sdxl, token=os.environ["HUB_TOKEN"])
14
 
15
 
16
- def forward(self, prompt):
17
- return self.client.text_to_image(prompt)
 
 
 
7
  class TextToImageTool(Tool):
8
  description = "This tool creates an image according to a prompt, which is a text description."
9
  name = "image_generator"
10
+ inputs = {"prompt": {"type": "string", "description": "The image generator prompt. Don't hesitate to add details in the prompt to make the image look better, like 'high-res, photorealistic', etc."},
11
+ "save_path": {"type": "string", "description": "A path in `/tmp` to save the image to."}
12
+ }
13
  output_type = "image"
14
  model_sdxl = "black-forest-labs/FLUX.1-schnell"
15
  client = InferenceClient(model_sdxl, token=os.environ["HUB_TOKEN"])
16
 
17
 
18
+ def forward(self, prompt, save_path):
19
+ image = self.client.text_to_image(prompt)
20
+ image.save(save_path)
21
+ return image