arunprasadh commited on
Commit
6b1583b
·
verified ·
1 Parent(s): d97b1f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -53,16 +53,27 @@ custom_role_conversions=None,
53
  # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
54
  @tool
55
  def generate_image_from_text(prompt: str) -> None:
56
- """Generates and displays an image based on the given text prompt."""
 
 
 
 
 
 
 
 
57
  try:
 
58
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
 
 
59
  image_url = image_generation_tool(prompt)
60
 
61
  # Fetch the image from the URL
62
  response = requests.get(image_url)
63
  image = Image.open(io.BytesIO(response.content))
64
 
65
- # Display the image inline in Jupyter Notebook
66
  display.display(image)
67
 
68
  except Exception as e:
 
53
  # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
54
  @tool
55
  def generate_image_from_text(prompt: str) -> None:
56
+ """
57
+ Generates and displays an image based on the given text prompt.
58
+
59
+ Args:
60
+ prompt (str): A string describing the image to be generated.
61
+
62
+ Returns:
63
+ None: The function displays the generated image.
64
+ """
65
  try:
66
+ # Load the image generation tool
67
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
68
+
69
+ # Generate the image and get the URL
70
  image_url = image_generation_tool(prompt)
71
 
72
  # Fetch the image from the URL
73
  response = requests.get(image_url)
74
  image = Image.open(io.BytesIO(response.content))
75
 
76
+ # Display the image inline (for Jupyter Notebook)
77
  display.display(image)
78
 
79
  except Exception as e: