예제 #1
0
def getPep():
    regex = {
	"capital_letters": re.compile("[A-Z]")
    }
    clean     = []
    cont      = 0
    path_file = "./virus_genome/peptite/antiviral.fasta"
    pathSave  = "path-to/pepdata"
    with open(path_file, 'r') as f:
        lines = f.readlines()
    for l in lines:
        clean.append(l.replace("\n", ""))    
    for pep in clean:
        # string preprocessing
        if ">" in pep: 
            continue
        if "-" in pep:
            continue
        if "(" in pep:
            continue
        if regex["capital_letters"].match(pep):
            print("..." + pep)
            text_to_image.encode(pep,os.path.join(pathSave,pep+".png"))
            img = cv2.imread(os.path.join(pathSave,pep+".png"))
            img = cv2.resize(img,(256,256))
            cv2.imwrite(os.path.join(pathSave,pep+".png"), img) 
예제 #2
0
def getData(nstrandsList,pathSave):
    cont = 0
    for s in tqdm(nstrandsList):
        text_to_image.encode(s,os.path.join(pathSave,"strands_"+str(cont)+".png"))
        img = cv2.imread(os.path.join(pathSave,"strands_"+str(cont)+".png"))
        img = cv2.resize(img,(256,256))
        cv2.imwrite(os.path.join(pathSave,"strands_"+str(cont)+".png"), img) 
        cont += 1
예제 #3
0
def main():
    os.makedirs("multi-label-png")
    os.makedirs("multi-label")
    df = pd.read_csv("test-cc")
    for index, row in df.iterrows():
        text_to_image.encode(row["sequences"],
                             "multi-label-png/" + row["proteins"])
        image = cv2.imread("multi-label-png/" + row["proteins"] + ".png", 0)
        resizedImage = cv2.resize(image, (299, 299))
        cv2.imwrite("multi-label/" + row["proteins"] + ".jpg", resizedImage)
예제 #4
0
def encrypt(request):
    if request.method == 'POST':

        input_value = request.POST['iptextarea']
        input_value = str(input_value)
        inp_conversion = Fernet(settings.ENCRYPT_KEY)
        encrypt_text = inp_conversion.encrypt(input_value.encode('ascii'))
        encrypted_text = base64.urlsafe_b64encode(encrypt_text).decode('ascii')

        encrypted_image = text_to_image.encode(
            encrypted_text, 'image.png')  #converting encrypted data into image
        encrypted_image = Image.open(encrypted_image)  #converted

        #encrypted_image = encrypted_image.resize((300,300))
        image_path = 'C:/Users/Ganesh vamsi/MY PROJECTS/image-encrypt-decrypt/image_en_de/static/temp_img/image.png'
        encrypted_image.save(image_path, 'PNG')  #saving the image temporarly
        '''
        image = PIL.Image.open(image_path)
        w,h=image.size
        print('44444444444555555',w,h)
        image.close()
        '''
        with open(image_path, 'rb') as image_file:
            image_data = base64.b64encode(image_file.read()).decode('utf-8')

        ctx = dict()
        ctx['encrypted_image'] = image_data
        os.remove(image_path, dir_fd=None)
        sentence = 'Download the below encrypted image'
        ctx['sentence'] = sentence
        ctx['enalbe_disable'] = 'enabled'  #output and download btn visibility
        return render(request, 'encrypt.html', ctx)
    return render(request, 'encrypt.html', {'enalbe_disable': 'disabled'})
예제 #5
0
def text_to_Image():
    global encoded_image_path
    global inputt
    inputt=input("Enter text: ")
    encoded_image_path = text_to_image.encode(inputt, "test")
    print('This is a test print', encoded_image_path, inputt)
    print('file is opend!!!!!!!!!!')
    encoded_image_path = text_to_image.encode_file("../test/test.txt", "result.png")
    return text_to_Image
