nguyen-brat
commited on
Commit
•
13c174c
1
Parent(s):
0ba87af
update
Browse files- Dockerfile +2 -0
- app.py +19 -1
Dockerfile
CHANGED
@@ -69,6 +69,8 @@ RUN chmod 777 $HOME/app/text-remove/test_folder
|
|
69 |
# Make port 7860 available to the world outside this container
|
70 |
EXPOSE 7860
|
71 |
|
|
|
|
|
72 |
# Run app.py when the container launches
|
73 |
ENTRYPOINT ["streamlit", "run"]
|
74 |
CMD ["app.py", "--server.port=7860", "--server.headless=true", "--server.enableCORS=false", "--server.enableXsrfProtection=false", "--server.fileWatcherType=none"]
|
|
|
69 |
# Make port 7860 available to the world outside this container
|
70 |
EXPOSE 7860
|
71 |
|
72 |
+
ENV PYTHONPATH=$HOME/app/text-remove
|
73 |
+
|
74 |
# Run app.py when the container launches
|
75 |
ENTRYPOINT ["streamlit", "run"]
|
76 |
CMD ["app.py", "--server.port=7860", "--server.headless=true", "--server.enableCORS=false", "--server.enableXsrfProtection=false", "--server.fileWatcherType=none"]
|
app.py
CHANGED
@@ -6,8 +6,26 @@ import zipfile
|
|
6 |
import io
|
7 |
import shutil
|
8 |
import time
|
|
|
9 |
from PIL import Image
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def run_bash_script(input_image_path, output_path, progress_placeholder, status_text):
|
12 |
bash_command = f"bash config/text_detection.sh -s {input_image_path} -t {output_path}"
|
13 |
process = subprocess.Popen(bash_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
@@ -69,7 +87,7 @@ if uploaded_file is not None:
|
|
69 |
|
70 |
input_file_path = os.path.join(input_path, uploaded_file.name)
|
71 |
image = Image.open(uploaded_file)
|
72 |
-
image.save(input_file_path)
|
73 |
|
74 |
if st.button("Run Text Detection"):
|
75 |
progress_placeholder = st.empty()
|
|
|
6 |
import io
|
7 |
import shutil
|
8 |
import time
|
9 |
+
import sys
|
10 |
from PIL import Image
|
11 |
|
12 |
+
def GET_PROJECT_ROOT():
|
13 |
+
count = 0
|
14 |
+
# goto the root folder of LogBar
|
15 |
+
current_abspath = os.path.abspath(__file__)
|
16 |
+
while True:
|
17 |
+
if count > 1000:
|
18 |
+
print("Can find root error")
|
19 |
+
sys.exit()
|
20 |
+
if os.path.split(current_abspath)[1] == 'text-remove':
|
21 |
+
project_root = current_abspath
|
22 |
+
break
|
23 |
+
else:
|
24 |
+
current_abspath = os.path.dirname(current_abspath)
|
25 |
+
return project_root
|
26 |
+
|
27 |
+
PROJECT_ROOT = GET_PROJECT_ROOT()
|
28 |
+
|
29 |
def run_bash_script(input_image_path, output_path, progress_placeholder, status_text):
|
30 |
bash_command = f"bash config/text_detection.sh -s {input_image_path} -t {output_path}"
|
31 |
process = subprocess.Popen(bash_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
|
87 |
|
88 |
input_file_path = os.path.join(input_path, uploaded_file.name)
|
89 |
image = Image.open(uploaded_file)
|
90 |
+
image.save(os.path.join(PROJECT_ROOT, input_file_path))
|
91 |
|
92 |
if st.button("Run Text Detection"):
|
93 |
progress_placeholder = st.empty()
|