rs_subset should accept multiple file inputs

Đang mở
#189 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
cli, data

Hướng nghiên cứu

Bắt đầu bằng cách tìm lệnh rs_subset và đọc các issue liên quan #187 và #148 để nắm được hành vi batching mong đợi. Thay đổi được hoàn tất khi rs_subset chấp nhận nhiều đầu vào .tiles và tạo ra các đầu ra train, validation và evaluation mà không yêu cầu người dùng phải kết hợp các tệp trước.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Similar to #187

With the introduction of the batching feature extraction (#148), the inputs to rs_subset is likely going to be multiple .tiles files. My current workaround to combine all of these files prior to running rs_subset

import os
import csv
import argparse
from random import shuffle


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('dir', type=str)
    parser.add_argument('out', type=str)
    parser.add_argument('--ext', type=str, default='tiles')
    args = parser.parse_args()

    os.makedirs(args.out, exist_ok=True)
    
    all, train, validation, evaluation = [], [], [], []

    # combine tile csv files
    for file in os.listdir(args.dir):
        if file.endswith(args.ext):
            csv_file = os.path.join(args.dir, file)

            print(f"processing file: {csv_file}")

            with open(csv_file, newline='') as csvfile:
                spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
                for row in spamreader:
                    all.append(row)

    # shuffle
    shuffle(all)

    _80 = int(len(all) * 0.80)
    _10 = int(len(all) * 0.10)

    train = all[0:_80]
    validation = all[_80: _80 + _10]
    evaluation = all[_80 + _10:]
    
    # write new csv files
    for k, v in {"train.tiles": train, "validation.tiles": validation, "evaluation.tiles": evaluation}.items():
        with open(os.path.join(args.out, k), 'w', newline='') as f:
            wr = csv.writer(f, delimiter=' ', escapechar=' ', quoting=csv.QUOTE_NONE)
            for line in v:
                wr.writerow(line)
    
if __name__ == "__main__":
    main()
Ngôn ngữ chính
Python
Star
2.1k
Fork
384
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mapbox/robosat

Tất cả issue của mapbox/robosat

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.