Spaces:
Running
Running
GitHub Actions commited on
Commit ·
83b7436
1
Parent(s): 5624679
Sync from GitHub Actions
Browse files- scripts/evaluate_model.py +0 -0
- scripts/predict_image.py +0 -0
- scripts/prepare_dataset.py +0 -0
- scripts/train_baseline.py +0 -0
- setup.py +0 -9
- template.py +0 -80
- tests/test_catalog_generator.py +26 -0
- tests/test_dataset.py +0 -0
- tests/test_inference.py +0 -0
- tests/test_model.py +0 -0
- tests/test_preprocessing.py +21 -0
scripts/evaluate_model.py
DELETED
|
File without changes
|
scripts/predict_image.py
DELETED
|
File without changes
|
scripts/prepare_dataset.py
DELETED
|
File without changes
|
scripts/train_baseline.py
DELETED
|
File without changes
|
setup.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
from setuptools import setup, find_packages
|
| 2 |
-
|
| 3 |
-
setup(
|
| 4 |
-
name="autocatalogai",
|
| 5 |
-
version="0.1.0",
|
| 6 |
-
author="Md Mohsin",
|
| 7 |
-
author_email="siam.mohsin2005@gmail.com",
|
| 8 |
-
packages=find_packages()
|
| 9 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from pathlib import Path
|
| 3 |
-
|
| 4 |
-
project_name = "AutoCatalogAI"
|
| 5 |
-
list_of_files = [
|
| 6 |
-
f"{project_name}/app/app.py",
|
| 7 |
-
f"{project_name}/app/inference.py",
|
| 8 |
-
f"{project_name}/app/templates/index.html",
|
| 9 |
-
|
| 10 |
-
f"{project_name}/autocatalog/__init__.py",
|
| 11 |
-
|
| 12 |
-
f"{project_name}/autocatalog/data/__init__.py",
|
| 13 |
-
f"{project_name}/autocatalog/data/dataset.py",
|
| 14 |
-
f"{project_name}/autocatalog/data/preprocessing.py",
|
| 15 |
-
|
| 16 |
-
f"{project_name}/autocatalog/models/__init__.py",
|
| 17 |
-
f"{project_name}/autocatalog/models/multitask_clip.py",
|
| 18 |
-
f"{project_name}/autocatalog/models/heads.py",
|
| 19 |
-
|
| 20 |
-
f"{project_name}/autocatalog/training/__init__.py",
|
| 21 |
-
f"{project_name}/autocatalog/training/train.py",
|
| 22 |
-
f"{project_name}/autocatalog/training/losses.py",
|
| 23 |
-
|
| 24 |
-
f"{project_name}/autocatalog/evaluation/__init__.py",
|
| 25 |
-
f"{project_name}/autocatalog/evaluation/evaluate.py",
|
| 26 |
-
f"{project_name}/autocatalog/evaluation/metrics.py",
|
| 27 |
-
f"{project_name}/autocatalog/evaluation/error_analysis.py",
|
| 28 |
-
|
| 29 |
-
f"{project_name}/autocatalog/inference/__init__.py",
|
| 30 |
-
f"{project_name}/autocatalog/inference/predictor.py",
|
| 31 |
-
f"{project_name}/autocatalog/inference/catalog_generator.py",
|
| 32 |
-
|
| 33 |
-
f"{project_name}/autocatalog/utils/__init__.py",
|
| 34 |
-
f"{project_name}/autocatalog/utils/config.py",
|
| 35 |
-
f"{project_name}/autocatalog/utils/logger.py",
|
| 36 |
-
f"{project_name}/autocatalog/utils/seed.py",
|
| 37 |
-
|
| 38 |
-
f"{project_name}/configs/config.yaml",
|
| 39 |
-
|
| 40 |
-
f"{project_name}/data/processed/train.csv",
|
| 41 |
-
f"{project_name}/data/processed/val.csv",
|
| 42 |
-
f"{project_name}/data/processed/test.csv",
|
| 43 |
-
|
| 44 |
-
f"{project_name}/artifacts/models/.gitkeep",
|
| 45 |
-
f"{project_name}/artifacts/evaluation/.gitkeep",
|
| 46 |
-
f"{project_name}/artifacts/plots/.gitkeep",
|
| 47 |
-
f"{project_name}/artifacts/examples/.gitkeep",
|
| 48 |
-
|
| 49 |
-
f"{project_name}/notebooks/01_dataset_experiment.ipynb",
|
| 50 |
-
|
| 51 |
-
f"{project_name}/scripts/prepare_dataset.py",
|
| 52 |
-
f"{project_name}/scripts/train_baseline.py",
|
| 53 |
-
f"{project_name}/scripts/train_multitask_clip.py",
|
| 54 |
-
f"{project_name}/scripts/evaluate_model.py",
|
| 55 |
-
f"{project_name}/scripts/predict_image.py",
|
| 56 |
-
|
| 57 |
-
f"{project_name}/tests/test_dataset.py",
|
| 58 |
-
f"{project_name}/tests/test_model.py",
|
| 59 |
-
f"{project_name}/tests/test_inference.py",
|
| 60 |
-
|
| 61 |
-
f"{project_name}/.gitignore",
|
| 62 |
-
f"{project_name}/README.md",
|
| 63 |
-
f"{project_name}/model_card.md",
|
| 64 |
-
f"{project_name}/requirements.txt",
|
| 65 |
-
f"{project_name}/Dockerfile",
|
| 66 |
-
f"{project_name}/setup.py",
|
| 67 |
-
]
|
| 68 |
-
|
| 69 |
-
for filepath in list_of_files:
|
| 70 |
-
filepath = Path(filepath)
|
| 71 |
-
filedir, filename = os.path.split(filepath)
|
| 72 |
-
|
| 73 |
-
if filedir:
|
| 74 |
-
os.makedirs(filedir, exist_ok=True)
|
| 75 |
-
|
| 76 |
-
if not filepath.exists():
|
| 77 |
-
filepath.touch()
|
| 78 |
-
print(f"Created: {filepath}")
|
| 79 |
-
else:
|
| 80 |
-
print(f"Already exists: {filepath}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_catalog_generator.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from autocatalog.inference.catalog_generator import (
|
| 2 |
+
generate_catalog_output,
|
| 3 |
+
)
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def test_catalog_output():
|
| 7 |
+
predictions = {
|
| 8 |
+
"gender": "Men",
|
| 9 |
+
"masterCategory": "Apparel",
|
| 10 |
+
"subCategory": "Topwear",
|
| 11 |
+
"articleType": "Tshirts",
|
| 12 |
+
"baseColour": "Black",
|
| 13 |
+
"season": "Summer",
|
| 14 |
+
"usage": "Casual",
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
output = generate_catalog_output(predictions)
|
| 18 |
+
|
| 19 |
+
assert output["suggested_title"] == (
|
| 20 |
+
"Men Black Casual Tshirts"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
assert "black tshirts" in output["search_tags"]
|
| 24 |
+
|
| 25 |
+
assert output["json_export"]["category"] == "Apparel"
|
| 26 |
+
assert output["json_export"]["color"] == "Black"
|
tests/test_dataset.py
DELETED
|
File without changes
|
tests/test_inference.py
DELETED
|
File without changes
|
tests/test_model.py
DELETED
|
File without changes
|
tests/test_preprocessing.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from PIL import Image
|
| 3 |
+
|
| 4 |
+
from autocatalog.data.preprocessing import (
|
| 5 |
+
COLOR_FEATURE_DIM,
|
| 6 |
+
extract_color_features,
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def test_color_feature_shape_and_values():
|
| 11 |
+
image = Image.new(
|
| 12 |
+
"RGB",
|
| 13 |
+
(128, 128),
|
| 14 |
+
color=(255, 0, 0),
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
features = extract_color_features(image)
|
| 18 |
+
|
| 19 |
+
assert features.shape == (COLOR_FEATURE_DIM,)
|
| 20 |
+
assert features.dtype == np.float32
|
| 21 |
+
assert np.isfinite(features).all()
|