hibam1 commited on
Commit ·
110c1d8
1
Parent(s): 15c82ee
test vision agent
Browse files- vision_agents.py +34 -0
vision_agents.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import requests
|
| 3 |
+
from io import BytesIO
|
| 4 |
+
from smolagents import CodeAgent, OpenAIServerModel
|
| 5 |
+
from model import model
|
| 6 |
+
|
| 7 |
+
joker_image_urls = [
|
| 8 |
+
"https://upload.wikimedia.org/wikipedia/commons/e/e8/The_Joker_at_Wax_Museum_Plus.jpg", # Joker image
|
| 9 |
+
"https://upload.wikimedia.org/wikipedia/en/9/98/Joker_%28DC_Comics_character%29.jpg" # Joker image
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
byte_joker_images = []
|
| 13 |
+
for url in joker_image_urls:
|
| 14 |
+
headers = {
|
| 15 |
+
"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"
|
| 16 |
+
}
|
| 17 |
+
response = requests.get(url,headers=headers)
|
| 18 |
+
image = Image.open(BytesIO(response.content)).convert("RGB")
|
| 19 |
+
byte_joker_images.append(image)
|
| 20 |
+
|
| 21 |
+
agent = CodeAgent(
|
| 22 |
+
tools=[],
|
| 23 |
+
model=model,
|
| 24 |
+
max_steps=20,
|
| 25 |
+
verbosity_level=2
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
response = agent.run(
|
| 29 |
+
"""
|
| 30 |
+
Describe the costume and makeup that the comic character in these photos is wearing and return the description.
|
| 31 |
+
Tell me if the guest is The Joker or Wonder Woman.
|
| 32 |
+
""",
|
| 33 |
+
images=byte_joker_images
|
| 34 |
+
)
|