Spaces:
Sleeping
Sleeping
Alexandros Popov
commited on
Commit
·
5406cd8
0
Parent(s):
initial commit.
Browse files- .gitignore +10 -0
- .python-version +1 -0
- README.md +9 -0
- app.py +22 -0
- evaluators.py +13 -0
- filters.py +15 -0
- pyproject.toml +12 -0
- uv.lock +0 -0
.gitignore
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python-generated files
|
2 |
+
__pycache__/
|
3 |
+
*.py[oc]
|
4 |
+
build/
|
5 |
+
dist/
|
6 |
+
wheels/
|
7 |
+
*.egg-info
|
8 |
+
|
9 |
+
# Virtual environments
|
10 |
+
.venv
|
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.10
|
README.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AI Art Director – Filter Showdown
|
2 |
+
|
3 |
+
Upload an image. Agents apply multiple filters and pick the best one based on quality metrics.
|
4 |
+
|
5 |
+
## Features
|
6 |
+
|
7 |
+
- Multiple preset filters
|
8 |
+
- Sharpness-based evaluation
|
9 |
+
- Simple Gradio UI
|
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from filters import apply_filters
|
3 |
+
from evaluators import evaluate_filters
|
4 |
+
|
5 |
+
def process_image(image):
|
6 |
+
filtered_images = apply_filters(image)
|
7 |
+
best_index, reasons = evaluate_filters(filtered_images)
|
8 |
+
return filtered_images, f"Winner: Filter {best_index + 1} — {reasons[best_index]}"
|
9 |
+
|
10 |
+
demo = gr.Interface(
|
11 |
+
fn=process_image,
|
12 |
+
inputs=gr.Image(type="pil"),
|
13 |
+
outputs=[
|
14 |
+
gr.Gallery(label="Filtered Options"),
|
15 |
+
gr.Textbox(label="Critique Agent's Verdict")
|
16 |
+
],
|
17 |
+
title="🧠 AI Art Director – Filter Showdown",
|
18 |
+
description="Upload an image and let AI agents apply, evaluate, and pick the best filter."
|
19 |
+
)
|
20 |
+
|
21 |
+
if __name__ == "__main__":
|
22 |
+
demo.launch()
|
evaluators.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import cv2
|
3 |
+
|
4 |
+
def score_image(pil_img):
|
5 |
+
img = np.array(pil_img.convert("L"))
|
6 |
+
variance = cv2.Laplacian(img, cv2.CV_64F).var()
|
7 |
+
return variance
|
8 |
+
|
9 |
+
def evaluate_filters(images):
|
10 |
+
scores = [score_image(img) for img in images]
|
11 |
+
best_index = int(np.argmax(scores))
|
12 |
+
reasons = [f"Sharpness score: {s:.2f}" for s in scores]
|
13 |
+
return best_index, reasons
|
filters.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import ImageEnhance
|
2 |
+
|
3 |
+
def apply_filters(image):
|
4 |
+
filters = []
|
5 |
+
|
6 |
+
# Filter 1: Brightness boost
|
7 |
+
filters.append(ImageEnhance.Brightness(image).enhance(1.3))
|
8 |
+
|
9 |
+
# Filter 2: Contrast boost
|
10 |
+
filters.append(ImageEnhance.Contrast(image).enhance(1.5))
|
11 |
+
|
12 |
+
# Filter 3: Color boost
|
13 |
+
filters.append(ImageEnhance.Color(image).enhance(1.8))
|
14 |
+
|
15 |
+
return filters
|
pyproject.toml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[project]
|
2 |
+
name = "ai-art-director"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = "Add your description here"
|
5 |
+
readme = "README.md"
|
6 |
+
requires-python = ">=3.10"
|
7 |
+
dependencies = [
|
8 |
+
"gradio>=5.32.1",
|
9 |
+
"numpy>=2.2.6",
|
10 |
+
"opencv-python>=4.11.0.86",
|
11 |
+
"pillow>=11.2.1",
|
12 |
+
]
|
uv.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|