Spaces:
Sleeping
Sleeping
Pradeep Kumar
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,27 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
-
|
| 3 |
-
# Command to clone the repository
|
| 4 |
-
clone_command = [
|
| 5 |
-
'git', 'clone', '--depth', '1', '-b', 'v2.17.0', 'https://github.com/tensorflow/models.git'
|
| 6 |
-
]
|
| 7 |
-
|
| 8 |
-
# Run the command
|
| 9 |
-
subprocess.run(clone_command, check=True)
|
| 10 |
-
|
| 11 |
-
# Verify the contents of the cloned repository
|
| 12 |
-
import os
|
| 13 |
-
print(f"Files in 'models' directory:", os.listdir('models'))
|
| 14 |
-
|
| 15 |
import zipfile
|
| 16 |
import sys
|
| 17 |
import os
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Check current directory and list files
|
| 20 |
print("Current Directory:", os.getcwd())
|
| 21 |
print("Files in Directory:", os.listdir())
|
| 22 |
|
| 23 |
-
with zipfile.ZipFile(r'/home/user/app/models.zip', 'r') as zip_ref:
|
| 24 |
-
zip_ref.extractall(r'/home/user/app/models/')
|
| 25 |
-
print("file extracted")
|
| 26 |
-
print("Current Directory:", os.getcwd())
|
| 27 |
-
print("Files in Directory:", os.listdir())
|
| 28 |
-
|
| 29 |
-
|
| 30 |
sys.path.append('models')
|
| 31 |
import numpy as np
|
| 32 |
import tensorflow as tf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import zipfile
|
| 2 |
import sys
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Paths to the ZIP file and the extraction directory
|
| 6 |
+
zip_file_path = '/home/user/app/models.zip'
|
| 7 |
+
extract_dir = '/home/user/app/models/'
|
| 8 |
+
|
| 9 |
+
# Ensure the extraction directory exists (create it if it doesn't)
|
| 10 |
+
if not os.path.exists(extract_dir):
|
| 11 |
+
os.makedirs(extract_dir)
|
| 12 |
+
|
| 13 |
+
# Unzipping the file
|
| 14 |
+
try:
|
| 15 |
+
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
| 16 |
+
zip_ref.extractall(extract_dir)
|
| 17 |
+
print(f"Files in '{extract_dir}' directory:", os.listdir(extract_dir))
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print(f"An error occurred: {e}"
|
| 20 |
+
|
| 21 |
# Check current directory and list files
|
| 22 |
print("Current Directory:", os.getcwd())
|
| 23 |
print("Files in Directory:", os.listdir())
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
sys.path.append('models')
|
| 26 |
import numpy as np
|
| 27 |
import tensorflow as tf
|