seed.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:EvalAI 作者: Cloud-CV 项目源码 文件源码
def create_challenge_phases(challenge, number_of_phases=1):
    """
    Creates challenge phases for the created challenges and returns it.
    """
    challenge_phases = []
    for i in range(number_of_phases):
        name = "{} Phase".format(fake.first_name())
        with open(os.path.join(settings.BASE_DIR, 'examples', 'example1', 'test_annotation.txt'), 'rb') as data_file:
            data = data_file.read()
        data = data or None
        challenge_phase = ChallengePhase.objects.create(
            name=name,
            description=fake.paragraph(),
            leaderboard_public=True,
            is_public=True,
            start_date=challenge.start_date,
            end_date=challenge.end_date,
            challenge=challenge,
            test_annotation=SimpleUploadedFile(fake.file_name(extension="txt"), data, content_type="text/plain"),
            codename="{}{}".format("phase", i + 1),
        )
        challenge_phases.append(challenge_phase)
        print("Challenge Phase created with name: {} challenge: {}".format(name, challenge.title))
    return challenge_phases
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号