Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,9 +49,6 @@ custom_role_conversions=None,
|
|
| 49 |
# Import tool from Hub
|
| 50 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 51 |
|
| 52 |
-
print("Image tool name:", image_generation_tool.name)
|
| 53 |
-
print("Image tool:", image_generation_tool)
|
| 54 |
-
|
| 55 |
with open("prompts.yaml", 'r') as stream:
|
| 56 |
prompt_templates = yaml.safe_load(stream)
|
| 57 |
|
|
@@ -67,12 +64,17 @@ agent = CodeAgent(
|
|
| 67 |
prompt_templates=prompt_templates
|
| 68 |
)
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
GradioUI(agent).launch()
|
|
|
|
| 49 |
# Import tool from Hub
|
| 50 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 51 |
|
|
|
|
|
|
|
|
|
|
| 52 |
with open("prompts.yaml", 'r') as stream:
|
| 53 |
prompt_templates = yaml.safe_load(stream)
|
| 54 |
|
|
|
|
| 64 |
prompt_templates=prompt_templates
|
| 65 |
)
|
| 66 |
|
| 67 |
+
img = image_generation_tool(prompt="A cute cat with prominent moustaches, photorealistic, high-resolution")
|
| 68 |
+
|
| 69 |
+
print("Returned type:", type(img))
|
| 70 |
+
print("Returned value:", img)
|
| 71 |
|
| 72 |
+
# If it's a PIL image, this will work:
|
| 73 |
+
try:
|
| 74 |
+
img.save("/tmp/test.png")
|
| 75 |
+
print("Saved to /tmp/test.png")
|
| 76 |
+
except Exception as e:
|
| 77 |
+
print("Could not save as PIL:", e)
|
| 78 |
|
| 79 |
|
| 80 |
GradioUI(agent).launch()
|