|
|
import requests |
|
|
import json |
|
|
import time |
|
|
|
|
|
def test_balanced_api(): |
|
|
"""Test the balanced quality API""" |
|
|
test_scenes = [ |
|
|
"A car driving through a city at night with neon lights", |
|
|
"A person dancing in a room with colorful lighting effects", |
|
|
"A mountain landscape with sunset and trees", |
|
|
"A modern building with glass windows reflecting sunlight" |
|
|
] |
|
|
|
|
|
print("π― TESTING BALANCED QUALITY API") |
|
|
print("=" * 60) |
|
|
|
|
|
for scene in test_scenes: |
|
|
try: |
|
|
response = requests.post( |
|
|
"http://localhost:8004/describe/scene", |
|
|
json={ |
|
|
"scene_description": scene, |
|
|
"enhance_adjectives": True, |
|
|
"adjective_density": 0.8, |
|
|
"grammar_constraint": True |
|
|
}, |
|
|
timeout=10 |
|
|
) |
|
|
|
|
|
if response.status_code == 200: |
|
|
result = response.json() |
|
|
print(f"π INPUT: {scene}") |
|
|
print(f"π¨ OUTPUT: {result['enhanced_description']}") |
|
|
print(f"β‘ TIME: {result['processing_time']:.2f}ms") |
|
|
|
|
|
|
|
|
adjectives = ['sleek', 'gleaming', 'modern', 'vibrant', 'colorful', |
|
|
'energetic', 'graceful', 'majestic', 'dramatic', 'lush'] |
|
|
output = result['enhanced_description'].lower() |
|
|
adj_count = sum(1 for adj in adjectives if adj in output) |
|
|
print(f"π ADJECTIVES: {adj_count} (Target: 2-4)") |
|
|
print("β" * 50) |
|
|
else: |
|
|
print(f"β Failed for: {scene}") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"π₯ Error: {e}") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
test_balanced_api() |
|
|
|