I have two python scripts one of whic has to write a json
(file1.py
) and another one(file2.py
) is to import file1
.
My python script file1.py
has executed successfully, but when I try to import in file2.py
it doesn't work as it contain if __name__ == '__main__':
file1.py
def demo(opt,streamPixel):
#some functions
if __name__ == '__main__':
streamPixel = "{\"type\":\"FeatureCollection\",\"features\":["
#parser = argparse.ArgumentParser()
Transformation= 'TPS'
FeatureExtraction = 'ResNet'
SequenceModeling = 'BiLSTM'
Prediction = 'Attn'
num_fiducial = 20
input_channel = 1
output_channel = 512
imgH = 72
imgW =320
hidden_size = 256
rgb = False
batch_max_length = 25
character = '01'
sensitive =True
#PAD = True
image_folder ='D:/work/source_code/VIC_OCR/cropped'
workers = 4
batch_size= 192
num_class = 4
saved_model = 'D:\\SARIGHA\\source_code\\saved_models\\TPS-ResNet-BiLSTM-Attn-Seed323\\best_accuracy.pth'
opt = None
""" vocab / character number configuration """
if sensitive:
character = string.printable[:-6] # same with ASTER setting (use 94 char).
cudnn.benchmark = True
cudnn.deterministic = True
num_gpu = torch.cuda.device_count()
demo(opt,streamPixel)
file2.py:
import file1
from file1 import demo
if I run my file2.py
is simply produce like this
(victoria) D:\work\source_code\textReg\imageOrientation>python file2.py
(victoria) D:\work\source_code\textReg\imageOrientation>
is there is any possible to import file1.py in file2.py