# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import pandas as pd
import pickle
import cv2

infile = open('config.pickle','rb')
new_dict = pickle.load(infile)
infile.close()

len(new_dict.class_mapping)

new_dict.class_mapping

bbx_df = pd.read_csv('disease_bbx.csv')

thic = 2
box_color_SPD = (102, 102, 255)
box_color_ADB = (102, 255, 255)
box_color_SS = (102, 255, 102)
box_color_EPD = (255, 255, 102)
label_color = (255, 255, 255)
for i,j in zip(bbx_df.img_name.unique(),bbx_df.path.unique()):
    img = cv2.imread(j)	
    cv2.rectangle(img,(4,4),(6,10),box_color_SPD,2)
    cv2.rectangle(img,(4,17),(6,23),box_color_ADB,2)
    cv2.rectangle(img,(4,29),(6,35),box_color_SS,2)
    cv2.rectangle(img,(4,41),(6,47),box_color_EPD,2)
    cv2.putText(img, "SPD", (10,11), cv2.FONT_HERSHEY_DUPLEX, 0.4, box_color_SPD)
    cv2.putText(img, "ADB", (10,24), cv2.FONT_HERSHEY_DUPLEX, 0.4, box_color_ADB)
    cv2.putText(img, "SS", (10,36), cv2.FONT_HERSHEY_DUPLEX, 0.4, box_color_SS)
    cv2.putText(img, "EPD", (10,48), cv2.FONT_HERSHEY_DUPLEX, 0.4, box_color_EPD)
    for _,row in bbx_df[bbx_df.img_name == i].iterrows():
        if row['class'] == "SPD":
            img = cv2.rectangle(img,(row.x1,row.y1),(row.x2,row.y2),box_color_SPD,thic)
            img = cv2.putText(img, row['class'], (row.x1,row.y1), cv2.FONT_HERSHEY_DUPLEX, 0.5, (255,255,255))
        elif row['class'] == "ADB":
            img = cv2.rectangle(img,(row.x1,row.y1),(row.x2,row.y2),box_color_ADB,thic)
            img = cv2.putText(img, row['class'], (row.x1,row.y1), cv2.FONT_HERSHEY_DUPLEX, 0.5, (255,255,255))
        elif row['class'] == "SS":
            img = cv2.rectangle(img,(row.x1,row.y1),(row.x2,row.y2),box_color_SS,thic)
            img = cv2.putText(img, row['class'], (row.x1,row.y1), cv2.FONT_HERSHEY_DUPLEX, 0.5, (255,255,255))
        elif row['class'] == "EPD":
            img = cv2.rectangle(img,(row.x1,row.y1),(row.x2,row.y2),box_color_EPD,thic)
            img = cv2.putText(img, row['class'], (row.x1,row.y1), cv2.FONT_HERSHEY_DUPLEX, 0.5, (255,255,255))
    cv2.imwrite('results_imgs\{}'.format(i),img)

import os
import glob

path = './SPD_result'

files = glob.glob(path + '/*')
for f in files:
    os.remove(f)

sve_loc_list = ['./SPD_result/','./SS_result/','./EPD_result/','./ADB_result/']

for r in sve_loc_list+['./results_imgs/']:
    print()
    print(r)

sve_loc_list



StarcoderdataJupyterScriptsDedupFiltered