deepforge-research-toolkit 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deepforge/__init__.py +3 -0
- deepforge/__main__.py +3 -0
- deepforge/advanced.py +117 -0
- deepforge/assets/icon.png +0 -0
- deepforge/assets/xvarna.png +0 -0
- deepforge/assets/xvarna_about.png +0 -0
- deepforge/assets/xvarna_sidebar.png +0 -0
- deepforge/audit.py +192 -0
- deepforge/automation.py +143 -0
- deepforge/checkpoint.py +155 -0
- deepforge/checkpoint_config.py +20 -0
- deepforge/checkpoint_torch.py +62 -0
- deepforge/checkpoint_yolo.py +18 -0
- deepforge/cli.py +119 -0
- deepforge/datasets.py +61 -0
- deepforge/diagnostics.py +67 -0
- deepforge/environment.py +26 -0
- deepforge/gui.py +579 -0
- deepforge/gui_data.py +119 -0
- deepforge/history.py +41 -0
- deepforge/live_view.py +100 -0
- deepforge/metrics.py +40 -0
- deepforge/models.py +19 -0
- deepforge/monitor.py +152 -0
- deepforge/notebook.py +73 -0
- deepforge/preview.py +20 -0
- deepforge/profiler.py +283 -0
- deepforge/reporting.py +118 -0
- deepforge/resources.py +24 -0
- deepforge/samples/dataset/test/square/sample_d.png +0 -0
- deepforge/samples/dataset/train/circle/sample_a.png +0 -0
- deepforge/samples/dataset/train/square/sample_b.png +0 -0
- deepforge/samples/dataset/val/circle/sample_c.png +0 -0
- deepforge/samples/groups.csv +6 -0
- deepforge/samples/history.csv +5 -0
- deepforge/samples/predictions.csv +5 -0
- deepforge/samples/runs/baseline.csv +5 -0
- deepforge/samples/runs/refined.csv +5 -0
- deepforge/samples/scores.csv +9 -0
- deepforge/samples/yolo/images/test/sample.png +0 -0
- deepforge/samples/yolo/images/train/sample.png +0 -0
- deepforge/samples/yolo/images/val/sample.png +0 -0
- deepforge/samples/yolo/labels/test/sample.txt +1 -0
- deepforge/samples/yolo/labels/train/sample.txt +1 -0
- deepforge/samples/yolo/labels/val/sample.txt +1 -0
- deepforge/training.py +118 -0
- deepforge/ultralytics.py +58 -0
- deepforge_research_toolkit-0.7.1.dist-info/METADATA +462 -0
- deepforge_research_toolkit-0.7.1.dist-info/RECORD +53 -0
- deepforge_research_toolkit-0.7.1.dist-info/WHEEL +5 -0
- deepforge_research_toolkit-0.7.1.dist-info/entry_points.txt +4 -0
- deepforge_research_toolkit-0.7.1.dist-info/licenses/LICENSE +21 -0
- deepforge_research_toolkit-0.7.1.dist-info/top_level.txt +1 -0
deepforge/gui.py
ADDED
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
"""DeepForge Studio: local-first desktop research workspaces."""
|
|
2
|
+
import json
|
|
3
|
+
import queue
|
|
4
|
+
import threading
|
|
5
|
+
import tkinter as tk
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from tkinter import filedialog, messagebox, ttk
|
|
9
|
+
|
|
10
|
+
from . import __version__
|
|
11
|
+
from .gui_data import TOOLS, analyze, summary, preview_threshold
|
|
12
|
+
from .reporting import export_report, table_rows, finding_rows
|
|
13
|
+
|
|
14
|
+
BG, PANEL, SIDEBAR, INK, MUTED = '#F3EFE5', '#FFFCF5', '#123B32', '#183C33', '#536B60'
|
|
15
|
+
ACCENT, GOLD, LINE, ERROR = '#12664F', '#8A651E', '#DDDCD0', '#A3353D'
|
|
16
|
+
SIDE_INK, SIDE_MUTED, SIDE_GOLD, SIDE_ACTIVE = '#FAF4E6', '#B6CDBF', '#E8C77D', '#235A49'
|
|
17
|
+
COLORS = (ACCENT, GOLD, '#476F9A', ERROR)
|
|
18
|
+
ASSETS = Path(__file__).parent / 'assets'
|
|
19
|
+
ICONS = {'Home':'01','Dataset':'02','Leakage':'03','Images':'04','Groups':'05','YOLO':'06','Training':'07','Compare':'08','Metrics':'09','Scores':'10','Model':'11','Environment':'12','Manifest':'13'}
|
|
20
|
+
GROUPS = {
|
|
21
|
+
'DATA QUALITY': ('Dataset', 'Leakage', 'Images', 'Groups', 'YOLO'),
|
|
22
|
+
'EXPERIMENTS': ('Training', 'Compare', 'Metrics', 'Scores'),
|
|
23
|
+
'SYSTEM & MODEL': ('Model', 'Environment', 'Manifest'),
|
|
24
|
+
}
|
|
25
|
+
NAMES = {'Dataset':'Dataset inspector','Leakage':'Exact duplicates','Images':'Image integrity', 'Groups':'Group leakage', 'YOLO':'YOLO labels', 'Training':'Learning curves','Compare':'Compare runs','Metrics':'Classification','Scores':'Binary scores','Model':'Model inspector','Environment':'Runtime','Manifest':'Reproducibility'}
|
|
26
|
+
DIR_TOOLS = {'Dataset','Leakage','Images','YOLO','Compare'}
|
|
27
|
+
DEMO_FILES = {'Training':'history.csv','Metrics':'predictions.csv','Scores':'scores.csv','Groups':'groups.csv'}
|
|
28
|
+
DEMO_DIRS = {'Dataset':'dataset','Leakage':'dataset','Images':'dataset','YOLO':'yolo','Compare':'runs'}
|
|
29
|
+
DEMOS = {**DEMO_FILES, **DEMO_DIRS}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Studio:
|
|
33
|
+
def __init__(self, root):
|
|
34
|
+
self.root = root
|
|
35
|
+
root.title(f'DeepForge Studio | {__version__}')
|
|
36
|
+
root.geometry('1440x900'); root.minsize(1000, 720); root.configure(bg=BG)
|
|
37
|
+
self.tool, self.busy, self.report, self.chart = 'Home', False, None, None
|
|
38
|
+
self.results, self.fields, self.nav = queue.Queue(), {}, {}
|
|
39
|
+
self.recent, self.current_opts = [], {}
|
|
40
|
+
self.saved_fields, self.chart_points = {}, []
|
|
41
|
+
self.sidebar_visible = True
|
|
42
|
+
self.nav_query = tk.StringVar()
|
|
43
|
+
self.find_query = tk.StringVar()
|
|
44
|
+
self.nav_sections = []
|
|
45
|
+
self.chart_mode = tk.StringVar(value='ROC')
|
|
46
|
+
self.style = ttk.Style(root); self.style.theme_use('clam')
|
|
47
|
+
self.font = 'Segoe UI' if root.tk.call('tk', 'windowingsystem') == 'win32' else 'DejaVu Sans'
|
|
48
|
+
self.configure_style()
|
|
49
|
+
self.side = side = tk.Frame(root, bg=SIDEBAR, width=248); side.pack(side='left', fill='y'); side.pack_propagate(False)
|
|
50
|
+
self.logo = self.load_brand_image('xvarna_sidebar.png')
|
|
51
|
+
self.app_icon = self.load_brand_image('icon.png')
|
|
52
|
+
root.iconphoto(True, self.app_icon)
|
|
53
|
+
brand = tk.Frame(side, bg=SIDEBAR); brand.pack(fill='x', padx=20, pady=(16,10))
|
|
54
|
+
tk.Label(brand,image=self.logo,bg=SIDEBAR).pack(anchor='w')
|
|
55
|
+
self.label(brand,'DEEPFORGE',17,SIDE_INK,SIDEBAR,True).pack(anchor='w',pady=(8,0))
|
|
56
|
+
self.label(brand,'RESEARCH STUDIO',9,SIDE_GOLD,SIDEBAR,True).pack(anchor='w')
|
|
57
|
+
foot = tk.Frame(side,bg=SIDEBAR); foot.pack(side='bottom',fill='x',padx=16,pady=10)
|
|
58
|
+
tk.Frame(foot,bg=SIDE_ACTIVE,height=1).pack(fill='x',pady=(0,8))
|
|
59
|
+
self.label(foot,'Alireza Khatibi',10,SIDE_INK,SIDEBAR,True).pack(anchor='w')
|
|
60
|
+
self.label(foot,f'XVARNA / v{__version__}',8,SIDE_GOLD,SIDEBAR).pack(anchor='w',pady=(3,0))
|
|
61
|
+
search = tk.Frame(side,bg=SIDEBAR); search.pack(fill='x',padx=16,pady=(0,8))
|
|
62
|
+
self.label(search,'FIND A WORKSPACE',8,SIDE_MUTED,SIDEBAR,True).pack(anchor='w',pady=(0,4))
|
|
63
|
+
self.search_entry = ttk.Entry(search,textvariable=self.nav_query); self.search_entry.pack(fill='x')
|
|
64
|
+
self.search_entry.bind('<Return>',self.open_first_match)
|
|
65
|
+
nav_area=tk.Frame(side,bg=SIDEBAR); nav_area.pack(fill='both',expand=True)
|
|
66
|
+
nav_canvas=tk.Canvas(nav_area,bg=SIDEBAR,highlightthickness=0)
|
|
67
|
+
nav_scroll=ttk.Scrollbar(nav_area,style='Side.Vertical.TScrollbar',command=nav_canvas.yview)
|
|
68
|
+
nav_canvas.configure(yscrollcommand=lambda a,b:self.auto_scroll(nav_scroll,a,b)); nav_canvas.pack(side='left',fill='both',expand=True)
|
|
69
|
+
nav_body=tk.Frame(nav_canvas,bg=SIDEBAR); nav_window=nav_canvas.create_window((0,0),window=nav_body,anchor='nw')
|
|
70
|
+
nav_body.bind('<Configure>',lambda _:nav_canvas.configure(scrollregion=nav_canvas.bbox('all')))
|
|
71
|
+
nav_canvas.bind('<Configure>',lambda e:nav_canvas.itemconfigure(nav_window,width=e.width))
|
|
72
|
+
self.nav_canvas=nav_canvas
|
|
73
|
+
self.nav_button(nav_body,'Home','Overview')
|
|
74
|
+
for group, tools in GROUPS.items():
|
|
75
|
+
heading=self.label(nav_body,group,8,SIDE_MUTED,SIDEBAR,True); heading.pack(anchor='w',padx=20,pady=(9,3))
|
|
76
|
+
self.nav_sections.append((heading,tools))
|
|
77
|
+
for tool in tools: self.nav_button(nav_body,tool,NAMES[tool])
|
|
78
|
+
self.nav_query.trace_add('write',self.filter_navigation)
|
|
79
|
+
self.main = tk.Frame(root,bg=BG); self.main.pack(side='left',fill='both',expand=True,padx=24,pady=18)
|
|
80
|
+
top = tk.Frame(self.main,bg=BG); top.pack(fill='x')
|
|
81
|
+
self.menu_btn=ttk.Button(top,text='Menu',width=6,command=self.toggle_sidebar); self.menu_btn.pack(side='left',padx=(0,10))
|
|
82
|
+
self.breadcrumb = self.label(top,'WORKSPACE / OVERVIEW',9,GOLD,BG,True); self.breadcrumb.pack(side='left')
|
|
83
|
+
ttk.Button(top,text='Checkpoint',command=self.checkpoint_settings).pack(side='right',padx=4)
|
|
84
|
+
ttk.Button(top,text='About',width=7,command=self.help).pack(side='right')
|
|
85
|
+
self.top_status=self.label(top,'LOCAL / READ-ONLY INPUTS',9,ACCENT,BG,True); self.top_status.pack(side='right',padx=12)
|
|
86
|
+
top.bind('<Configure>',lambda e:self.top_status.configure(text='LOCAL' if e.width<850 else 'LOCAL / READ-ONLY INPUTS'))
|
|
87
|
+
self.heading = self.label(self.main,'',26,INK,BG,True); self.heading.pack(anchor='w',pady=(8,0))
|
|
88
|
+
self.subheading = self.label(self.main,'',10,MUTED,BG); self.subheading.pack(anchor='w',pady=(4,14),fill='x'); self.main.bind('<Configure>',lambda e:self.subheading.configure(wraplength=max(220,e.width-20)))
|
|
89
|
+
self.home = tk.Frame(self.main,bg=BG)
|
|
90
|
+
self.home_canvas = tk.Canvas(self.home,bg=BG,highlightthickness=0)
|
|
91
|
+
home_scroll = ttk.Scrollbar(self.home,command=self.home_canvas.yview)
|
|
92
|
+
self.home_canvas.configure(yscrollcommand=lambda a,b:self.auto_scroll(home_scroll,a,b))
|
|
93
|
+
self.home_canvas.pack(side='left',fill='both',expand=True)
|
|
94
|
+
self.home_body = tk.Frame(self.home_canvas,bg=BG)
|
|
95
|
+
self.home_window = self.home_canvas.create_window((0,0),window=self.home_body,anchor='nw')
|
|
96
|
+
self.home_body.bind('<Configure>',lambda _:self.home_canvas.configure(scrollregion=self.home_canvas.bbox('all')))
|
|
97
|
+
self.home_canvas.bind('<Configure>',lambda e:self.home_canvas.itemconfigure(self.home_window,width=e.width))
|
|
98
|
+
self.work = tk.Frame(self.main,bg=BG)
|
|
99
|
+
self.form = tk.Frame(self.work,bg=PANEL,padx=16,pady=10); self.form.pack(fill='x')
|
|
100
|
+
config_header=tk.Frame(self.form,bg=PANEL);config_header.pack(fill='x')
|
|
101
|
+
self.label(config_header,'INPUT CONFIGURATION',9,GOLD,PANEL,True).pack(side='left')
|
|
102
|
+
self.config_btn=ttk.Button(config_header,text='Hide inputs',width=12,command=self.toggle_config);self.config_btn.pack(side='right')
|
|
103
|
+
self.inputs = tk.Frame(self.form,bg=PANEL); self.inputs.pack(fill='x');self.config_visible=True
|
|
104
|
+
toolbar = tk.Frame(self.work,bg=BG); toolbar.pack(fill='x',pady=12)
|
|
105
|
+
self.run_btn = ttk.Button(toolbar,text='Run analysis',width=13,style='Action.TButton',command=self.run); self.run_btn.pack(side='left')
|
|
106
|
+
self.demo_btn = ttk.Button(toolbar,text='Load demo',width=10,command=self.load_demo); self.demo_btn.pack(side='left',padx=7)
|
|
107
|
+
self.export_btn = ttk.Button(toolbar,text='Export JSON',width=11,command=self.export,state='disabled'); self.export_btn.pack(side='left')
|
|
108
|
+
self.html_btn = ttk.Button(toolbar,text='Export HTML',width=11,command=lambda:self.export('html'),state='disabled'); self.html_btn.pack(side='left',padx=7)
|
|
109
|
+
self.status_row=tk.Frame(self.work,bg=BG); self.status_row.pack(fill='x',pady=(0,5))
|
|
110
|
+
self.status = self.label(self.status_row,'Ready',9,MUTED,BG); self.status.pack(side='left')
|
|
111
|
+
self.progress = ttk.Progressbar(self.status_row,mode='indeterminate',length=90)
|
|
112
|
+
self.cards = tk.Frame(self.work,bg=BG); self.cards.pack(fill='x',pady=(0,12))
|
|
113
|
+
self.threshold_panel=tk.Frame(self.work,bg=PANEL,padx=12,pady=6)
|
|
114
|
+
self.threshold_var=tk.DoubleVar(value=.5)
|
|
115
|
+
self.threshold_info=self.label(self.threshold_panel,'',9,INK,PANEL,True)
|
|
116
|
+
self.label(self.threshold_panel,'Threshold preview',9,GOLD,PANEL,True).pack(side='left')
|
|
117
|
+
self.threshold_scale=ttk.Scale(self.threshold_panel,from_=0,to=1,variable=self.threshold_var,command=self.threshold_changed,length=100); self.threshold_scale.pack(side='left',padx=8,fill='x',expand=True)
|
|
118
|
+
self.threshold_info.pack(side='left',padx=4)
|
|
119
|
+
ttk.Button(self.threshold_panel,text='Apply',command=self.apply_threshold).pack(side='right',padx=(4,0))
|
|
120
|
+
self.tabs = ttk.Notebook(self.work); self.tabs.pack(fill='both',expand=True)
|
|
121
|
+
plot_frame = tk.Frame(self.tabs,bg=PANEL); self.tabs.add(plot_frame,text=' Visualization ')
|
|
122
|
+
self.chart_header = tk.Frame(plot_frame,bg=PANEL); self.chart_header.pack(fill='x',padx=16,pady=(12,0))
|
|
123
|
+
self.chart_title = self.label(self.chart_header,'ANALYSIS PREVIEW',9,GOLD,PANEL,True); self.chart_title.pack(side='left')
|
|
124
|
+
self.chart_select = ttk.Combobox(self.chart_header,textvariable=self.chart_mode,values=('ROC','Precision–recall','Calibration'),state='readonly',width=18)
|
|
125
|
+
self.chart_select.bind('<<ComboboxSelected>>',lambda _:self.draw())
|
|
126
|
+
self.canvas = tk.Canvas(plot_frame,bg=PANEL,highlightthickness=0); self.canvas.pack(fill='both',expand=True,padx=8,pady=4)
|
|
127
|
+
self.canvas.bind('<Configure>',lambda _:self.draw())
|
|
128
|
+
self.canvas.bind('<Motion>',self.chart_hover); self.canvas.bind('<Leave>',lambda _:self.canvas.delete('hover'))
|
|
129
|
+
table = tk.Frame(self.tabs,bg=PANEL); self.tabs.add(table,text=' Findings ')
|
|
130
|
+
filterbar=tk.Frame(table,bg=PANEL,padx=12,pady=8); filterbar.pack(fill='x')
|
|
131
|
+
self.label(filterbar,'Filter findings',9,MUTED,PANEL,True).pack(side='left',padx=(0,8))
|
|
132
|
+
ttk.Entry(filterbar,textvariable=self.find_query,width=24).pack(side='left',fill='x',expand=True)
|
|
133
|
+
ttk.Button(filterbar,text='Copy row',command=self.copy_row).pack(side='right',padx=(8,0))
|
|
134
|
+
self.table = ttk.Treeview(table,columns=('key','value'),show='headings',selectmode='browse')
|
|
135
|
+
self.find_query.trace_add('write',lambda *_:self.render_findings())
|
|
136
|
+
self.table.heading('key',text='Field'); self.table.heading('value',text='Value')
|
|
137
|
+
self.table.column('key',width=280,stretch=True); self.table.column('value',width=430,stretch=True)
|
|
138
|
+
sy = ttk.Scrollbar(table,command=self.table.yview); sx = ttk.Scrollbar(table,orient='horizontal',command=self.table.xview)
|
|
139
|
+
self.table.configure(yscrollcommand=sy.set,xscrollcommand=sx.set); sy.pack(side='right',fill='y'); sx.pack(side='bottom',fill='x'); self.table.pack(fill='both',expand=True)
|
|
140
|
+
report_frame = tk.Frame(self.tabs,bg=PANEL); self.tabs.add(report_frame,text=' Full report · JSON ')
|
|
141
|
+
self.raw = tk.Text(report_frame,bg=PANEL,fg=INK,insertbackground=INK,wrap='none',font=('Consolas' if self.font=='Segoe UI' else 'DejaVu Sans Mono',10),relief='flat',padx=12,pady=12)
|
|
142
|
+
sy=ttk.Scrollbar(report_frame,command=self.raw.yview); sx=ttk.Scrollbar(report_frame,orient='horizontal',command=self.raw.xview)
|
|
143
|
+
self.raw.configure(yscrollcommand=sy.set,xscrollcommand=sx.set,state='disabled'); sy.pack(side='right',fill='y'); sx.pack(side='bottom',fill='x'); self.raw.pack(fill='both',expand=True)
|
|
144
|
+
root.bind('<Control-Return>', lambda _:self.run() if self.tool!='Home' else None)
|
|
145
|
+
root.bind('<Control-s>',lambda _:self.export())
|
|
146
|
+
root.bind('<Control-k>',self.focus_search)
|
|
147
|
+
root.bind('<Control-b>',lambda _:self.toggle_sidebar())
|
|
148
|
+
root.bind_all('<MouseWheel>',self.scroll_wheel)
|
|
149
|
+
root.bind_all('<Button-4>',self.scroll_wheel); root.bind_all('<Button-5>',self.scroll_wheel)
|
|
150
|
+
self.select('Home'); root.after(80,self.poll)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def checkpoint_settings(self):
|
|
154
|
+
from .checkpoint import CheckpointPolicy, atomic_json
|
|
155
|
+
from dataclasses import asdict
|
|
156
|
+
dialog = tk.Toplevel(self.root)
|
|
157
|
+
dialog.title("Checkpoint configuration")
|
|
158
|
+
values = {key: tk.StringVar(value=value) for key, value in {
|
|
159
|
+
"root": "checkpoints", "run_id": "run_001", "keep_last": "2",
|
|
160
|
+
"save_every_epochs": "1", "max_bytes": ""
|
|
161
|
+
}.items()}
|
|
162
|
+
enabled = tk.BooleanVar(value=True)
|
|
163
|
+
for key, var in values.items():
|
|
164
|
+
ttk.Label(dialog, text=key).pack(anchor="w", padx=12)
|
|
165
|
+
ttk.Entry(dialog, textvariable=var, width=48).pack(padx=12, pady=3)
|
|
166
|
+
ttk.Checkbutton(dialog, text="Enable checkpointing", variable=enabled).pack()
|
|
167
|
+
def save():
|
|
168
|
+
try:
|
|
169
|
+
policy = CheckpointPolicy(enabled=enabled.get(),
|
|
170
|
+
keep_last=int(values["keep_last"].get()),
|
|
171
|
+
save_every_epochs=int(values["save_every_epochs"].get()),
|
|
172
|
+
max_bytes=int(values["max_bytes"].get()) if values["max_bytes"].get() else None)
|
|
173
|
+
import re
|
|
174
|
+
run_id = values["run_id"].get()
|
|
175
|
+
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]{0,127}", run_id):
|
|
176
|
+
raise ValueError("invalid run identifier")
|
|
177
|
+
if not values["root"].get().strip():
|
|
178
|
+
raise ValueError("storage root is required")
|
|
179
|
+
path = filedialog.asksaveasfilename(parent=dialog, defaultextension=".json")
|
|
180
|
+
if path:
|
|
181
|
+
atomic_json(Path(path), {"root": values["root"].get(),
|
|
182
|
+
"run_id": run_id, "policy": asdict(policy)})
|
|
183
|
+
dialog.destroy()
|
|
184
|
+
except (ValueError, OSError) as exc:
|
|
185
|
+
messagebox.showerror("Checkpoint", str(exc), parent=dialog)
|
|
186
|
+
ttk.Button(dialog, text="Export configuration", command=save).pack(pady=12)
|
|
187
|
+
|
|
188
|
+
def load_brand_image(self, filename):
|
|
189
|
+
path = ASSETS / filename
|
|
190
|
+
try:
|
|
191
|
+
return tk.PhotoImage(master=self.root, file=str(path))
|
|
192
|
+
except tk.TclError:
|
|
193
|
+
from PIL import Image, ImageTk
|
|
194
|
+
with Image.open(path) as image:
|
|
195
|
+
return ImageTk.PhotoImage(image.convert("RGBA"), master=self.root)
|
|
196
|
+
|
|
197
|
+
def configure_style(self):
|
|
198
|
+
s=self.style
|
|
199
|
+
s.configure('.',font=(self.font,10),background=BG,foreground=INK)
|
|
200
|
+
s.configure('TFrame',background=BG)
|
|
201
|
+
s.configure('TEntry',fieldbackground='#FFFFFF',foreground=INK,insertcolor=INK,padding=8,bordercolor=LINE,lightcolor=LINE,darkcolor=LINE)
|
|
202
|
+
s.configure('TCombobox',fieldbackground='#FFFFFF',foreground=INK,padding=7,arrowcolor=INK)
|
|
203
|
+
s.map('TCombobox',fieldbackground=[('readonly','#FFFFFF')],foreground=[('readonly',INK)])
|
|
204
|
+
self.root.option_add('*TCombobox*Listbox.background',PANEL); self.root.option_add('*TCombobox*Listbox.foreground',INK)
|
|
205
|
+
s.configure('TButton',background='#E5EBE1',foreground=INK,bordercolor=LINE,lightcolor=LINE,darkcolor=LINE,padding=(12,8),font=(self.font,9,'bold'))
|
|
206
|
+
s.map('TButton',background=[('active','#D1E4D5'),('disabled','#F1EDE4')],foreground=[('disabled','#8B968D')])
|
|
207
|
+
s.configure('Action.TButton',background=ACCENT,foreground='#FFFFFF',font=(self.font,10,'bold'),padding=(16,9))
|
|
208
|
+
s.map('Action.TButton',background=[('active','#1B795B'),('disabled','#A5B9AA')],foreground=[('active','#FFFFFF'),('disabled',INK)])
|
|
209
|
+
s.configure('Horizontal.TScale',background=PANEL,troughcolor='#D4E1D4',sliderlength=18,bordercolor=LINE,lightcolor=LINE,darkcolor=LINE)
|
|
210
|
+
s.configure('TNotebook',background=BG,borderwidth=0,bordercolor=LINE,lightcolor=LINE,darkcolor=LINE)
|
|
211
|
+
s.configure('TNotebook.Tab',background='#E8E3D8',foreground=MUTED,padding=(13,9),bordercolor=LINE,lightcolor=LINE,darkcolor=LINE)
|
|
212
|
+
s.map('TNotebook.Tab',background=[('selected',PANEL)],foreground=[('selected',ACCENT)])
|
|
213
|
+
s.configure('Treeview',background=PANEL,fieldbackground=PANEL,foreground=INK,rowheight=30,bordercolor=LINE)
|
|
214
|
+
s.configure('Treeview.Heading',background='#E8EEE5',foreground=GOLD,font=(self.font,9,'bold'),padding=6)
|
|
215
|
+
s.map('Treeview',background=[('selected','#CFE4D4')],foreground=[('selected',INK)])
|
|
216
|
+
s.configure('Vertical.TScrollbar',background='#B9C5B7',troughcolor=BG,bordercolor=BG,lightcolor=LINE,darkcolor=LINE,arrowcolor=MUTED)
|
|
217
|
+
s.configure('Horizontal.TScrollbar',background='#B9C5B7',troughcolor=BG,bordercolor=BG,lightcolor=LINE,darkcolor=LINE,arrowcolor=MUTED)
|
|
218
|
+
s.configure('Side.Vertical.TScrollbar',background=SIDE_ACTIVE,troughcolor=SIDEBAR,bordercolor=SIDEBAR,lightcolor=SIDEBAR,darkcolor=SIDEBAR,arrowcolor=SIDE_MUTED)
|
|
219
|
+
s.configure('Horizontal.TProgressbar',background=ACCENT,troughcolor=PANEL,bordercolor=BG,lightcolor=ACCENT,darkcolor=ACCENT)
|
|
220
|
+
|
|
221
|
+
def label(self,parent,text,size,fg,bg,bold=False):
|
|
222
|
+
return tk.Label(parent,text=text,fg=fg,bg=bg,font=(self.font,size,'bold' if bold else 'normal'),justify='left',anchor='w')
|
|
223
|
+
|
|
224
|
+
def nav_button(self,parent,key,caption):
|
|
225
|
+
b=tk.Button(parent,text=f'{ICONS[key]} {caption}',anchor='w',font=(self.font,10),padx=12,pady=4,bg=SIDEBAR,fg=SIDE_INK,activebackground=SIDE_ACTIVE,activeforeground=SIDE_GOLD,relief='flat',borderwidth=0,highlightthickness=1,highlightcolor=SIDE_GOLD,highlightbackground=SIDEBAR,command=lambda:self.select(key),cursor='hand2')
|
|
226
|
+
b.pack(fill='x',padx=10,pady=1); self.nav[key]=b
|
|
227
|
+
b.bind('<Enter>',lambda _,k=key,w=b:w.configure(bg=SIDE_ACTIVE) if k!=self.tool else None)
|
|
228
|
+
b.bind('<Leave>',lambda _,k=key,w=b:w.configure(bg=SIDEBAR) if k!=self.tool else None)
|
|
229
|
+
|
|
230
|
+
def auto_scroll(self,scroll,first,last):
|
|
231
|
+
scroll.set(first,last)
|
|
232
|
+
if float(first)<=0 and float(last)>=1:
|
|
233
|
+
if scroll.winfo_manager(): scroll.pack_forget()
|
|
234
|
+
elif not scroll.winfo_manager():
|
|
235
|
+
scroll.pack(side='right',fill='y',before=next(w for w in scroll.master.pack_slaves() if isinstance(w,tk.Canvas)))
|
|
236
|
+
|
|
237
|
+
def threshold_changed(self,value):
|
|
238
|
+
if self.tool!='Scores' or self.report is None: return
|
|
239
|
+
t=round(float(value),3); m=preview_threshold(self.report,t)
|
|
240
|
+
self.threshold_info.configure(text=f'{t:.3f} | P {m["precision"]:.2f} R {m["recall"]:.2f} F1 {m["f1"]:.2f}')
|
|
241
|
+
|
|
242
|
+
def apply_threshold(self):
|
|
243
|
+
if self.busy or self.tool!='Scores' or self.report is None: return
|
|
244
|
+
# Recompute on the explicitly selected CSV and update the exported report.
|
|
245
|
+
self.fields['threshold'].set(f'{self.threshold_var.get():.3f}'); self.run()
|
|
246
|
+
|
|
247
|
+
def toggle_config(self,visible=None):
|
|
248
|
+
visible=not self.config_visible if visible is None else bool(visible)
|
|
249
|
+
if visible: self.inputs.pack(fill='x')
|
|
250
|
+
else: self.inputs.pack_forget()
|
|
251
|
+
self.config_visible=visible;self.config_btn.configure(text='Hide inputs' if visible else 'Show inputs')
|
|
252
|
+
|
|
253
|
+
def toggle_sidebar(self):
|
|
254
|
+
if self.sidebar_visible:
|
|
255
|
+
self.side.pack_forget()
|
|
256
|
+
else:
|
|
257
|
+
self.side.pack(side='left',fill='y',before=self.main)
|
|
258
|
+
self.sidebar_visible=not self.sidebar_visible
|
|
259
|
+
|
|
260
|
+
def focus_search(self,event=None):
|
|
261
|
+
if not self.sidebar_visible: self.toggle_sidebar()
|
|
262
|
+
self.search_entry.focus_set(); self.search_entry.selection_range(0,'end')
|
|
263
|
+
return 'break'
|
|
264
|
+
|
|
265
|
+
def matches(self,key):
|
|
266
|
+
q=self.nav_query.get().strip().casefold()
|
|
267
|
+
return not q or q in ('overview home' if key=='Home' else ' '.join((key,NAMES[key],*TOOLS[key])).casefold())
|
|
268
|
+
|
|
269
|
+
def filter_navigation(self,*_):
|
|
270
|
+
for b in self.nav.values(): b.pack_forget()
|
|
271
|
+
for heading,_ in self.nav_sections: heading.pack_forget()
|
|
272
|
+
if self.matches('Home'): self.nav['Home'].pack(fill='x',padx=10,pady=1)
|
|
273
|
+
for heading,keys in self.nav_sections:
|
|
274
|
+
matches=[k for k in keys if self.matches(k)]
|
|
275
|
+
if matches: heading.pack(anchor='w',padx=20,pady=(9,3))
|
|
276
|
+
for k in matches: self.nav[k].pack(fill='x',padx=10,pady=1)
|
|
277
|
+
self.nav_canvas.yview_moveto(0)
|
|
278
|
+
|
|
279
|
+
def open_first_match(self,event=None):
|
|
280
|
+
for key in self.nav:
|
|
281
|
+
if self.matches(key): self.select(key); break
|
|
282
|
+
return 'break'
|
|
283
|
+
|
|
284
|
+
def scroll_wheel(self,event):
|
|
285
|
+
widget=event.widget
|
|
286
|
+
while widget is not None:
|
|
287
|
+
if widget in (self.home_canvas,self.nav_canvas):
|
|
288
|
+
units=-1 if getattr(event,'num',None)==4 or getattr(event,'delta',0)>0 else 1
|
|
289
|
+
widget.yview_scroll(units*3,'units'); return 'break'
|
|
290
|
+
widget=getattr(widget,'master',None)
|
|
291
|
+
|
|
292
|
+
def render_findings(self):
|
|
293
|
+
for item in self.table.get_children(): self.table.delete(item)
|
|
294
|
+
query=self.find_query.get().casefold().strip()
|
|
295
|
+
if self.report is not None:
|
|
296
|
+
for i,(k,v) in enumerate(finding_rows(self.report)+table_rows(self.report)):
|
|
297
|
+
if not query or query in f'{k} {v}'.casefold():
|
|
298
|
+
self.table.insert('','end',values=(k,v),tags=('even' if i%2==0 else 'odd',))
|
|
299
|
+
self.table.tag_configure('odd',background='#F1F4EB')
|
|
300
|
+
self.table.tag_configure('even',background=PANEL)
|
|
301
|
+
|
|
302
|
+
def copy_row(self):
|
|
303
|
+
selected=self.table.selection()
|
|
304
|
+
if selected:
|
|
305
|
+
values=self.table.item(selected[0],'values'); self.root.clipboard_clear(); self.root.clipboard_append('\t'.join(values))
|
|
306
|
+
self.status.configure(text='Finding copied',fg=ACCENT)
|
|
307
|
+
|
|
308
|
+
def chart_hover(self,event):
|
|
309
|
+
c=self.canvas; c.delete('hover')
|
|
310
|
+
if not self.chart_points: return
|
|
311
|
+
x,y,label=min(self.chart_points,key=lambda p:(p[0]-event.x)**2+(p[1]-event.y)**2)
|
|
312
|
+
if (x-event.x)**2+(y-event.y)**2>32**2: return
|
|
313
|
+
c.create_oval(x-5,y-5,x+5,y+5,outline=GOLD,width=2,tags='hover')
|
|
314
|
+
tx=min(max(x+10,8),max(8,c.winfo_width()-240)); ty=max(20,y-24)
|
|
315
|
+
t=c.create_text(tx,ty,text=label,anchor='w',fill=SIDE_INK,font=(self.font,9),tags='hover')
|
|
316
|
+
a,b,d,e=c.bbox(t); rect=c.create_rectangle(a-7,b-5,d+7,e+5,fill=SIDEBAR,outline=GOLD,tags='hover'); c.tag_lower(rect,t)
|
|
317
|
+
|
|
318
|
+
def field(self,parent,name,caption,default='',choices=None,width=18):
|
|
319
|
+
box=tk.Frame(parent,bg=PANEL); box.pack(side='left',fill='x',expand=True,padx=(0,9))
|
|
320
|
+
self.label(box,caption,9,MUTED,PANEL).pack(anchor='w',pady=(0,4))
|
|
321
|
+
var=tk.StringVar(value=default); self.fields[name]=var
|
|
322
|
+
widget=ttk.Combobox(box,textvariable=var,values=choices,state='readonly',width=min(width,12)) if choices else ttk.Entry(box,textvariable=var,width=min(width,15))
|
|
323
|
+
widget.pack(fill='x'); return box
|
|
324
|
+
|
|
325
|
+
def render_home(self):
|
|
326
|
+
for child in self.home_body.winfo_children(): child.destroy()
|
|
327
|
+
hero=tk.Frame(self.home_body,bg=SIDEBAR,padx=26,pady=22); hero.pack(fill='x',pady=(0,14))
|
|
328
|
+
hero_top=tk.Frame(hero,bg=SIDEBAR); hero_top.pack(fill='x')
|
|
329
|
+
self.label(hero_top,'XVARNA / RESEARCH OPERATIONS',9,SIDE_GOLD,SIDEBAR,True).pack(side='left')
|
|
330
|
+
self.label(hero_top,'PROFESSIONAL EDITION',8,SIDE_MUTED,SIDEBAR,True).pack(side='right')
|
|
331
|
+
hero_heading=self.label(hero,'Build confidence in every experiment.',21,SIDE_INK,SIDEBAR,True); hero_heading.pack(anchor='w',pady=(12,6),fill='x')
|
|
332
|
+
hero.bind('<Configure>',lambda e:hero_heading.configure(wraplength=max(220,e.width-52)))
|
|
333
|
+
self.label(hero,'From dataset quality to model evaluation, one local-first workspace.',10,SIDE_MUTED,SIDEBAR).pack(anchor='w')
|
|
334
|
+
actions=tk.Frame(hero,bg=SIDEBAR); actions.pack(fill='x',pady=(16,0))
|
|
335
|
+
ttk.Button(actions,text='Explore synthetic demo',style='Action.TButton',command=lambda:self.open_demo('Training')).pack(side='left')
|
|
336
|
+
ttk.Button(actions,text='Audit a dataset',command=lambda:self.select('Dataset')).pack(side='left',padx=8)
|
|
337
|
+
tk.Frame(hero,bg=SIDE_GOLD,height=2).pack(fill='x',pady=(18,0))
|
|
338
|
+
row=tk.Frame(self.home_body,bg=BG); row.pack(fill='x',pady=(0,14))
|
|
339
|
+
for i,(label,value,detail) in enumerate([('Research tools',str(len(TOOLS)),'Independent workspaces'),('Session analyses',str(len(self.recent)),'Last 15 reports retained'),('Execution','Local','No cloud needed')]):
|
|
340
|
+
row.grid_columnconfigure(i,weight=1,uniform='stats'); card=tk.Frame(row,bg=PANEL,padx=14,pady=12,highlightbackground=LINE,highlightthickness=1); card.grid(row=0,column=i,sticky='nsew',padx=(0,8))
|
|
341
|
+
self.label(card,label,9,MUTED,PANEL).pack(anchor='w'); self.label(card,value,22,ACCENT,PANEL,True).pack(anchor='w'); self.label(card,detail,9,MUTED,PANEL).pack(anchor='w')
|
|
342
|
+
self.label(self.home_body,'START A WORKFLOW',9,GOLD,BG,True).pack(anchor='w',pady=(0,6))
|
|
343
|
+
row=tk.Frame(self.home_body,bg=BG); row.pack(fill='x',pady=(0,14))
|
|
344
|
+
for i,(name,desc,tool) in enumerate([('01 / Audit data','Inspect balance and leakage.','Dataset'),('02 / Diagnose runs','Compare learning curves.','Training'),('03 / Evaluate','Review prediction metrics.','Scores')]):
|
|
345
|
+
row.grid_columnconfigure(i,weight=1,uniform='flows'); card=tk.Frame(row,bg=PANEL,padx=14,pady=12,highlightbackground=LINE,highlightthickness=1); card.grid(row=0,column=i,sticky='nsew',padx=(0,8))
|
|
346
|
+
self.label(card,name,11,INK,PANEL,True).pack(anchor='w'); self.label(card,desc,9,MUTED,PANEL).pack(anchor='w',pady=6)
|
|
347
|
+
ttk.Button(card,text='Open workspace',command=lambda t=tool:self.select(t)).pack(anchor='w')
|
|
348
|
+
self.label(self.home_body,'RECENT SESSION ANALYSES',9,GOLD,BG,True).pack(anchor='w',pady=(0,6))
|
|
349
|
+
if not self.recent:
|
|
350
|
+
self.label(self.home_body,'No reports yet. Choose a workspace or run the bundled synthetic demo.',10,MUTED,BG).pack(anchor='w')
|
|
351
|
+
else:
|
|
352
|
+
for item in self.recent[:3]:
|
|
353
|
+
row=tk.Frame(self.home_body,bg=PANEL,padx=12,pady=4); row.pack(fill='x',pady=2)
|
|
354
|
+
self.label(row,item['time']+' / '+NAMES[item['tool']],10,INK,PANEL).pack(side='left')
|
|
355
|
+
ttk.Button(row,text='View report',command=lambda r=item:self.reopen(r)).pack(side='right')
|
|
356
|
+
|
|
357
|
+
def select(self,tool):
|
|
358
|
+
if self.busy: return
|
|
359
|
+
if self.tool!='Home' and self.fields: self.saved_fields[self.tool]={k:v.get() for k,v in self.fields.items()}
|
|
360
|
+
self.tool,self.report,self.chart=tool,None,None; self.fields={}
|
|
361
|
+
for t,b in self.nav.items(): b.configure(bg=SIDE_ACTIVE if t==tool else SIDEBAR,fg=SIDE_GOLD if t==tool else SIDE_INK)
|
|
362
|
+
self.find_query.set('')
|
|
363
|
+
self.breadcrumb.configure(text='WORKSPACE / '+('OVERVIEW' if tool=='Home' else NAMES[tool].upper()))
|
|
364
|
+
self.work.pack_forget(); self.home.pack_forget()
|
|
365
|
+
if tool=='Home':
|
|
366
|
+
self.heading.configure(text='Research dashboard'); self.subheading.configure(text='Your local command center for reproducible deep learning.')
|
|
367
|
+
self.render_home(); self.home.pack(fill='both',expand=True); return
|
|
368
|
+
self.work.pack(fill='both',expand=True);self.toggle_config(True)
|
|
369
|
+
self.heading.configure(text=TOOLS[tool][0]); self.subheading.configure(text=TOOLS[tool][1])
|
|
370
|
+
for child in self.inputs.winfo_children(): child.destroy()
|
|
371
|
+
if tool in DIR_TOOLS or tool in DEMO_FILES or tool=='Manifest':
|
|
372
|
+
row=tk.Frame(self.inputs,bg=PANEL); row.pack(fill='x',pady=4)
|
|
373
|
+
self.field(row,'path','Dataset / run directory' if tool in DIR_TOOLS else 'Optional input file' if tool=='Manifest' else 'Input CSV file',width=40)
|
|
374
|
+
ttk.Button(row,text='Browse…',command=self.browse).pack(side='left',anchor='s')
|
|
375
|
+
row=tk.Frame(self.inputs,bg=PANEL); row.pack(fill='x',pady=4)
|
|
376
|
+
if tool in ('Training','Compare'):
|
|
377
|
+
for k,cap,val in (('metric','Validation metric','val_loss'),('train_metric','Training metric (optional)','train_loss'),('epoch_column','Epoch column','epoch')):
|
|
378
|
+
self.field(row,k,cap,val,width=14)
|
|
379
|
+
self.field(row,'mode','Optimize','min',('min','max'),7)
|
|
380
|
+
elif tool=='Metrics':
|
|
381
|
+
self.field(row,'true_column','True label column','y_true'); self.field(row,'pred_column','Predicted label column','y_pred')
|
|
382
|
+
elif tool=='Scores':
|
|
383
|
+
for k,cap,val in (('true_column','True label column','y_true'),('score_column','Probability column','score'),('positive_label','Positive label','1'),('threshold','Decision threshold','0.5')):
|
|
384
|
+
self.field(row,k,cap,val,width=12)
|
|
385
|
+
elif tool=='Model':
|
|
386
|
+
for k,cap,val in (('inputs','Input width','16'),('hidden','Hidden width','32'),('outputs','Output width','3'),('batch','Batch size','1')): self.field(row,k,cap,val)
|
|
387
|
+
elif tool=='Images':
|
|
388
|
+
self.field(row,'similarity','Perceptual comparison','yes',('yes','no')); self.field(row,'threshold','Max Hamming distance','4'); self.field(row,'max_images','Image scan limit','2000')
|
|
389
|
+
elif tool=='Groups':
|
|
390
|
+
self.field(row,'group_column','Group ID column','group_id'); self.field(row,'split_column','Split column','split')
|
|
391
|
+
elif tool=='YOLO': self.field(row,'classes','Number of classes (optional)','')
|
|
392
|
+
elif tool=='Leakage': self.label(row,'Exact byte duplicates only. A clean report does not establish patient independence.',9,GOLD,PANEL).pack(anchor='w')
|
|
393
|
+
elif tool=='Environment': self.label(row,'Reports Python and optional PyTorch / CUDA availability without network access.',9,MUTED,PANEL).pack(anchor='w')
|
|
394
|
+
for k,v in self.saved_fields.get(tool,{}).items():
|
|
395
|
+
if k in self.fields: self.fields[k].set(v)
|
|
396
|
+
self.demo_btn.configure(state='normal' if tool in DEMOS else 'disabled')
|
|
397
|
+
self.export_btn.configure(state='disabled'); self.html_btn.configure(state='disabled'); self.status.configure(text='Ready',fg=MUTED)
|
|
398
|
+
self.chart_select.pack_forget(); self.chart_mode.set('ROC'); self.tabs.select(0); self.render()
|
|
399
|
+
|
|
400
|
+
def open_demo(self,tool):
|
|
401
|
+
if self.busy: return
|
|
402
|
+
self.select(tool); self.load_demo(); self.run()
|
|
403
|
+
|
|
404
|
+
def load_demo(self):
|
|
405
|
+
if self.tool not in DEMOS or self.busy: return
|
|
406
|
+
self.fields['path'].set(str(Path(__file__).parent/'samples'/DEMOS[self.tool])); self.status.configure(text='Synthetic demo loaded',fg=GOLD)
|
|
407
|
+
|
|
408
|
+
def browse(self):
|
|
409
|
+
path=filedialog.askdirectory(parent=self.root) if self.tool in DIR_TOOLS else filedialog.askopenfilename(parent=self.root,filetypes=[('All files','*')] if self.tool=='Manifest' else [('CSV files','*.csv'),('All files','*')])
|
|
410
|
+
if path: self.fields['path'].set(path)
|
|
411
|
+
|
|
412
|
+
def run(self):
|
|
413
|
+
if self.busy or self.tool=='Home': return
|
|
414
|
+
opts={k:v.get().strip() for k,v in self.fields.items()}
|
|
415
|
+
if 'path' in opts and not opts['path'] and self.tool!='Manifest':
|
|
416
|
+
messagebox.showwarning('Input required','Select a file or directory first.',parent=self.root); return
|
|
417
|
+
self.busy=True; self.report=self.chart=None; self.current_opts=opts; self.render()
|
|
418
|
+
for b in (self.run_btn,self.demo_btn,self.export_btn,self.html_btn): b.configure(state='disabled')
|
|
419
|
+
self.status.configure(text='Analyzing…',fg=GOLD); self.progress.pack(side='right',padx=5); self.progress.start(12)
|
|
420
|
+
tool=self.tool
|
|
421
|
+
def work():
|
|
422
|
+
try: self.results.put((True,analyze(tool,opts)))
|
|
423
|
+
except Exception as exc: self.results.put((False,f'{type(exc).__name__}: {exc}'))
|
|
424
|
+
threading.Thread(target=work,daemon=True).start()
|
|
425
|
+
|
|
426
|
+
def poll(self):
|
|
427
|
+
try: ok,value=self.results.get_nowait()
|
|
428
|
+
except queue.Empty: pass
|
|
429
|
+
else:
|
|
430
|
+
self.busy=False; self.progress.stop(); self.progress.pack_forget(); self.run_btn.configure(state='normal')
|
|
431
|
+
self.demo_btn.configure(state='normal' if self.tool in DEMOS else 'disabled')
|
|
432
|
+
if ok:
|
|
433
|
+
self.report,self.chart=value
|
|
434
|
+
self.recent.insert(0,{'time':datetime.now().strftime('%H:%M:%S'),'tool':self.tool,'options':self.current_opts.copy(),'report':self.report,'chart':self.chart}); del self.recent[15:]
|
|
435
|
+
self.status.configure(text='Analysis complete',fg=ACCENT)
|
|
436
|
+
if self.root.winfo_height()<800: self.toggle_config(False)
|
|
437
|
+
self.export_btn.configure(state='normal'); self.html_btn.configure(state='normal'); self.render()
|
|
438
|
+
else:
|
|
439
|
+
self.status.configure(text='Analysis failed',fg=ERROR); messagebox.showerror('Analysis failed',value,parent=self.root)
|
|
440
|
+
self.root.after(80,self.poll)
|
|
441
|
+
|
|
442
|
+
def reopen(self,item):
|
|
443
|
+
if self.busy: return
|
|
444
|
+
self.select(item['tool'])
|
|
445
|
+
for k,v in item['options'].items():
|
|
446
|
+
if k in self.fields: self.fields[k].set(v)
|
|
447
|
+
self.report,self.chart=item['report'],item['chart']; self.current_opts=item['options'].copy(); self.status.configure(text='Saved session result',fg=ACCENT)
|
|
448
|
+
self.export_btn.configure(state='normal'); self.html_btn.configure(state='normal'); self.render()
|
|
449
|
+
|
|
450
|
+
def export(self,fmt='json'):
|
|
451
|
+
if self.report is None: return
|
|
452
|
+
path=filedialog.asksaveasfilename(parent=self.root,defaultextension='.'+fmt,filetypes=[(fmt.upper()+' report','*.'+fmt)],initialfile=f'deepforge-{self.tool.lower()}.{fmt}')
|
|
453
|
+
if path:
|
|
454
|
+
try:
|
|
455
|
+
source = self.current_opts.get('path')
|
|
456
|
+
output = Path(path).resolve()
|
|
457
|
+
if output.suffix.lower() != '.'+fmt:
|
|
458
|
+
raise ValueError('Choose an output filename ending in .'+fmt)
|
|
459
|
+
if source:
|
|
460
|
+
source_path = Path(source).resolve()
|
|
461
|
+
if output == source_path or (source_path.is_dir() and output.is_relative_to(source_path) and output.exists()):
|
|
462
|
+
raise ValueError('Choose a different output path; an input file must not be overwritten.')
|
|
463
|
+
export_report(path,TOOLS[self.tool][0],self.report,cards=summary(self.tool,self.report),fmt=fmt,chart=self.active_chart())
|
|
464
|
+
except (OSError,ValueError) as exc: messagebox.showerror('Export failed',str(exc),parent=self.root)
|
|
465
|
+
else: self.status.configure(text='Report exported',fg=ACCENT)
|
|
466
|
+
|
|
467
|
+
def active_chart(self):
|
|
468
|
+
if self.tool!='Scores' or self.report is None or self.chart_mode.get()=='ROC': return self.chart
|
|
469
|
+
mode=self.chart_mode.get()
|
|
470
|
+
if mode=='Calibration':
|
|
471
|
+
rows=[r for r in self.report['calibration'] if r['count']]
|
|
472
|
+
return {'type':'probability','title':'Calibration','x':[r['mean_probability'] for r in rows],'y':[r['positive_fraction'] for r in rows],'xlabel':'Mean probability','baseline':None}
|
|
473
|
+
rows=self.report['precision_recall_curve']
|
|
474
|
+
return {'type':'probability','title':'Precision–recall','x':[r['recall'] for r in rows],'y':[r['precision'] for r in rows],'xlabel':'Recall','baseline':self.report['positive_prevalence']}
|
|
475
|
+
|
|
476
|
+
def help(self):
|
|
477
|
+
dialog=tk.Toplevel(self.root); dialog.title('About DeepForge Studio'); dialog.configure(bg=PANEL); dialog.transient(self.root); dialog.resizable(False,False)
|
|
478
|
+
hero=tk.Frame(dialog,bg=SIDEBAR,padx=28,pady=20); hero.pack(fill='x')
|
|
479
|
+
logo=tk.PhotoImage(file=str(ASSETS/'xvarna_about.png')); image=tk.Label(hero,image=logo,bg=SIDEBAR); image.image=logo; image.pack()
|
|
480
|
+
body=tk.Frame(dialog,bg=PANEL,padx=24,pady=18); body.pack(fill='both',expand=True)
|
|
481
|
+
self.label(body,'DeepForge Studio',22,INK,PANEL,True).pack(anchor='w')
|
|
482
|
+
self.label(body,f'Professional Edition / v{__version__}',10,GOLD,PANEL,True).pack(anchor='w',pady=(4,10))
|
|
483
|
+
self.label(body,'Created by Alireza Khatibi · XVARNA',11,INK,PANEL,True).pack(anchor='w')
|
|
484
|
+
self.label(body,'Local research tools. MIT-licensed software.\nReview reports and sensitive paths before sharing.\nSimilarity and overfitting signals require human review.',10,MUTED,PANEL).pack(anchor='w',pady=12)
|
|
485
|
+
self.label(body,'KEYBOARD SHORTCUTS',9,GOLD,PANEL,True).pack(anchor='w')
|
|
486
|
+
self.label(body,'Ctrl+K Find workspace Ctrl+B Toggle sidebar\nCtrl+Enter Analyze Ctrl+S Export JSON',10,INK,PANEL).pack(anchor='w',pady=8)
|
|
487
|
+
ttk.Button(body,text='Close',style='Action.TButton',command=dialog.destroy).pack(anchor='e',pady=(8,0))
|
|
488
|
+
dialog.bind('<Escape>',lambda _:dialog.destroy())
|
|
489
|
+
return dialog
|
|
490
|
+
|
|
491
|
+
def render(self):
|
|
492
|
+
for child in self.cards.winfo_children(): child.destroy()
|
|
493
|
+
values=summary(self.tool,self.report) if self.report is not None else [('Status','Ready'),('Execution','Local'),('Report','Not generated')]
|
|
494
|
+
for label,value in values:
|
|
495
|
+
card=tk.Frame(self.cards,bg=PANEL,padx=16,pady=9); card.pack(side='left',fill='x',expand=True,padx=(0,8))
|
|
496
|
+
self.label(card,label.upper(),8,MUTED,PANEL,True).pack(anchor='w'); self.label(card,value,21,ACCENT,PANEL,True).pack(anchor='w',pady=(4,0))
|
|
497
|
+
self.raw.configure(state='normal'); self.raw.delete('1.0','end'); self.raw.insert('1.0',json.dumps(self.report,indent=2,ensure_ascii=False,allow_nan=False) if self.report is not None else 'Run an analysis to generate a report.'); self.raw.configure(state='disabled')
|
|
498
|
+
self.render_findings()
|
|
499
|
+
if self.tool=='Scores' and self.report is not None:
|
|
500
|
+
self.chart_select.pack(side='right'); self.threshold_var.set(self.report['threshold']); self.threshold_changed(self.threshold_var.get())
|
|
501
|
+
self.threshold_panel.pack(fill='x',pady=(0,8),before=self.tabs)
|
|
502
|
+
else:
|
|
503
|
+
self.chart_select.pack_forget(); self.threshold_panel.pack_forget()
|
|
504
|
+
self.draw()
|
|
505
|
+
|
|
506
|
+
def draw(self):
|
|
507
|
+
c=self.canvas; c.delete('all'); self.chart_points=[]; w,h=c.winfo_width(),c.winfo_height()
|
|
508
|
+
if w<100 or h<100: return
|
|
509
|
+
def text(x,y,t,**kw): return c.create_text(x,y,text=t,fill=kw.pop('fill',MUTED),font=(self.font,kw.pop('size',9)),**kw)
|
|
510
|
+
if not self.chart:
|
|
511
|
+
self.chart_title.configure(text='ANALYSIS PREVIEW')
|
|
512
|
+
text(w/2,h/2-18,'Ready to analyze' if self.report is None else 'Analysis report ready',size=18,fill=INK)
|
|
513
|
+
text(w/2,h/2+12,'Configure inputs and run an analysis.' if self.report is None else 'Open Findings or Full report to inspect runtime details.',width=w-40)
|
|
514
|
+
return
|
|
515
|
+
d=self.chart; kind=d['type']; x0,y0,x1,y1=65,32,w-45,h-45
|
|
516
|
+
if kind=='bars':
|
|
517
|
+
self.chart_title.configure(text='ESTIMATED MACs BY LAYER' if self.tool=='Model' else 'RESULT DISTRIBUTION / FIRST 12 ITEMS')
|
|
518
|
+
vals=d['values'][:12]; x0=170; x1=w-65; lo=min([0]+[v for _,v in vals]); hi=max([0]+[v for _,v in vals]); span=hi-lo or 1
|
|
519
|
+
step=(y1-y0)/max(1,len(vals)); zero=x0+(0-lo)/span*(x1-x0)
|
|
520
|
+
for i in range(5):
|
|
521
|
+
xx=x0+(x1-x0)*i/4; c.create_line(xx,y0,xx,y1,fill=LINE); text(xx,y1+15,f'{lo+span*i/4:.3g}')
|
|
522
|
+
for i,(name,v) in enumerate(vals):
|
|
523
|
+
mid=y0+step*(i+.5); end=x0+(v-lo)/span*(x1-x0); bar=min(24,step*.55)
|
|
524
|
+
text(x0-10,mid,str(name)[:23],anchor='e'); c.create_rectangle(min(zero,end),mid-bar/2,max(zero,end),mid+bar/2,fill=COLORS[i%4],outline='')
|
|
525
|
+
text(end+6 if v>=0 else end-6,mid,f'{v:,.4g}',anchor='w' if v>=0 else 'e',fill=INK)
|
|
526
|
+
self.chart_points.append((end,mid,f'{name}: {v:,.5g}'))
|
|
527
|
+
elif kind=='lines':
|
|
528
|
+
self.chart_title.configure(text='LEARNING CURVES / LOGGED EPOCHS')
|
|
529
|
+
xs=d['x']; series=d['series']; ys=[v for vs in series.values() for v in vs]; lo,hi=min(ys),max(ys); spread=hi-lo or 1; dx=xs[-1]-xs[0] or 1
|
|
530
|
+
y0+=18
|
|
531
|
+
for i in range(5):
|
|
532
|
+
yy=y1-(y1-y0)*i/4; c.create_line(x0,yy,x1,yy,fill=LINE); text(x0-9,yy,f'{lo+spread*i/4:.3g}',anchor='e')
|
|
533
|
+
for j,(name,vs) in enumerate(series.items()):
|
|
534
|
+
color=COLORS[j%4]; pts=[(x0+(x-xs[0])/dx*(x1-x0),y1-(v-lo)/spread*(y1-y0)) for x,v in zip(xs,vs)]
|
|
535
|
+
if len(pts)>1: c.create_line(*[n for p in pts for n in p],fill=color,width=2.5)
|
|
536
|
+
self.chart_points.extend((px,py,f'{name} | Epoch {x:g}: {v:.5g}') for (px,py),x,v in zip(pts,xs,vs))
|
|
537
|
+
for x,y in pts if len(pts)<=100 else []: c.create_oval(x-3,y-3,x+3,y+3,fill=color,outline='')
|
|
538
|
+
text(x0+j*max(130,(x1-x0)/len(series)),17,name,anchor='w',fill=color)
|
|
539
|
+
if self.report and 'best_epoch' in self.report:
|
|
540
|
+
xx=x0+(self.report['best_epoch']-xs[0])/dx*(x1-x0); c.create_line(xx,y0,xx,y1,fill=GOLD,dash=(4,5)); text(min(x1-55,xx+6),y0+10,'Best epoch',anchor='w',fill=GOLD)
|
|
541
|
+
for i in range(min(len(xs),6)):
|
|
542
|
+
idx=round(i*(len(xs)-1)/max(1,min(len(xs),6)-1)); xx=x0+(xs[idx]-xs[0])/dx*(x1-x0); text(xx,y1+15,f'{xs[idx]:g}')
|
|
543
|
+
text((x0+x1)/2,y1+33,'Epoch')
|
|
544
|
+
elif kind=='roc':
|
|
545
|
+
mode=self.chart_mode.get(); self.chart_title.configure(text=mode.upper()+' / BINARY PROBABILITIES'); y0+=12
|
|
546
|
+
if mode=='Precision–recall':
|
|
547
|
+
rows=self.report['precision_recall_curve']; xs=[r['recall'] for r in rows]; ys=[r['precision'] for r in rows]; xl,yl='Recall','Precision'; baseline=self.report['positive_prevalence']
|
|
548
|
+
elif mode=='Calibration':
|
|
549
|
+
rows=[r for r in self.report['calibration'] if r['count']]; xs=[r['mean_probability'] for r in rows]; ys=[r['positive_fraction'] for r in rows]; xl,yl='Mean probability','Observed positive fraction'; baseline=None
|
|
550
|
+
else: xs=d['x']; ys=d['y']; xl,yl='False positive rate','True positive rate'; baseline=None
|
|
551
|
+
for i in range(6):
|
|
552
|
+
f=i/5; xx=x0+f*(x1-x0); yy=y1-f*(y1-y0)
|
|
553
|
+
c.create_line(x0,yy,x1,yy,fill=LINE); c.create_line(xx,y0,xx,y1,fill=LINE); text(x0-10,yy,f'{f:.1f}',anchor='e'); text(xx,y1+14,f'{f:.1f}')
|
|
554
|
+
if baseline is None: c.create_line(x0,y1,x1,y0,fill=MUTED,dash=(4,5))
|
|
555
|
+
else: c.create_line(x0,y1-baseline*(y1-y0),x1,y1-baseline*(y1-y0),fill=MUTED,dash=(4,5))
|
|
556
|
+
pts=[(x0+x*(x1-x0),y1-y*(y1-y0)) for x,y in zip(xs,ys)]
|
|
557
|
+
if len(pts)>1: c.create_line(*[n for p in pts for n in p],fill=ACCENT,width=3)
|
|
558
|
+
self.chart_points.extend((px,py,f'{xl}: {x:.4g} | {yl}: {y:.4g}') for (px,py),x,y in zip(pts,xs,ys))
|
|
559
|
+
for x,y in pts if len(pts)<=100 else []: c.create_oval(x-3,y-3,x+3,y+3,fill=ACCENT,outline='')
|
|
560
|
+
text((x0+x1)/2,y1+33,xl); text(x0,y0-13,yl,anchor='w')
|
|
561
|
+
elif kind=='matrix':
|
|
562
|
+
self.chart_title.configure(text='CONFUSION MATRIX / COUNTS'); labels=d['labels']; matrix=d['values']; n=len(labels)
|
|
563
|
+
if n>20: text(w/2,h/2,'More than 20 classes. See the Full report tab.',width=w-40); return
|
|
564
|
+
x0=110; y0=50; cell=min((x1-x0)/n,(y1-y0)/n); x0=max(x0,(w-cell*n)/2); maxv=max(max(r) for r in matrix) or 1
|
|
565
|
+
text(w/2,14,'Predicted labels (columns) · True labels (rows)')
|
|
566
|
+
for i,label in enumerate(labels):
|
|
567
|
+
text(x0-8,y0+(i+.5)*cell,label[:14],anchor='e'); text(x0+(i+.5)*cell,y0-15,label[:14])
|
|
568
|
+
for j,v in enumerate(matrix[i]):
|
|
569
|
+
t=v/maxv; color=f'#{int(236-215*t):02x}{int(242-139*t):02x}{int(226-145*t):02x}'
|
|
570
|
+
x,y=x0+j*cell,y0+i*cell; c.create_rectangle(x,y,x+cell,y+cell,fill=color,outline=BG)
|
|
571
|
+
self.chart_points.append((x+cell/2,y+cell/2,f'True {labels[i]} / predicted {labels[j]}: {v}'))
|
|
572
|
+
if cell>=18: text(x+cell/2,y+cell/2,str(v),fill=INK if t<.48 else '#FFFFFF',size=min(17,max(9,int(cell/5))))
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
def main():
|
|
576
|
+
root=tk.Tk(); Studio(root); root.mainloop()
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
if __name__=='__main__': main()
|