Spaces:
Running
Running
jaifar530
commited on
fix zip
Browse files
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 |
-
#
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
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
|
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)
|