Merlintxu commited on
Commit
40507b0
1 Parent(s): 206183d

modified: README.md

Browse files

new file: configs/models.yaml
new file: tests/test_analyzer.py

Files changed (3) hide show
  1. README.md +35 -13
  2. configs/models.yaml +14 -0
  3. tests/test_analyzer.py +38 -0
README.md CHANGED
@@ -1,13 +1,35 @@
1
- ---
2
- title: Arte Analyzer
3
- emoji: 馃弳
4
- colorFrom: red
5
- colorTo: indigo
6
- sdk: gradio
7
- sdk_version: 5.29.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Art Transformer 馃帹
2
+
3
+ Automatiza el an谩lisis y transformaci贸n de 谩lbumes de arte usando IA.
4
+
5
+ ## Caracter铆sticas Principales
6
+ - An谩lisis autom谩tico de obras de arte
7
+ - Generaci贸n de marcos personalizados
8
+ - Integraci贸n con Google Photos
9
+ - Interfaz web con Gradio
10
+
11
+ ## Configuraci贸n en Hugging Face Spaces
12
+
13
+ 1. **Variables de Entorno:**
14
+ ```env
15
+ OPENAI_API_KEY=your_openai_key
16
+ GOOGLE_CLIENT_SECRET=your_google_client_secret
17
+ ```
18
+
19
+ 2. **Hardware:**
20
+ - GPU recomendada
21
+ - Memoria: Al menos 16GB
22
+
23
+ 3. **Ejecuci贸n:**
24
+ ```bash
25
+ pip install -r requirements.txt
26
+ python app.py
27
+ ```
28
+
29
+ ## Uso
30
+ 1. Sube tus im谩genes
31
+ 2. Selecciona prioridad
32
+ 3. Espera los resultados
33
+ 4. Descarga las obras transformadas
34
+
35
+ ![Demo Interface](demo_screenshot.png)
configs/models.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ default_models:
2
+ captioning: "Salesforce/blip2-opt-2.7b"
3
+ style_classifier: "dima806/art_painting_style_detection"
4
+ color_detector: "google/color-detector"
5
+ art_analysis: "ArtGAN/art-critique-generator"
6
+
7
+ model_params:
8
+ captioning:
9
+ max_new_tokens: 150
10
+ temperature: 0.7
11
+
12
+ art_analysis:
13
+ max_new_tokens: 250
14
+ temperature: 0.9
tests/test_analyzer.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from image_processor.analyzer import ImageAnalyzer
3
+ from PIL import Image
4
+ import numpy as np
5
+ import logging
6
+
7
+ @pytest.fixture
8
+ def sample_image():
9
+ return Image.fromarray(np.random.randint(0, 255, (512, 512, 3), 'RGB')
10
+
11
+ def test_initialization():
12
+ analyzer = ImageAnalyzer(device="cpu")
13
+ assert analyzer.models is not None
14
+ assert 'captioning' in analyzer.models
15
+
16
+ def test_image_analysis(sample_image):
17
+ analyzer = ImageAnalyzer(device="cpu")
18
+ results = analyzer.analyze_image(sample_image)
19
+
20
+ assert isinstance(results, dict)
21
+ assert 'title' in results
22
+ assert 'style' in results
23
+ assert len(results['colors']) == 5
24
+
25
+ def test_error_handling():
26
+ analyzer = ImageAnalyzer(device="cpu")
27
+ invalid_input = "not_an_image"
28
+
29
+ with pytest.raises(Exception):
30
+ analyzer.analyze_image(invalid_input)
31
+
32
+ def test_color_detection(sample_image):
33
+ analyzer = ImageAnalyzer(device="cpu")
34
+ colors = analyzer._get_colors(sample_image)
35
+
36
+ assert len(colors) == 5
37
+ assert all('hex' in c for c in colors)
38
+ assert all(0 <= c['score'] <= 1 for c in colors)