Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,22 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 13 |
@tool
|
| 14 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
from smolagents import Tool
|
| 11 |
+
from huggingface_hub import InferenceClient
|
| 12 |
|
| 13 |
|
| 14 |
+
class TextToImageTool(Tool):
|
| 15 |
+
description = "This tool creates an image according to a prompt, which is a text description."
|
| 16 |
+
name = "image_generator"
|
| 17 |
+
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."}}
|
| 18 |
+
output_type = "image"
|
| 19 |
+
model_sdxl = "black-forest-labs/FLUX.1-schnell"
|
| 20 |
+
client = InferenceClient(model_sdxl)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def forward(self, prompt):
|
| 24 |
+
return self.client.text_to_image(prompt)
|
| 25 |
+
|
| 26 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 27 |
@tool
|
| 28 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|