Skip to content

Instantly share code, notes, and snippets.

View ValV's full-sized avatar
🚷

Vladimir Valeyev ValV

🚷
View GitHub Profile
import json
from os import listdir as ls, makedirs, path as osp
from tempfile import TemporaryDirectory
from zipfile import ZipFile
import pandas as pd
def merge_coco_archives(path_source, path_target=None, suffix='default'):
@ValV
ValV / create_cvat_yolo_zip.py
Last active September 16, 2023 00:40
CVAT zip annotation creator
from os import listdir as ls, makedirs, path as osp
from shutil import copy2 as cp, make_archive
from tempfile import TemporaryDirectory
def create_cvat_yolo_zip(path_source, path_classes=None, path_target=None, copy_images=False):
assert osp.isdir(path_source), f"'path_source' must be a directory with [flat] YOLO annotations!"
path_classes = path_classes or osp.join(path_source, 'classes.txt')
assert osp.isfile(path_classes), f"either 'path_classes' or 'classes.txt' in 'source_path' must exist!"
path_target = path_target or '.'
@ValV
ValV / rl_week04_cell_evaluate.py
Created March 13, 2023 11:05
Yandex Practical RL - Record sessions with OpenCV
# Evaluate function
def evaluate(env, agent, n_games=1, greedy=False, t_max=10000, frames=None):
""" Plays n_games full games. If greedy, picks actions as argmax(qvalues). Returns mean reward. """
rewards = []
render = isinstance(frames, list)
for _ in range(n_games):
s, _ = env.reset()
reward = 0
for _ in range(t_max):
!git clone ololo
%pip install ./ololo
@ValV
ValV / Serializing.kt
Last active November 19, 2018 08:59
test-serialization
package com.github.valv.test
import kotlinx.serialization.*
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JSON
object Serializing {
@Serializable
data class SomeData(val name: String, val value: Any)