Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 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:
|