import xml.etree.ElementTree as ET
import os
import json
import glob
from tqdm import tqdm

if __name__ == "__main__":

    xml_path = '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole_xml/' 
    json_path = '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole.json'
    xml_files = glob.glob(xml_path + '*.xml')
    
    metrics_gt = {}
    
    for xml_file in tqdm(xml_files):
        # xml_file = os.path.join(xml_path,'1_3000.xml')
        tree = ET.parse(xml_file)
        root = tree.getroot()
        filename = root.find('filename').text
        bndbox_list = []

        for bndbox in root.iter('bndbox'):
            xmin = int(bndbox.find('xmin').text)
            ymin = int(bndbox.find('ymin').text)
            xmax = int(bndbox.find('xmax').text)
            ymax = int(bndbox.find('ymax').text)
            bndbox_list.append([xmin,ymin,xmax,ymax])

        metrics_gt[filename] = bndbox_list
        # print metrics_gt
        # break
    #print metrics_gt.keys()
    with open(json_path,'w') as f:
        json.dump(metrics_gt,f)
     

32c5398e6fc2286e329f486d8623327fc5b1fea7
<mask token>

<mask token>
if __name__ == '__main__':
    xml_path = '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole_xml/'
    json_path = (
        '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole.json')
    xml_files = glob.glob(xml_path + '*.xml')
    metrics_gt = {}
    for xml_file in tqdm(xml_files):
        tree = ET.parse(xml_file)
        root = tree.getroot()
        filename = root.find('filename').text
        bndbox_list = []
        for bndbox in root.iter('bndbox'):
            xmin = int(bndbox.find('xmin').text)
            ymin = int(bndbox.find('ymin').text)
            xmax = int(bndbox.find('xmax').text)
            ymax = int(bndbox.find('ymax').text)
            bndbox_list.append([xmin, ymin, xmax, ymax])
        metrics_gt[filename] = bndbox_list
    with open(json_path, 'w') as f:
        json.dump(metrics_gt, f)

import xml.etree.ElementTree as ET
import os
import json
import glob
from tqdm import tqdm
if __name__ == '__main__':
    xml_path = '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole_xml/'
    json_path = (
        '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole.json')
    xml_files = glob.glob(xml_path + '*.xml')
    metrics_gt = {}
    for xml_file in tqdm(xml_files):
        tree = ET.parse(xml_file)
        root = tree.getroot()
        filename = root.find('filename').text
        bndbox_list = []
        for bndbox in root.iter('bndbox'):
            xmin = int(bndbox.find('xmin').text)
            ymin = int(bndbox.find('ymin').text)
            xmax = int(bndbox.find('xmax').text)
            ymax = int(bndbox.find('ymax').text)
            bndbox_list.append([xmin, ymin, xmax, ymax])
        metrics_gt[filename] = bndbox_list
    with open(json_path, 'w') as f:
        json.dump(metrics_gt, f)

import xml.etree.ElementTree as ET
import os
import json
import glob
from tqdm import tqdm

if __name__ == "__main__":

    xml_path = '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole_xml/' 
    json_path = '/media/htic/NewVolume1/murali/mitosis/mitotic_count/whole.json'
    xml_files = glob.glob(xml_path + '*.xml')
    
    metrics_gt = {}
    
    for xml_file in tqdm(xml_files):
        # xml_file = os.path.join(xml_path,'1_3000.xml')
        tree = ET.parse(xml_file)
        root = tree.getroot()
        filename = root.find('filename').text
        bndbox_list = []

        for bndbox in root.iter('bndbox'):
            xmin = int(bndbox.find('xmin').text)
            ymin = int(bndbox.find('ymin').text)
            xmax = int(bndbox.find('xmax').text)
            ymax = int(bndbox.find('ymax').text)
            bndbox_list.append([xmin,ymin,xmax,ymax])

        metrics_gt[filename] = bndbox_list
        # print metrics_gt
        # break
    #print metrics_gt.keys()
    with open(json_path,'w') as f:
        json.dump(metrics_gt,f)
     
