Om Prakash Singh commited on
Commit
5d2e65e
1 Parent(s): 3ab8725

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -1,5 +1,22 @@
1
  from tensorflow.keras.models import load_model
2
- import tensorflow as tf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  import gradio as gr
4
  import numpy as np
5
 
 
1
  from tensorflow.keras.models import load_model
2
+ try:
3
+ import tensorflow as tf
4
+ print("TensorFlow version:", tf.__version__)
5
+ except ImportError:
6
+ print("TensorFlow is not installed. Installing now...")
7
+ try:
8
+ import pip
9
+ pip.main(['install', 'tensorflow'])
10
+ except AttributeError:
11
+ import subprocess
12
+ subprocess.call(['pip', 'install', 'tensorflow'])
13
+
14
+ # Now try importing again
15
+ try:
16
+ import tensorflow as tf
17
+ print("TensorFlow has been successfully installed. Version:", tf.__version__)
18
+ except ImportError:
19
+ print("Installation failed. Please install TensorFlow manually.")
20
  import gradio as gr
21
  import numpy as np
22