fix: Update labels and titles to English in plots
Browse files- app.py +4 -5
- detector.py +19 -17
app.py
CHANGED
|
@@ -60,20 +60,19 @@ def create_gradio_interface():
|
|
| 60 |
output_image, metrics = detector.detect(image, conf_thres, iou_thres)
|
| 61 |
|
| 62 |
# Create plots data
|
| 63 |
-
hist_data = pd.DataFrame({"
|
| 64 |
indices = range(
|
| 65 |
metrics["start_index"], metrics["start_index"] + len(metrics["times"])
|
| 66 |
)
|
| 67 |
|
| 68 |
line_data = pd.DataFrame(
|
| 69 |
{
|
| 70 |
-
"
|
| 71 |
-
"
|
| 72 |
-
"
|
| 73 |
}
|
| 74 |
)
|
| 75 |
|
| 76 |
-
# Criar plots
|
| 77 |
hist_fig, line_fig = detector.create_plots(hist_data, line_data)
|
| 78 |
|
| 79 |
return (
|
|
|
|
| 60 |
output_image, metrics = detector.detect(image, conf_thres, iou_thres)
|
| 61 |
|
| 62 |
# Create plots data
|
| 63 |
+
hist_data = pd.DataFrame({"Time (ms)": metrics["times"]})
|
| 64 |
indices = range(
|
| 65 |
metrics["start_index"], metrics["start_index"] + len(metrics["times"])
|
| 66 |
)
|
| 67 |
|
| 68 |
line_data = pd.DataFrame(
|
| 69 |
{
|
| 70 |
+
"Inference": indices,
|
| 71 |
+
"Time (ms)": metrics["times"],
|
| 72 |
+
"Mean": [metrics["avg_time"]] * len(metrics["times"]),
|
| 73 |
}
|
| 74 |
)
|
| 75 |
|
|
|
|
| 76 |
hist_fig, line_fig = detector.create_plots(hist_data, line_data)
|
| 77 |
|
| 78 |
return (
|
detector.py
CHANGED
|
@@ -109,16 +109,16 @@ class SignatureDetector:
|
|
| 109 |
if not metrics["times"]:
|
| 110 |
return None, None, None, None, None, None
|
| 111 |
|
| 112 |
-
hist_data = pd.DataFrame({"
|
| 113 |
indices = range(
|
| 114 |
metrics["start_index"], metrics["start_index"] + len(metrics["times"])
|
| 115 |
)
|
| 116 |
|
| 117 |
line_data = pd.DataFrame(
|
| 118 |
{
|
| 119 |
-
"
|
| 120 |
-
"
|
| 121 |
-
"
|
| 122 |
}
|
| 123 |
)
|
| 124 |
|
|
@@ -155,13 +155,13 @@ class SignatureDetector:
|
|
| 155 |
bins=20, ax=hist_ax, color="#4F46E5", alpha=0.7, edgecolor="white"
|
| 156 |
)
|
| 157 |
hist_ax.set_title(
|
| 158 |
-
"
|
| 159 |
pad=15,
|
| 160 |
fontsize=12,
|
| 161 |
color="#1f2937",
|
| 162 |
)
|
| 163 |
-
hist_ax.set_xlabel("
|
| 164 |
-
hist_ax.set_ylabel("
|
| 165 |
hist_ax.tick_params(colors="#4b5563")
|
| 166 |
hist_ax.grid(True, linestyle="--", alpha=0.3)
|
| 167 |
|
|
@@ -169,29 +169,31 @@ class SignatureDetector:
|
|
| 169 |
line_fig, line_ax = plt.subplots(figsize=(8, 4), facecolor="#f0f0f5")
|
| 170 |
line_ax.set_facecolor("#f0f0f5")
|
| 171 |
line_data.plot(
|
| 172 |
-
x="
|
| 173 |
-
y="
|
| 174 |
ax=line_ax,
|
| 175 |
color="#4F46E5",
|
| 176 |
alpha=0.7,
|
| 177 |
-
label="
|
| 178 |
)
|
| 179 |
line_data.plot(
|
| 180 |
-
x="
|
| 181 |
-
y="
|
| 182 |
ax=line_ax,
|
| 183 |
color="#DC2626",
|
| 184 |
linestyle="--",
|
| 185 |
-
label="
|
| 186 |
)
|
| 187 |
line_ax.set_title(
|
| 188 |
-
"
|
| 189 |
)
|
| 190 |
-
line_ax.set_xlabel("
|
| 191 |
-
line_ax.set_ylabel("
|
| 192 |
line_ax.tick_params(colors="#4b5563")
|
| 193 |
line_ax.grid(True, linestyle="--", alpha=0.3)
|
| 194 |
-
line_ax.legend(
|
|
|
|
|
|
|
| 195 |
|
| 196 |
hist_fig.tight_layout()
|
| 197 |
line_fig.tight_layout()
|
|
|
|
| 109 |
if not metrics["times"]:
|
| 110 |
return None, None, None, None, None, None
|
| 111 |
|
| 112 |
+
hist_data = pd.DataFrame({"Time (ms)": metrics["times"]})
|
| 113 |
indices = range(
|
| 114 |
metrics["start_index"], metrics["start_index"] + len(metrics["times"])
|
| 115 |
)
|
| 116 |
|
| 117 |
line_data = pd.DataFrame(
|
| 118 |
{
|
| 119 |
+
"Inference": indices,
|
| 120 |
+
"Time (ms)": metrics["times"],
|
| 121 |
+
"Mean": [metrics["avg_time"]] * len(metrics["times"]),
|
| 122 |
}
|
| 123 |
)
|
| 124 |
|
|
|
|
| 155 |
bins=20, ax=hist_ax, color="#4F46E5", alpha=0.7, edgecolor="white"
|
| 156 |
)
|
| 157 |
hist_ax.set_title(
|
| 158 |
+
"Distribution of Inference Times",
|
| 159 |
pad=15,
|
| 160 |
fontsize=12,
|
| 161 |
color="#1f2937",
|
| 162 |
)
|
| 163 |
+
hist_ax.set_xlabel("Time (ms)", color="#374151")
|
| 164 |
+
hist_ax.set_ylabel("Frequency", color="#374151")
|
| 165 |
hist_ax.tick_params(colors="#4b5563")
|
| 166 |
hist_ax.grid(True, linestyle="--", alpha=0.3)
|
| 167 |
|
|
|
|
| 169 |
line_fig, line_ax = plt.subplots(figsize=(8, 4), facecolor="#f0f0f5")
|
| 170 |
line_ax.set_facecolor("#f0f0f5")
|
| 171 |
line_data.plot(
|
| 172 |
+
x="Inference",
|
| 173 |
+
y="Time (ms)",
|
| 174 |
ax=line_ax,
|
| 175 |
color="#4F46E5",
|
| 176 |
alpha=0.7,
|
| 177 |
+
label="Time",
|
| 178 |
)
|
| 179 |
line_data.plot(
|
| 180 |
+
x="Inference",
|
| 181 |
+
y="Mean",
|
| 182 |
ax=line_ax,
|
| 183 |
color="#DC2626",
|
| 184 |
linestyle="--",
|
| 185 |
+
label="Mean",
|
| 186 |
)
|
| 187 |
line_ax.set_title(
|
| 188 |
+
"Inference Time per Execution", pad=15, fontsize=12, color="#1f2937"
|
| 189 |
)
|
| 190 |
+
line_ax.set_xlabel("Inference Number", color="#374151")
|
| 191 |
+
line_ax.set_ylabel("Time (ms)", color="#374151")
|
| 192 |
line_ax.tick_params(colors="#4b5563")
|
| 193 |
line_ax.grid(True, linestyle="--", alpha=0.3)
|
| 194 |
+
line_ax.legend(
|
| 195 |
+
frameon=True, facecolor="#f0f0f5", edgecolor="white", labelcolor="black"
|
| 196 |
+
)
|
| 197 |
|
| 198 |
hist_fig.tight_layout()
|
| 199 |
line_fig.tight_layout()
|