예제 #6
0
def write_image_from_hex(hex_content, out_path):  # out path including .png
    text_to_image.encode(hex_content, 'images/' + out_path)
예제 #7
0
train, test = 100000, 100000

for i in range(2, 99999):
    if (w_sheet.Cells(i, 1).Value == None):
        break
    if (w_sheet.Cells(i, 3).Value == None):
        w_sheet.Cells(i, 3).Value = '0 미정'  #라벨빈칸 '0 미정'으로 바꿈

    st1 = w_sheet.Cells(i, 1).Value  # 회사명 받기
    st2 = w_sheet.Cells(i, 2).Value  # 가게명 받기
    st1 = str(st1)
    st2 = str(st2)  #스트링 형식으로

    de = w_sheet.Cells(i, 3).Value  # 라벨 받아오기

    encoded_image_path = text_to_image.encode(
        st1 + st2,
        "C:\\Users\\aiia\\.atom\\python\\text_to_image_2\\test\\a_%d_%d.png" %
        (test, de))  #이미지로 인코딩
    img = Image.open(
        "C:\\Users\\aiia\\.atom\\python\\text_to_image_2\\test\\a_%d_%d.png" %
        (test, de))  # 이미지 사이즈 조절을 위해 이미지 다시 받아오기
    re_img = img.resize((28, 28))  # 이미지 크기 설정
    re_img.save(
        "C:\\Users\\aiia\\.atom\\python\\text_to_image_2\\test\\a_%d_%d.png" %
        (test, de))  # 변경된 이미지 다시 저장
    test = test + 1

excel_file.Save()
excel.Quit()
예제 #8
0
    def pre_img(self):

        if os.path.exists(self.img_PATH):
            for file in os.scandir(self.img_PATH):
                os.remove(file.path)

        WIDTH, HEIGHT = 28, 28
        train, test = 100000, 100000

        ###### 등록번호 '-' 기호 지우기 ####
        '''
        if self.T == '영수증':
            buyer = '회사등록번호'
        else:
            buyer = '사업자등록번호'
        '''
        buyer = 'NO_BIZ'
        seller = 'NO_BIZ_C'


        try:
            buyer_raw_data = self.df[buyer].str.split('-', n=2, expand=True)
            buyer_raw_data[buyer] = buyer_raw_data[0].str.cat(buyer_raw_data[1])
            buyer_raw_data[buyer] = buyer_raw_data[buyer].str.cat(buyer_raw_data[2]).copy()
            del (buyer_raw_data[0])
            del (buyer_raw_data[1])
            del (buyer_raw_data[2])
            buyer_raw_data = buyer_raw_data.astype('str')

            del (self.df[buyer])
            self.df[buyer] = buyer_raw_data[buyer].astype('str')
        except AttributeError:
            print('-부호 없음')

        try:
            buyer_raw_data2 = self.df[seller].str.split('-', n=2, expand=True)
            print('buyer_raw_data2', buyer_raw_data2)
            buyer_raw_data2[seller] = buyer_raw_data2[0].str.cat(buyer_raw_data2[1])
            buyer_raw_data2[seller] = buyer_raw_data2[seller].str.cat(buyer_raw_data2[2]).copy()
            del (buyer_raw_data2[0])
            del (buyer_raw_data2[1])
            del (buyer_raw_data2[2])
            buyer_raw_data2 = buyer_raw_data2.astype('str')

            del (self.df['NO_BIZ_C'])
            self.df['NO_BIZ_C'] = buyer_raw_data2['NO_BIZ_C'].astype('str')

            ###################################
        except AttributeError:
            print('-부호 없음')




        # print(ind[0])
        name = buyer
        # xl = excel_PATH2 + 'total_17_18_new.xlsx'
        name2 = 'NO_BIZ_C'
        target = 'CD_ACCOUNT'
        if self.T == '계산서' :
            e_name = 'e_bill_2019_uniq.json'
        elif self.T == '영수증':
            e_name = 'cash_train.json'
        elif self.T == '기타' :
            e_name = 'etc.json'
        df = comp(self.comend,self.excel_PATH, self.T, self.df, target, e_name, name, name2)

        # df = comp(df,target, 'e_bill_2019_uniq.xlsx',name)

        # print(len(data))
        # print(df)
        print(df.head())

        if self.T == '영수증' or self.T == '기타':
            pre_data = df.loc[:, [name,name2]].astype('str')
            pre_data[name] = pre_data[name].str.replace(' ','')
            pre_data[name2] = pre_data[name2].str.replace(' ','')
            if self.comend == 'train':
                pre_data[target] = df[target].astype('str')
        else :
            name = 'NM_ITEM'
            pre_data = df.loc[:, [name]].astype('str')
            pre_data[name] = pre_data[name].str.replace(' ', '')
            if self.comend == 'train':
                pre_data[target] = df[target].astype('str')
            #print(pre_data.head())

        if os.path.exists(self.img_PATH):
            print("already eixts path")
        else :
            os.mkdir(self.img_PATH)
            print("create path")

        for i in range(len(pre_data)):
            img_num = train + i
            obj = pre_data.loc[i, [name]].item()
            # obj += pre_data.loc[i,[name2]].item() ##name2도 이미지화 하는데 같이 고려해야 한다면
            if self.comend == 'train':
                c_num = pre_data.loc[i, [target]].str.split(' ', n=2, expand=True)
                text2img.encode(obj, self.img_PATH + 'a_%d_%d.png' % (img_num, c_num[0]))
                img = Image.open(self.img_PATH + 'a_%d_%d.png' % (img_num, c_num[0]))
                resize_img = img.resize((WIDTH, HEIGHT))
                resize_img.save(self.img_PATH + 'a_%d_%d.png' % (img_num, c_num[0]))
                print('이미지화 : %d / %d' % (i, len(pre_data)))
            else :
                #c_num = pre_data.loc[i, [target]].str.split(' ', n=2, expand=True)
                text2img.encode(obj, self.img_PATH + 'a_%d.png' % (img_num))
                img = Image.open(self.img_PATH + 'a_%d.png' % (img_num))
                resize_img = img.resize((WIDTH, HEIGHT))
                resize_img.save(self.img_PATH + 'a_%d.png' % (img_num))
                print('이미지화 : %d / %d' % (i, len(pre_data)))
