-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegrate_model.py
More file actions
65 lines (54 loc) · 1.93 KB
/
integrate_model.py
File metadata and controls
65 lines (54 loc) · 1.93 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
import os
import subprocess
import sys
def run_command(cmd):
"""Run a command and return success status"""
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print(f"SUCCESS: {cmd}")
return True
else:
print(f"FAILED: {cmd}")
print(f"Error: {result.stderr}")
return False
except Exception as e:
print(f"FAILED: {cmd} - Exception: {e}")
return False
def integrate_model():
print("Integrating Graph Classifier Model")
print("=" * 50)
# Check if model file exists
if not os.path.exists('graph_classifier_model.pth'):
print("ERROR: graph_classifier_model.pth not found!")
return False
print("Model file found: graph_classifier_model.pth")
# Install dependencies
print("\nInstalling Python dependencies...")
if not run_command("pip install -r requirements.txt"):
return False
# Analyze model structure
print("\nAnalyzing model structure...")
if not run_command("python test_model.py"):
print("WARNING: Model analysis failed, but continuing...")
# Convert model
print("\nConverting PyTorch model to TensorFlow...")
if not run_command("python convert_model.py"):
return False
# Check if conversion was successful
if os.path.exists('model.h5'):
print("Model converted successfully to model.h5")
else:
print("Model conversion failed")
return False
print("\nIntegration complete!")
print("\nNext steps:")
print("1. Start backend: python graph_generator.py")
print("2. Start frontend: npm start")
print("3. Use 'Classify Graph' button in the UI")
return True
if __name__ == "__main__":
success = integrate_model()
if not success:
print("\nIntegration failed. Please check the errors above.")
sys.exit(1)