Spaces:
Runtime error
Runtime error
nyonyong
commited on
Commit
•
1fcea5a
1
Parent(s):
6dc60e4
Directory fix
Browse files- process.py +11 -11
process.py
CHANGED
@@ -20,22 +20,22 @@ def textDetection(im):
|
|
20 |
|
21 |
#change dir to yolo folder
|
22 |
#yolo_dir = "/HCR/TextDetection/"
|
23 |
-
subprocess.call('pwd', shell=True)
|
24 |
-
subprocess.call('ls', shell=True)
|
25 |
-
subprocess.call('sudo cd '+ Dir.yolo_dir, shell=True)
|
26 |
|
27 |
#transfrom ndarray type to PIL type
|
28 |
im = Image.fromarray(im)
|
29 |
|
30 |
# save input image to cookie folder
|
31 |
-
subprocess.call('cd cookie', shell=True)
|
32 |
-
im.save("user_input.jpg", 'JPEG')
|
33 |
|
34 |
#yolo_dir = "/HCR/TextDetection/"
|
35 |
-
subprocess.call('cd '+ Dir.yolo_dir, shell=True)
|
36 |
|
37 |
# (Shell) run detect.py to get cropped word images
|
38 |
-
subprocess.call(['python','detect.py',
|
39 |
#User Input Data : /text_detection/cookie
|
40 |
'--source','/cookie',
|
41 |
#Text Detection Model : /runs/wordDetection/weights/best.pt
|
@@ -54,14 +54,14 @@ def textDetection(im):
|
|
54 |
#return Image.fromarray(results.imgs[0])
|
55 |
|
56 |
def textRearrange():
|
57 |
-
subprocess.call('cd ' + Dir.DBSCAN_dir, shell=True)
|
58 |
-
subprocess.call(['python','DBSCAN.py'])
|
59 |
|
60 |
def textRecognition():
|
61 |
#%cd /content/drive/MyDrive/KITA/Text/lmdb/deep-text-recognition-benchmark
|
62 |
-
subprocess.call('cd '+Dir.recog_dir, shell=True)
|
63 |
#!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
|
64 |
-
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)
|
65 |
|
66 |
def getHcrResult(file_path):#*#
|
67 |
texts = ""
|
|
|
20 |
|
21 |
#change dir to yolo folder
|
22 |
#yolo_dir = "/HCR/TextDetection/"
|
23 |
+
#subprocess.call('pwd', shell=True)
|
24 |
+
#subprocess.call('ls', shell=True)
|
25 |
+
## subprocess.call('sudo cd '+ Dir.yolo_dir, shell=True)
|
26 |
|
27 |
#transfrom ndarray type to PIL type
|
28 |
im = Image.fromarray(im)
|
29 |
|
30 |
# save input image to cookie folder
|
31 |
+
## subprocess.call('cd cookie', shell=True)
|
32 |
+
im.save(Dir.yolo_dir+"/cookie/user_input.jpg", 'JPEG')
|
33 |
|
34 |
#yolo_dir = "/HCR/TextDetection/"
|
35 |
+
## subprocess.call('cd '+ Dir.yolo_dir, shell=True)
|
36 |
|
37 |
# (Shell) run detect.py to get cropped word images
|
38 |
+
subprocess.call(['python', Dir.yolo_dir+'/detect.py',
|
39 |
#User Input Data : /text_detection/cookie
|
40 |
'--source','/cookie',
|
41 |
#Text Detection Model : /runs/wordDetection/weights/best.pt
|
|
|
54 |
#return Image.fromarray(results.imgs[0])
|
55 |
|
56 |
def textRearrange():
|
57 |
+
## subprocess.call('cd ' + Dir.DBSCAN_dir, shell=True)
|
58 |
+
subprocess.call(['python', Dir.DBSCAN_dir+'/DBSCAN.py'])
|
59 |
|
60 |
def textRecognition():
|
61 |
#%cd /content/drive/MyDrive/KITA/Text/lmdb/deep-text-recognition-benchmark
|
62 |
+
## subprocess.call('cd '+Dir.recog_dir, shell=True)
|
63 |
#!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
|
64 |
+
subprocess.call('CUDA_VISIBLE_DEVICES="" python3 '+ Dir.recog_dir +'/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)
|
65 |
|
66 |
def getHcrResult(file_path):#*#
|
67 |
texts = ""
|