Spaces:
Runtime error
Runtime error
Update app.py
Browse filesAdded default tools and gaussian blur.
app.py
CHANGED
|
@@ -4,19 +4,37 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +73,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import cv2
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def gaussian_blur(image_path: str, output_path: str, kernel_size: int = 5, sigma: int = 0) -> str:
|
| 14 |
+
"""
|
| 15 |
+
Applies Gaussian blur to an image.
|
| 16 |
+
|
| 17 |
Args:
|
| 18 |
+
image_path (str): Path to the input image.
|
| 19 |
+
output_path (str): Path to save the blurred image.
|
| 20 |
+
kernel_size (int): Size of the Gaussian kernel (default is 5).
|
| 21 |
+
sigma (int): Standard deviation for Gaussian kernel (default is 0, which lets OpenCV decide).
|
| 22 |
+
|
| 23 |
+
Returns:
|
| 24 |
+
str: Path to the blurred image.
|
| 25 |
"""
|
| 26 |
+
image = cv2.imread(image_path)
|
| 27 |
+
if image is None:
|
| 28 |
+
raise ValueError(f"Could not load image from {image_path}")
|
| 29 |
+
|
| 30 |
+
# Ensure kernel_size is an odd number
|
| 31 |
+
if kernel_size % 2 == 0:
|
| 32 |
+
kernel_size += 1
|
| 33 |
+
|
| 34 |
+
blurred_image = cv2.GaussianBlur(image, (kernel_size, kernel_size), sigma)
|
| 35 |
+
cv2.imwrite(output_path, blurred_image)
|
| 36 |
+
|
| 37 |
+
return output_path
|
| 38 |
|
| 39 |
@tool
|
| 40 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 73 |
|
| 74 |
agent = CodeAgent(
|
| 75 |
model=model,
|
| 76 |
+
tools=[image_generation_tool, get_current_time_in_timezone, gaussian_blur, DuckDuckGoSearchTool(), final_answer], ## add your tools here (don't remove final answer)
|
| 77 |
max_steps=6,
|
| 78 |
verbosity_level=1,
|
| 79 |
grammar=None,
|