예제 #9
0
    list_notes = []
    for note in notes:

        note_td = note.find_all('td', valign="top")
        str_note_td = str(note_td)
        clean3 = re.compile('<.*?>')
        clean4 = (re.sub(clean, '', str_note_td))
        list_notes.append(clean4)
    #pd.set_option('display.max_colwidth', 60)
    df = pd.DataFrame(list_notes)
    table = str.maketrans('', '', string.punctuation)
    table = str.maketrans('', '', "xa0\xa0\r\n\t\t\t\t\t'")
    stripped = [w.translate(table) for w in df[0]]
    p = df[df[0].str.contains("2013") == True]
    p = p[p[0].str.contains("B.Tech") == True]
    np = p.values
    dicter = p.to_string()
    encoded_image_path = text_to_image.encode(dicter, "image1.png")

    text, chat = get_last_chat_id_and_text(get_updates())
    send_image('/home/sj/Documents/products/noteifi/test.png', chat)
    send_message(
        'Displaying Last {} notifications containing 2013 and B.Tech as tags'.
        format(len(np)), chat)

    for i in range(len(np)):
        send_message(np[i], chat)

        print(np[i])
    time.sleep(43200)
예제 #10
0
# generate random string of 5 characters
import string
import random
import text_to_image


def id_generator(size=6, chars=string.ascii_lowercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))


# for x in range(100):
# 	S = id_generator(5)
# 	print(str(x) + '. ' + S)

S = id_generator(5)
print(S)

encoded_image_path = text_to_image.encode(S, "image.png")

print(encoded_image_path)