81a5691526015b88f252e22a42c123720ee30c97,data/extract_bottomup.py,,main,#Any#,149

Before Change


    detectron_model = infer_engine.initialize_model_from_cfg(args.weights, args.gpu_id)

    // list of paths (example: "coco_train2014/COCO_train2014_000000123456.jpg")
    image_paths = [os.path.join(args.image_root, name)
                   for name in os.listdir(args.image_root)
                   if name not in {".", ".."}]

    // create an output HDF to save extracted features
    save_h5 = h5py.File(args.save_path, "w")
    image_ids_h5d = save_h5.create_dataset(

After Change


    detectron_model = infer_engine.initialize_model_from_cfg(args.weights, args.gpu_id)

    // list of paths (example: "coco_train2014/COCO_train2014_000000123456.jpg")
    image_paths = []
    for image_root in args.image_root:
        image_paths.extend([os.path.join(image_root, name)
                            for name in glob.glob(os.path.join(image_root, "*.jpg"))
                            if name not in {".", ".."}])

    // create an output HDF to save extracted features
    save_h5 = h5py.File(args.save_path, "w")
    image_ids_h5d = save_h5.create_dataset(
        "image_ids", (len(image_paths), )
    )

    // "features" is a chunked dataset, each chunk holds features from one image
    features_h5d = save_h5.create_dataset(
        "features", (len(image_paths), args.max_boxes, args.feat_dims),
        chunks=(1, args.max_boxes, args.feat_dims)
    )

    for idx, image_path in tqdm(enumerate(image_paths)):
        try:
            image_ids_h5d[idx] = image_id_from_path(image_path)

            image = cv2.imread(image_path)
            // we only care about features, not classes
            _, _, _, bottomup_features = detect_image(detectron_model, image, args)
            features_h5d[idx] = bottomup_features
        except:
            print(f"\nWarning: features from {idx}, {image_path} failed to extract.\n")
    // set current split name in attributrs of file, for tractability
    save_h5.attrs["split"] = args.split
    save_h5.close()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: batra-mlp-lab/visdial-challenge-starter-pytorch
Commit Name: 81a5691526015b88f252e22a42c123720ee30c97
Time: 2018-12-25
Author: karandesai281196@gmail.com
File Name: data/extract_bottomup.py
Class Name:
Method Name: main


Project Name: nipy/dipy
Commit Name: 39e8146b3d7354d1e34cd41a4eca19e70c053a4a
Time: 2019-08-05
Author: bramshq@gmail.com
File Name: dipy/stats/analysis.py
Class Name:
Method Name: bundle_analysis


Project Name: AllenCellModeling/pytorch_fnet
Commit Name: 2b4dfea5674a6b6b4d6556d7546a387f41f947fa
Time: 2017-11-10
Author: chek.o@outlook.com
File Name: tools/colorize_tifs.py
Class Name:
Method Name: