newRoop commited on
Commit
9c57b99
Β·
verified Β·
1 Parent(s): 53148a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -43,10 +43,19 @@ def check_tensorflow_installation():
43
  except ImportError:
44
  print("TensorFlow is not installed.")
45
  install_tensorflow()
46
- return False
 
 
 
 
 
 
 
 
47
 
48
  if not check_tensorflow_installation():
49
- check_tensorflow_installation()
 
50
 
51
  import tensorflow as tf
52
  from tensorflow.keras.layers import Input, Add, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D, MaxPooling2D, AveragePooling2D, Dropout
@@ -68,17 +77,22 @@ except ImportError:
68
  if IS_COLAB:
69
  try:
70
  drive.mount("/content/drive", timeout_ms=60000)
 
 
 
71
  except Exception as e:
72
  print(f"Error mounting drive: {e}")
73
  print("Continuing without Google Drive...")
74
- train_dir = 'train'
75
- val_dir = 'val'
76
- test_dir = 'test'
 
 
77
  else:
78
  # **IMPORTANT: Update these paths to the actual location of your data!**
79
- train_dir = "/content/drive/MyDrive/Periodontal_lessDataSet/train" # Replace with your actual path
80
- val_dir = "/content/drive/MyDrive/Periodontal_lessDataSet/val" # Replace with your actual path
81
- test_dir = "/content/drive/MyDrive/Periodontal_lessDataSet/test" # Replace with your actual path
82
 
83
  if not os.path.exists(train_dir):
84
  print(f"Error: Training data directory not found at {train_dir}")
 
43
  except ImportError:
44
  print("TensorFlow is not installed.")
45
  install_tensorflow()
46
+ try:
47
+ import tensorflow as tf
48
+ print(f"TensorFlow version: {tf.__version__}")
49
+ print("TensorFlow is installed and ready to use.")
50
+ return True
51
+ except ImportError:
52
+ return False
53
+
54
+
55
 
56
  if not check_tensorflow_installation():
57
+ print("TensorFlow installation failed. Exiting.")
58
+ sys.exit(1)
59
 
60
  import tensorflow as tf
61
  from tensorflow.keras.layers import Input, Add, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D, MaxPooling2D, AveragePooling2D, Dropout
 
77
  if IS_COLAB:
78
  try:
79
  drive.mount("/content/drive", timeout_ms=60000)
80
+ train_dir = "/content/drive/MyDrive/Periodontal_lessDataSet/train"
81
+ val_dir = "/content/drive/MyDrive/Periodontal_lessDataSet/val"
82
+ test_dir = "/content/drive/MyDrive/Periodontal_lessDataSet/test"
83
  except Exception as e:
84
  print(f"Error mounting drive: {e}")
85
  print("Continuing without Google Drive...")
86
+ print("Please ensure your data is in the correct local paths.")
87
+ train_dir = "train" # These should be set even if the drive fails.
88
+ val_dir = "val"
89
+ test_dir = "test"
90
+
91
  else:
92
  # **IMPORTANT: Update these paths to the actual location of your data!**
93
+ train_dir = "train" # Replace with your actual path
94
+ val_dir = "val" # Replace with your actual path
95
+ test_dir = "test" # Replace with your actual path
96
 
97
  if not os.path.exists(train_dir):
98
  print(f"Error: Training data directory not found at {train_dir}")