Spaces:
Runtime error
Runtime error
nyonyong
commited on
Commit
·
8ee5136
1
Parent(s):
f4d2a46
Directory fix
Browse files- TextRearrange/DBSCAN.py +2 -2
- app.py +1 -1
- directories.py +7 -7
- process.py +5 -4
TextRearrange/DBSCAN.py
CHANGED
|
@@ -8,8 +8,8 @@ import seaborn as sns
|
|
| 8 |
import matplotlib.pyplot as plt
|
| 9 |
from sklearn.cluster import DBSCAN
|
| 10 |
from sklearn.preprocessing import StandardScaler
|
| 11 |
-
import
|
| 12 |
-
|
| 13 |
|
| 14 |
"""
|
| 15 |
|
|
|
|
| 8 |
import matplotlib.pyplot as plt
|
| 9 |
from sklearn.cluster import DBSCAN
|
| 10 |
from sklearn.preprocessing import StandardScaler
|
| 11 |
+
import arrange as DbscanArrange
|
| 12 |
+
import directories as Dir
|
| 13 |
|
| 14 |
"""
|
| 15 |
|
app.py
CHANGED
|
@@ -10,7 +10,7 @@ def HCR(im):
|
|
| 10 |
ps.textRearrange()
|
| 11 |
ps.textRecognition()
|
| 12 |
hcr = ps.getHcrResult(Dir.txt_file_path)
|
| 13 |
-
subprocess.call('cd'+ Dir.yolo_dir, shell=True)
|
| 14 |
#clearDir()
|
| 15 |
|
| 16 |
return hcr
|
|
|
|
| 10 |
ps.textRearrange()
|
| 11 |
ps.textRecognition()
|
| 12 |
hcr = ps.getHcrResult(Dir.txt_file_path)
|
| 13 |
+
#subprocess.call('cd'+ Dir.yolo_dir, shell=True)
|
| 14 |
#clearDir()
|
| 15 |
|
| 16 |
return hcr
|
directories.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
home_dir = "
|
| 2 |
-
yolo_dir = "/
|
| 3 |
-
input_img = "/
|
| 4 |
detect_model_dir = "/runs/wordDetection/weights/best.pt"
|
| 5 |
cropped_img_folder_name = "user_output"
|
| 6 |
cropped_img_path = "/runs/detect/" + cropped_img_folder_name
|
| 7 |
folder_path = cropped_img_path + "/crops/word"
|
| 8 |
-
DBSCAN_dir = "/
|
| 9 |
-
recog_dir = "/
|
| 10 |
-
recog_model_dir=
|
| 11 |
-
txt_file_path = "/
|
|
|
|
| 1 |
+
home_dir = "~"
|
| 2 |
+
yolo_dir = "/TextDetection"
|
| 3 |
+
input_img = "/TextDetection/cookie/user_input.jpg"
|
| 4 |
detect_model_dir = "/runs/wordDetection/weights/best.pt"
|
| 5 |
cropped_img_folder_name = "user_output"
|
| 6 |
cropped_img_path = "/runs/detect/" + cropped_img_folder_name
|
| 7 |
folder_path = cropped_img_path + "/crops/word"
|
| 8 |
+
DBSCAN_dir = "/TextRearrange"
|
| 9 |
+
recog_dir = "/TextRecognition"
|
| 10 |
+
recog_model_dir = "/TextRecognition/best_accuracy_s/best_accuracy_s.pth"
|
| 11 |
+
txt_file_path = "/TextRecognition/log_demo_result.txt"
|
process.py
CHANGED
|
@@ -20,7 +20,8 @@ def textDetection(im):
|
|
| 20 |
|
| 21 |
#change dir to yolo folder
|
| 22 |
#yolo_dir = "/HCR/TextDetection/"
|
| 23 |
-
subprocess.call('
|
|
|
|
| 24 |
|
| 25 |
#transfrom ndarray type to PIL type
|
| 26 |
im = Image.fromarray(im)
|
|
@@ -30,7 +31,7 @@ def textDetection(im):
|
|
| 30 |
im.save("user_input.jpg", 'JPEG')
|
| 31 |
|
| 32 |
#yolo_dir = "/HCR/TextDetection/"
|
| 33 |
-
subprocess.call('cd'+ Dir.yolo_dir, shell=True)
|
| 34 |
|
| 35 |
# (Shell) run detect.py to get cropped word images
|
| 36 |
subprocess.call(['python','detect.py',
|
|
@@ -52,14 +53,14 @@ def textDetection(im):
|
|
| 52 |
#return Image.fromarray(results.imgs[0])
|
| 53 |
|
| 54 |
def textRearrange():
|
| 55 |
-
subprocess.call('cd' + Dir.DBSCAN_dir, shell=True)
|
| 56 |
subprocess.call(['python','DBSCAN.py'])
|
| 57 |
|
| 58 |
def textRecognition():
|
| 59 |
#%cd /content/drive/MyDrive/KITA/Text/lmdb/deep-text-recognition-benchmark
|
| 60 |
subprocess.call('cd '+Dir.recog_dir, shell=True)
|
| 61 |
#!CUDA_VISIBLE_DEVICES=0 python3 demo.py --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --image_folder /content/drive/MyDrive/KITA/Text/YOLO/runs/detect/youtube_data2/crops/word --saved_model /content/drive/MyDrive/KITA/Text/best_accuracy_s/best_accuracy_s.pth
|
| 62 |
-
subprocess.call('CUDA_VISIBLE_DEVICES="" python3 demo.py --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --image_folder ' + Dir.
|
| 63 |
|
| 64 |
def getHcrResult(file_path):#*#
|
| 65 |
texts = ""
|
|
|
|
| 20 |
|
| 21 |
#change dir to yolo folder
|
| 22 |
#yolo_dir = "/HCR/TextDetection/"
|
| 23 |
+
subprocess.call('pwd', shell=True)
|
| 24 |
+
subprocess.call('cd '+ Dir.yolo_dir, shell=True)
|
| 25 |
|
| 26 |
#transfrom ndarray type to PIL type
|
| 27 |
im = Image.fromarray(im)
|
|
|
|
| 31 |
im.save("user_input.jpg", 'JPEG')
|
| 32 |
|
| 33 |
#yolo_dir = "/HCR/TextDetection/"
|
| 34 |
+
subprocess.call('cd '+ Dir.yolo_dir, shell=True)
|
| 35 |
|
| 36 |
# (Shell) run detect.py to get cropped word images
|
| 37 |
subprocess.call(['python','detect.py',
|
|
|
|
| 53 |
#return Image.fromarray(results.imgs[0])
|
| 54 |
|
| 55 |
def textRearrange():
|
| 56 |
+
subprocess.call('cd ' + Dir.DBSCAN_dir, shell=True)
|
| 57 |
subprocess.call(['python','DBSCAN.py'])
|
| 58 |
|
| 59 |
def textRecognition():
|
| 60 |
#%cd /content/drive/MyDrive/KITA/Text/lmdb/deep-text-recognition-benchmark
|
| 61 |
subprocess.call('cd '+Dir.recog_dir, shell=True)
|
| 62 |
#!CUDA_VISIBLE_DEVICES=0 python3 demo.py --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --image_folder /content/drive/MyDrive/KITA/Text/YOLO/runs/detect/youtube_data2/crops/word --saved_model /content/drive/MyDrive/KITA/Text/best_accuracy_s/best_accuracy_s.pth
|
| 63 |
+
subprocess.call('CUDA_VISIBLE_DEVICES="" python3 demo.py --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --image_folder ' + Dir.yolo_dir + Dir.cropped_img_path + '/crops/word --saved_model '+ Dir.recog_model_dir, shell=True)
|
| 64 |
|
| 65 |
def getHcrResult(file_path):#*#
|
| 66 |
texts = ""
|