Dhanushlevi commited on
Commit
a20c444
·
1 Parent(s): fd3fd3e

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +71 -0
  2. best_accuracy.pth +3 -0
  3. log_demo_result.txt +56 -0
  4. output.txt +11 -0
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import subprocess
3
+ import os
4
+ import time
5
+ import pandas as pd
6
+ from PIL import Image
7
+
8
+ def run_command(command):
9
+ process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
10
+ process.communicate()
11
+
12
+ def main():
13
+ st.set_page_config(
14
+ page_title="OCR Captcha Solver",
15
+ page_icon=":books:",
16
+ layout="wide",
17
+ initial_sidebar_state="expanded",
18
+ )
19
+
20
+ # Add title in the middle of the screen
21
+ st.write(
22
+ """
23
+ # OCR Captcha Solver
24
+ """
25
+ )
26
+
27
+ st.sidebar.title("Options")
28
+ st.sidebar.markdown("Upload an image and click the button to run text recognition.")
29
+
30
+ uploaded_file = st.sidebar.file_uploader("Upload an image", type=["jpg", "png"])
31
+
32
+ if uploaded_file is not None:
33
+ image_folder = "./user_images"
34
+ os.makedirs(image_folder, exist_ok=True)
35
+
36
+ image_path = os.path.join(image_folder, uploaded_file.name)
37
+ with open(image_path, "wb") as f:
38
+ f.write(uploaded_file.getbuffer())
39
+ st.success(f"Image successfully saved to {image_path}")
40
+
41
+ command = f"python C:/Users/Dhanush/Downloads/staret/deep-text-recognition-benchmark/demo.py > C:/Users/Dhanush/Downloads/staret/output.txt --image_folder C:/Users/Dhanush/Downloads/staret/user_images --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --saved_model C:/Users/Dhanush/Downloads/staret/best_accuracy.pth"
42
+
43
+ if st.sidebar.button("Run Text Recognition"):
44
+ with st.spinner("Running... Please wait."):
45
+ run_command(command)
46
+ time.sleep(3)
47
+
48
+ output_path = "C:/Users/Dhanush/Downloads/staret/output.txt"
49
+ if os.path.isfile(output_path):
50
+ with open(output_path, "r") as file:
51
+ output_lines = file.readlines()
52
+
53
+ if len(output_lines) > 5:
54
+ data = []
55
+ for line in output_lines[5:]:
56
+ line_data = line.strip().split('\t')
57
+ data.append(line_data)
58
+
59
+ df = pd.DataFrame(data, columns=["Image Path", "Predicted Labels", "Confidence Score"])
60
+ st.table(df)
61
+
62
+ # Display uploaded image
63
+ uploaded_image = Image.open(uploaded_file)
64
+ st.image(uploaded_image, caption="Uploaded Image", use_column_width=True)
65
+ else:
66
+ st.write("No results found.")
67
+ else:
68
+ st.write("The process is still running. Please wait for a moment and refresh the page.")
69
+
70
+ if __name__ == "__main__":
71
+ main()
best_accuracy.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a12309e2c9cb901cae996744f692297f5be3871aa8d6baeedcebf237a9759ff
3
+ size 198717893
log_demo_result.txt ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --------------------------------------------------------------------------------
2
+ image_path predicted_labels confidence score
3
+ --------------------------------------------------------------------------------
4
+ C:/Users/Dhanush/Downloads/staret/data/sample\2b827.png 2b827 0.9994
5
+ --------------------------------------------------------------------------------
6
+ image_path predicted_labels confidence score
7
+ --------------------------------------------------------------------------------
8
+ C:/Users/Dhanush/Downloads/staret/data/sample\2b827.png 2b827 0.9994
9
+ --------------------------------------------------------------------------------
10
+ image_path predicted_labels confidence score
11
+ --------------------------------------------------------------------------------
12
+ C:/Users/Dhanush/Downloads/staret/data/sample\2b827.png 2b827 0.9994
13
+ --------------------------------------------------------------------------------
14
+ image_path predicted_labels confidence score
15
+ --------------------------------------------------------------------------------
16
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
17
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
18
+ --------------------------------------------------------------------------------
19
+ image_path predicted_labels confidence score
20
+ --------------------------------------------------------------------------------
21
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
22
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
23
+ C:/Users/Dhanush/Downloads/staret/user_images\2g7nm.png 2g7nm 0.9994
24
+ --------------------------------------------------------------------------------
25
+ image_path predicted_labels confidence score
26
+ --------------------------------------------------------------------------------
27
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
28
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
29
+ C:/Users/Dhanush/Downloads/staret/user_images\2g7nm.png 2g7nm 0.9994
30
+ C:/Users/Dhanush/Downloads/staret/user_images\download.png xff8d 0.0354
31
+ --------------------------------------------------------------------------------
32
+ image_path predicted_labels confidence score
33
+ --------------------------------------------------------------------------------
34
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
35
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
36
+ C:/Users/Dhanush/Downloads/staret/user_images\2g7nm.png 2g7nm 0.9994
37
+ C:/Users/Dhanush/Downloads/staret/user_images\6m5eg.png 6m5eg 0.9999
38
+ C:/Users/Dhanush/Downloads/staret/user_images\download.png xff8d 0.0354
39
+ --------------------------------------------------------------------------------
40
+ image_path predicted_labels confidence score
41
+ --------------------------------------------------------------------------------
42
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
43
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
44
+ C:/Users/Dhanush/Downloads/staret/user_images\2g7nm.png 2g7nm 0.9994
45
+ C:/Users/Dhanush/Downloads/staret/user_images\6m5eg.png 6m5eg 0.9999
46
+ C:/Users/Dhanush/Downloads/staret/user_images\74853.png 74853 0.9999
47
+ C:/Users/Dhanush/Downloads/staret/user_images\download.png xff8d 0.0354
48
+ --------------------------------------------------------------------------------
49
+ image_path predicted_labels confidence score
50
+ --------------------------------------------------------------------------------
51
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
52
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
53
+ C:/Users/Dhanush/Downloads/staret/user_images\2g7nm.png 2g7nm 0.9994
54
+ C:/Users/Dhanush/Downloads/staret/user_images\6m5eg.png 6m5eg 0.9999
55
+ C:/Users/Dhanush/Downloads/staret/user_images\8n34n.png 8n34n 1.0000
56
+ C:/Users/Dhanush/Downloads/staret/user_images\74853.png 74853 0.9999
output.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model input parameters 32 100 20 1 512 256 38 25 TPS ResNet BiLSTM Attn
2
+ loading pretrained model from C:/Users/Dhanush/Downloads/staret/best_accuracy.pth
3
+ --------------------------------------------------------------------------------
4
+ image_path predicted_labels confidence score
5
+ --------------------------------------------------------------------------------
6
+ C:/Users/Dhanush/Downloads/staret/user_images\2enf4.png 2enf4 1.0000
7
+ C:/Users/Dhanush/Downloads/staret/user_images\2fxgd.png 2fxgd 0.9998
8
+ C:/Users/Dhanush/Downloads/staret/user_images\2g7nm.png 2g7nm 0.9994
9
+ C:/Users/Dhanush/Downloads/staret/user_images\6m5eg.png 6m5eg 0.9999
10
+ C:/Users/Dhanush/Downloads/staret/user_images\8n34n.png 8n34n 1.0000
11
+ C:/Users/Dhanush/Downloads/staret/user_images\74853.png 74853 0.9999