jaifar530 commited on
Commit
91871c3
·
unverified ·
1 Parent(s): 6548f98
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -1,9 +1,8 @@
1
  import streamlit as st
2
  st.write("Test system if working")
3
-
4
  import os
5
  import requests
6
- import subprocess # Import the subprocess module
7
  from keras.models import load_model
8
  from keras.preprocessing.text import Tokenizer
9
  from keras.preprocessing.sequence import pad_sequences
@@ -40,21 +39,20 @@ if not os.path.exists('my_authorship_model'):
40
  if os.path.exists(zip_file_path):
41
  st.write("Zip file exists")
42
 
43
- # # Debugging: List contents of the zip file using unzip
44
- # subprocess.run(['unzip', '-l', zip_file_path])
45
-
46
- # Extract the model using unzip
47
- unzip_result = subprocess.run(['unzip', '-o', zip_file_path, '-d', 'my_authorship_model'])
48
-
49
- # Debugging: Check unzip exit code (0 means success)
50
- if unzip_result.returncode == 0:
51
- st.write("Model folder successfully extracted using unzip")
52
  # Debugging: List the directory contents after extraction
53
  st.write("Listing directory contents:")
54
  st.write(os.listdir('.'))
55
  else:
56
- st.write("Model folder was not extracted successfully using unzip")
57
  exit(1)
 
58
  else:
59
  st.write("Zip file does not exist")
60
  exit(1)
 
1
  import streamlit as st
2
  st.write("Test system if working")
3
+ import zipfile
4
  import os
5
  import requests
 
6
  from keras.models import load_model
7
  from keras.preprocessing.text import Tokenizer
8
  from keras.preprocessing.sequence import pad_sequences
 
39
  if os.path.exists(zip_file_path):
40
  st.write("Zip file exists")
41
 
42
+ # Extract the model using zipfile
43
+ with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
44
+ zip_ref.extractall('my_authorship_model')
45
+
46
+ # Debugging: Check if the folder is successfully created
47
+ if os.path.exists('my_authorship_model'):
48
+ st.write("Model folder successfully extracted using zipfile")
 
 
49
  # Debugging: List the directory contents after extraction
50
  st.write("Listing directory contents:")
51
  st.write(os.listdir('.'))
52
  else:
53
+ st.write("Model folder was not extracted successfully using zipfile")
54
  exit(1)
55
+
56
  else:
57
  st.write("Zip file does not exist")
58
  exit(1)