Download vision_agents.py from hibanail/First_agent_template: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/hibanail/First_agent_template/resolve/main/vision_agents.py
- Command line
-
hf download hf://hibanail/First_agent_template/vision_agents.py
-
curl -L -o vision_agents.py https://huggingface.co/hibanail/First_agent_template/resolve/main/vision_agents.py
1.07 kB
| from PIL import Image | |
| import requests | |
| from io import BytesIO | |
| from smolagents import CodeAgent, OpenAIServerModel | |
| from model import model | |
| joker_image_urls = [ | |
| "https://upload.wikimedia.org/wikipedia/commons/e/e8/The_Joker_at_Wax_Museum_Plus.jpg", # Joker image | |
| "https://upload.wikimedia.org/wikipedia/en/9/98/Joker_%28DC_Comics_character%29.jpg" # Joker image | |
| ] | |
| byte_joker_images = [] | |
| for url in joker_image_urls: | |
| headers = { | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" | |
| } | |
| response = requests.get(url,headers=headers) | |
| image = Image.open(BytesIO(response.content)).convert("RGB") | |
| byte_joker_images.append(image) | |
| agent = CodeAgent( | |
| tools=[], | |
| model=model, | |
| max_steps=20, | |
| verbosity_level=2 | |
| ) | |
| response = agent.run( | |
| """ | |
| Describe the costume and makeup that the comic character in these photos is wearing and return the description. | |
| Tell me if the guest is The Joker or Wonder Woman. | |
| """, | |
| images=byte_joker_images | |
| ) |