GitHub Actions commited on
Commit
9c5b99f
·
1 Parent(s): 749c99c

Sync from GitHub Actions

Browse files
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Md Mohsin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
app/app.py → app.py RENAMED
@@ -7,7 +7,7 @@ ROOT_DIR = Path(__file__).resolve().parents[1]
7
  if str(ROOT_DIR) not in sys.path:
8
  sys.path.insert(0, str(ROOT_DIR))
9
 
10
- from inference import (
11
  load_predictor,
12
  render_metrics,
13
  render_prediction_card,
@@ -159,9 +159,8 @@ def main():
159
 
160
  with st.spinner("Loading AutoCatalogAI V2 model..."):
161
  predictor = load_predictor(
162
- repo_id=repo_id,
163
- device=device,
164
- top_k=selected_top_k,
165
  )
166
 
167
  metrics = predictor.get_model_metrics()
 
7
  if str(ROOT_DIR) not in sys.path:
8
  sys.path.insert(0, str(ROOT_DIR))
9
 
10
+ from src.inference import (
11
  load_predictor,
12
  render_metrics,
13
  render_prediction_card,
 
159
 
160
  with st.spinner("Loading AutoCatalogAI V2 model..."):
161
  predictor = load_predictor(
162
+ repo_id=repo_id,
163
+ device=device,
 
164
  )
165
 
166
  metrics = predictor.get_model_metrics()
configs/config.yaml CHANGED
@@ -26,6 +26,7 @@ data:
26
  color_cache_path: artifacts/cache/fashion_color_features_v2.npy
27
 
28
  model:
 
29
  source_repo_id: mohsin416/autocatalogai-clip-multitask
30
  target_repo_id: mohsin416/autocatalogai-clip-multitask-v2
31
  output_dir: artifacts/models/autocatalogai_v2
@@ -86,4 +87,9 @@ evaluation:
86
  masterCategory_accuracy: 0.93
87
  subCategory_accuracy: 0.88
88
  articleType_accuracy: 0.75
89
- usage_accuracy: 0.75
 
 
 
 
 
 
26
  color_cache_path: artifacts/cache/fashion_color_features_v2.npy
27
 
28
  model:
29
+ repo_id: mohsin416/autocatalogai-clip-multitask-v2
30
  source_repo_id: mohsin416/autocatalogai-clip-multitask
31
  target_repo_id: mohsin416/autocatalogai-clip-multitask-v2
32
  output_dir: artifacts/models/autocatalogai_v2
 
87
  masterCategory_accuracy: 0.93
88
  subCategory_accuracy: 0.88
89
  articleType_accuracy: 0.75
90
+ usage_accuracy: 0.75
91
+
92
+ inference:
93
+ device: null
94
+ top_k: 3
95
+ apply_consistency_rules: true
{app → src}/inference.py RENAMED
@@ -2,31 +2,34 @@ import streamlit as st
2
  from autocatalog.inference.predictor import AutoCatalogPredictor
3
 
4
  @st.cache_resource(show_spinner=False)
5
- def load_predictor(repo_id, device, top_k):
6
  return AutoCatalogPredictor(
7
  repo_id=repo_id,
8
- top_k=top_k
9
  )
10
-
11
-
12
  def format_percent(value):
13
  return f"{value * 100:.2f}%"
14
 
15
-
16
  def render_prediction_card(task_name, task_result):
17
  label = task_result["label"]
18
  confidence = task_result["confidence"]
19
-
20
  st.markdown(
21
  f"""
22
  <div class="prediction-card">
23
  <div class="prediction-header">
24
  <span class="task-name">{task_name}</span>
25
- <span class="confidence">{format_percent(confidence)}</span>
 
 
26
  </div>
27
  <div class="label">{label}</div>
28
  <div class="bar-bg">
29
- <div class="bar-fill" style="width: {confidence * 100:.2f}%"></div>
 
 
 
30
  </div>
31
  </div>
32
  """,
@@ -37,25 +40,53 @@ def render_top_predictions(prediction):
37
  with st.expander("View Top-3 Predictions"):
38
  for task, result in prediction.items():
39
  st.markdown(f"**{task}**")
40
-
41
  for item in result["top_3"]:
42
- st.write(f"{item['label']} — {format_percent(item['confidence'])}")
 
 
 
43
 
44
  st.divider()
45
-
46
 
47
  def render_metrics(metrics):
48
  if not metrics:
49
  return
50
 
51
- overall = metrics.get("overall_metrics", {})
52
  if not overall:
53
  return
54
 
55
  st.subheader("Model Evaluation")
56
  col1, col2, col3, col4 = st.columns(4)
57
-
58
- col1.metric("Average Accuracy", format_percent(overall.get("average_accuracy", 0)))
59
- col2.metric("Weighted F1", format_percent(overall.get("average_weighted_f1", 0)))
60
- col3.metric("Top-3 Accuracy", format_percent(overall.get("average_top3_accuracy", 0)))
61
- col4.metric("Test Samples", f"{overall.get('samples', 0):,}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from autocatalog.inference.predictor import AutoCatalogPredictor
3
 
4
  @st.cache_resource(show_spinner=False)
5
+ def load_predictor(repo_id, device=None):
6
  return AutoCatalogPredictor(
7
  repo_id=repo_id,
8
+ device=device,
9
  )
10
+
 
11
  def format_percent(value):
12
  return f"{value * 100:.2f}%"
13
 
 
14
  def render_prediction_card(task_name, task_result):
15
  label = task_result["label"]
16
  confidence = task_result["confidence"]
17
+
18
  st.markdown(
19
  f"""
20
  <div class="prediction-card">
21
  <div class="prediction-header">
22
  <span class="task-name">{task_name}</span>
23
+ <span class="confidence">
24
+ {format_percent(confidence)}
25
+ </span>
26
  </div>
27
  <div class="label">{label}</div>
28
  <div class="bar-bg">
29
+ <div
30
+ class="bar-fill"
31
+ style="width: {confidence * 100:.2f}%"
32
+ ></div>
33
  </div>
34
  </div>
35
  """,
 
40
  with st.expander("View Top-3 Predictions"):
41
  for task, result in prediction.items():
42
  st.markdown(f"**{task}**")
 
43
  for item in result["top_3"]:
44
+ st.write(
45
+ f"{item['label']} — "
46
+ f"{format_percent(item['confidence'])}"
47
+ )
48
 
49
  st.divider()
50
+
51
 
52
  def render_metrics(metrics):
53
  if not metrics:
54
  return
55
 
56
+ overall = metrics.get("overall_metrics",{},)
57
  if not overall:
58
  return
59
 
60
  st.subheader("Model Evaluation")
61
  col1, col2, col3, col4 = st.columns(4)
62
+ col1.metric(
63
+ "Average Accuracy",
64
+ format_percent(
65
+ overall.get(
66
+ "average_accuracy",
67
+ 0,
68
+ )
69
+ ),
70
+ )
71
+ col2.metric(
72
+ "Weighted F1",
73
+ format_percent(
74
+ overall.get(
75
+ "average_weighted_f1",
76
+ 0,
77
+ )
78
+ ),
79
+ )
80
+ col3.metric(
81
+ "Top-3 Accuracy",
82
+ format_percent(
83
+ overall.get(
84
+ "average_top3_accuracy",
85
+ 0,
86
+ )
87
+ ),
88
+ )
89
+ col4.metric(
90
+ "Test Samples",
91
+ f"{overall.get('samples', 0):,}",
92
+ )