-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixed-dpg-ui.py
More file actions
executable file
·82 lines (68 loc) · 2.27 KB
/
fixed-dpg-ui.py
File metadata and controls
executable file
·82 lines (68 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
"""
Fixed launcher script for OneTrainer DPG UI that patches compatibility issues.
"""
import os
import sys
import traceback
def apply_quick_fixes():
"""Apply quick fixes for known issues"""
try:
# Create a simple class with the required attributes if importing fails
with open("quick_fix.py", "w") as f:
f.write("""
# Quick fix to handle missing attributes
import sys
import os
def fix_train_config():
try:
from modules.util.config.TrainConfig import TrainConfig
# Add mixed_precision attribute if it doesn't exist
if not hasattr(TrainConfig, 'mixed_precision'):
print("Adding mixed_precision attribute to TrainConfig")
setattr(TrainConfig, 'mixed_precision', property(
lambda self: getattr(self, 'train_dtype', None) in ['float16', 'bfloat16'],
lambda self, value: None
))
return True
except ImportError:
return False
# Apply the fix
fix_train_config()
""")
# Run the quick fix
import quick_fix
return True
except Exception as e:
print(f"Error applying quick fixes: {e}")
return False
# Apply quick fixes first
apply_quick_fixes()
# Simple wrapper to launch onetrainer_dpg_full.py
try:
# Add the current directory to the path
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# Check for DPG
try:
import dearpygui.dearpygui as dpg
except ImportError:
print("DearPyGui not found. Please install it with: pip install dearpygui")
sys.exit(1)
# Import mock config if needed
try:
from modules.util.config.TrainConfig import TrainConfig
print("Using real TrainConfig")
except ImportError:
print("Using mock TrainConfig")
# Import will be handled by the patched file
# Import and run the app
print("Launching OneTrainer DPG UI...")
from onetrainer_dpg_full import OneTrainerDPG
app = OneTrainerDPG()
app.run()
except Exception as e:
traceback.print_exc()
print(f"Error starting OneTrainer DPG UI: {e}")
input("Press Enter to exit...")