Spaces:
Sleeping
Sleeping
Alexandros Popov
commited on
Commit
·
291c5d0
1
Parent(s):
4dbf90f
first implementation of agents.
Browse files- .gitignore +1 -0
- agents.py +14 -0
.gitignore
CHANGED
|
@@ -8,3 +8,4 @@ wheels/
|
|
| 8 |
|
| 9 |
# Virtual environments
|
| 10 |
.venv
|
|
|
|
|
|
| 8 |
|
| 9 |
# Virtual environments
|
| 10 |
.venv
|
| 11 |
+
.env
|
agents.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, HfApiModel, tool
|
| 2 |
+
from filters import *
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
HUGGING_FACE_TOKEN = os.environ["HUGGING_FACE_TOKEN"]
|
| 6 |
+
|
| 7 |
+
# Initialize the model and agent
|
| 8 |
+
model = HfApiModel(token=HUGGING_FACE_TOKEN)
|
| 9 |
+
agent = CodeAgent(tools=[adjust_contrast, load_image_as_bgr, save_image], model=model)
|
| 10 |
+
|
| 11 |
+
# Run the agent
|
| 12 |
+
agent.run("Adjust the contrast of the image in image_path by a factor of 1.5. Save the image to output_path.",
|
| 13 |
+
additional_args={'image_path': 'toa-heftiba-Xmn-QXsVL4k-unsplash.jpg',
|
| 14 |
+
"output_path": 'adjusted_image.jpg'})
|