Spaces:
Sleeping
Sleeping
Update app.py to try to render the image
Browse files4 unmodified lines56789101112131415164 unmodified lines21222324252627282938 unmodified lines686970717273744 unmodified linesimport yamlfrom tools.final_answer import FinalAnswerToolfrom PIL import Imagefrom Gradio_UI import GradioUI# Below is an example of a tool that does nothing. Amaze us with your creativity !@tooldef generate_image_by_description(image_description:str)-> Image.Image: #it's import to specify the return type"""A tool that generates an image based on the image_description variableArgs:image_description: the description of the image to be generated4 unmodified linesimage = image_generation_tool(image_description)# image.show()return image@tooldef display_image(image:Image.Image)-> None: #it's import to specify the return type38 unmodified linesagent = CodeAgent(model=model,tools=[final_answer, generate_image_by_description, display_image], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,4 unmodified lines5678910111213141516174 unmodified lines222324252627282930313233343536373838 unmodified lines777879808182834 unmodified linesimport yamlfrom tools.final_answer import FinalAnswerToolfrom PIL import Imagefrom io import BytesIOfrom Gradio_UI import GradioUI# Below is an example of a tool that does nothing. Amaze us with your creativity !@tooldef generate_image_by_description(image_description:str)-> BytesIO: #it's import to specify the return type"""A tool that generates an image based on the image_description variableArgs:image_description: the description of the image to be generated4 unmodified linesimage = image_generation_tool(image_description)# Normalizeif isinstance(image, list):image = image[0]elif isinstance(image, dict) and "images" in image:image = image["images"][0]buffer = BytesIO()image.save(buffer, format="PNG")buffer.seek(0)return buffer@tooldef display_image(image:Image.Image)-> None: #it's import to specify the return type38 unmodified linesagent = CodeAgent(model=model,tools=[final_answer, generate_image_by_description], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,
app.py+13-4