id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,289,800 | dev.py | watermelon1024_EEW/dev.py | import asyncio
import logging
import os
import random
import time
from aiohttp import web
DEV_SERVER_HOST = "127.0.0.1"
DEV_SERVER_PORT = 8000
loop = asyncio.new_event_loop()
app = web.Application()
routes = web.RouteTableDef()
from src import Client, Config, InterceptHandler, Logging, WebSocketConnectionConfig, ... | 3,647 | Python | .py | 99 | 30.505051 | 109 | 0.64718 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,801 | main.py | watermelon1024_EEW/main.py | import logging
import os
from dotenv import load_dotenv
load_dotenv(override=True)
def main():
from src import Client, Config, InterceptHandler, Logging, WebSocketConnectionConfig, WebSocketService
config = Config()
logger = Logging(
retention=config["log"]["retention"],
debug_mode=conf... | 1,127 | Python | .py | 32 | 29 | 106 | 0.670664 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,802 | line.py | watermelon1024_EEW/notification/line.py | import asyncio
import os
import aiohttp
from src import EEW, BaseNotificationClient, Config, Logger
LINE_API_NODE = "https://api.line.me/v2"
class LineNotification(BaseNotificationClient):
"""
Represents a linebot EEW notification client.
"""
alerts: dict[str, str] = {}
notification_channels: ... | 9,456 | Python | .py | 206 | 27.126214 | 125 | 0.438571 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,803 | message.py | watermelon1024_EEW/notification/discord/message.py | import asyncio
import math
from datetime import datetime
from typing import TYPE_CHECKING, Optional, TypedDict
import discord
from src import EEW
if TYPE_CHECKING:
from .bot import DiscordNotification
class NotificationChannel(TypedDict):
channel: discord.TextChannel
mention: Optional[str]
class _Sin... | 9,158 | Python | .py | 216 | 31.282407 | 132 | 0.586091 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,804 | bot.py | watermelon1024_EEW/notification/discord/bot.py | from datetime import datetime
import discord
from discord.ext import tasks
from src import EEW, BaseNotificationClient, Config, Logger
from .message import EEWMessages, NotificationChannel
def void(*args, **kwargs):
pass
class DiscordNotification(BaseNotificationClient, discord.Bot):
"""
Represents a... | 4,524 | Python | .py | 109 | 31.330275 | 106 | 0.584149 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,805 | register.py | watermelon1024_EEW/notification/discord/register.py | import os
from src import Config, Logger
NAMESPACE = "discord-bot"
def register(config: Config, logger: Logger) -> None:
"""
Register the discord notification client.
:param config: The configuration of discord bot.
:type config: Config
:param logger: The logger instance.
:type logger: Logg... | 552 | Python | .py | 16 | 29.8125 | 58 | 0.720227 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,806 | linenotify.py | watermelon1024_EEW/notification/linenotify/linenotify.py | import asyncio
from datetime import datetime
from typing import Optional
import aiohttp
from src import EEW, BaseNotificationClient, Config, Logger
LINE_NOTIFY_API = "https://notify-api.line.me/api/notify"
class LineNotifyClient(BaseNotificationClient):
"""
Represents a [custom] EEW notificati... | 7,352 | Python | .py | 156 | 32.730769 | 112 | 0.576135 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,807 | register.py | watermelon1024_EEW/notification/linenotify/register.py | import os
from src import Config, Logger
NAMESPACE = "line-notify"
def register(config: Config, logger: Logger) -> None:
"""
Register the linenotify notification client.
Note: DO NOT run or start the client in this function, just register it.
If you want to run it in the event loop, do it in :metho... | 783 | Python | .py | 19 | 36.210526 | 87 | 0.727513 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,808 | config.py | watermelon1024_EEW/src/config.py | from typing import Any, Union
import tomli
class Config:
"""
The a configuration class.
"""
_path: str = "config.toml"
with open(_path, "rb") as f:
_config: dict = tomli.load(f)
@classmethod
def _load_config(cls) -> dict:
"""
Load the configuration file.
... | 1,521 | Python | .py | 48 | 23.8125 | 69 | 0.577793 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,809 | logging.py | watermelon1024_EEW/src/logging.py | import inspect
import logging
import sys
from datetime import timedelta
from typing import Union
from loguru._logger import Core, Logger, _defaults
from .utils import MISSING
class Logging:
"""
Represents a logger class.
"""
def __init__(self, retention: timedelta, debug_mode: bool = False, format:... | 2,275 | Python | .py | 70 | 23.157143 | 104 | 0.564523 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,810 | utils.py | watermelon1024_EEW/src/utils.py | from typing import Any
class Missing:
"""
Represents a status of missing.
"""
def __eq__(self, other) -> bool:
return False
def __bool__(self) -> bool:
return False
def __repr__(self) -> str:
return "..."
def __int__(self) -> int:
return 0
def __ite... | 382 | Python | .py | 16 | 17.8125 | 36 | 0.532213 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,811 | __init__.py | watermelon1024_EEW/src/__init__.py | """
ExpTech API Client
~~~~~~~~~~~~~~~~~~~
A simple wrapper to connect to ExpTech EEW API
"""
from .client.client import Client
from .client.http import HTTPClient
from .client.websocket import (
AuthorizationFailed,
ExpTechWebSocket,
WebSocketConnectionConfig,
WebSocketEvent,
WebSocketReconnect,
... | 998 | Python | .py | 40 | 21.8 | 57 | 0.770921 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,812 | base.py | watermelon1024_EEW/src/notification/base.py | from abc import ABC
from ..earthquake.eew import EEW
class BaseNotificationClient(ABC):
"""
An ABC for notification client.
"""
async def send_eew(self, eew: EEW):
"""Send EEW notification"""
pass
async def update_eew(self, eew: EEW):
"""Update EEW notification"""
... | 421 | Python | .py | 15 | 21.866667 | 52 | 0.63 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,813 | register.py | watermelon1024_EEW/src/notification/template/register.py | """
Register the [custom notification client].
This module registers the [custom notification client] with the provided configuration and logger.
The `register` function is the entry point for registering the client. It creates an instance of the `CustomNotificationClient` and returns it.
See also: https://github.com... | 1,087 | Python | .py | 22 | 45.363636 | 143 | 0.765774 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,814 | main.py | watermelon1024_EEW/src/notification/template/main.py | """
The template for a custom notification client.
Note: This template is out of date, please wait for the next update.
See also: https://github.com/watermelon1024/EEW/blob/main/docs/zh-TW/dev/notification.md#開發客戶端功能
"""
from src import EEW, BaseNotificationClient, Config, Logger
class CustomNotificationClient(Base... | 1,873 | Python | .py | 54 | 26.703704 | 111 | 0.610056 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,815 | client.py | watermelon1024_EEW/src/client/client.py | import asyncio
import importlib
import os
import re
from collections import defaultdict
from typing import Any, Optional
import aiohttp
from cachetools import TTLCache
from ..config import Config
from ..earthquake.eew import EEW
from ..logging import Logger
from ..notification.base import BaseNotificationClient
from ... | 12,533 | Python | .py | 291 | 31.694158 | 121 | 0.555911 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,816 | websocket.py | watermelon1024_EEW/src/client/websocket.py | import asyncio
import json
from enum import Enum
from typing import TYPE_CHECKING, Any, Optional, Union
import aiohttp
from ..logging import Logger
if TYPE_CHECKING:
from .client import Client
class AuthorizationFailed(Exception):
"""Represents an authorization failure."""
class WebSocketReconnect(Except... | 9,646 | Python | .py | 247 | 29.712551 | 112 | 0.618557 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,817 | http.py | watermelon1024_EEW/src/client/http.py | import asyncio
import random
import time
from typing import TYPE_CHECKING
import aiohttp
from ..logging import Logger
from .websocket import ExpTechWebSocket
if TYPE_CHECKING:
from .client import Client
class HTTPClient:
"""A HTTP client for interacting with ExpTech API."""
def __init__(
self,... | 7,733 | Python | .py | 189 | 30.920635 | 112 | 0.567722 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,818 | location.py | watermelon1024_EEW/src/earthquake/location.py | import json
from typing import Union
import geopandas as gpd
from ..utils import MISSING
class Location:
"""
A base class represents a location with longitude and latitude.
"""
__slots__ = ("_longitude", "_latitude")
def __init__(self, longitude: float, latitude: float):
"""
In... | 6,138 | Python | .py | 170 | 28.8 | 97 | 0.607022 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,819 | eew.py | watermelon1024_EEW/src/earthquake/eew.py | import asyncio
from datetime import datetime
from ..utils import MISSING
from .location import REGIONS_GROUP_BY_CITY, EarthquakeLocation, RegionLocation
from .map import Map
from .model import (
Intensity,
RegionExpectedIntensity,
WaveModel,
calculate_expected_intensity_and_travel_time,
get_wave_mo... | 9,350 | Python | .py | 304 | 22.236842 | 92 | 0.575425 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,820 | map.py | watermelon1024_EEW/src/earthquake/map.py | import io
from typing import TYPE_CHECKING
import matplotlib.pyplot as plt
if TYPE_CHECKING:
from earthquake.eew import EarthquakeData
import warnings
import matplotlib.image as mpimg
from matplotlib.offsetbox import AnnotationBbox, OffsetImage
from .location import COUNTRY_DATA, TAIWAN_CENTER, TOWN_DATA, TOWN... | 5,515 | Python | .py | 157 | 25.745223 | 110 | 0.553618 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,821 | model.py | watermelon1024_EEW/src/earthquake/model.py | """
Earthquake expected data calculator.
Reference: https://github.com/ExpTechTW/TREM-tauri/blob/main/src/scripts/helper/utils.ts
"""
import math
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, OrderedDict
import numpy as np
from obspy.taup import tau
from scipy.interpolate import interp1d... | 13,360 | Python | .py | 387 | 27.142119 | 139 | 0.61634 | watermelon1024/EEW | 8 | 4 | 0 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,822 | main.py | Aspectise_Bundle-Sniper/main.py | import aiohttp
import asyncio
import os
from src import cprint
import json
from functions import checker, display, checker2
import traceback
import time
with open("settings.json", "r") as file:settings = json.load(file)
class Sniper:
def __init__(self) -> None:
self.cookie = settings["Cookie"]
... | 3,311 | Python | .py | 63 | 40.047619 | 393 | 0.581403 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,823 | cprint.py | Aspectise_Bundle-Sniper/src/cprint.py | from rgbprint import Color
def info(text):
print(f"{Color(127, 127, 127)}INFO{Color(255, 255, 255)} | {text}")
def bought(text):
print(f"{Color(0, 255, 0)}BOUGHT{Color(255, 255, 255)} | {text}")
def error(text):
print(f"{Color(255, 0, 0)}ERROR{Color(255, 255, 255)} | {text}")
| 302 | Python | .py | 7 | 38.571429 | 72 | 0.622837 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,824 | csrf.py | Aspectise_Bundle-Sniper/src/csrf.py | import requests
from rgbprint import Color
def get(cookie) -> str:
response = requests.post("https://economy.roblox.com/", cookies = {".ROBLOSECURITY": cookie})
xcsrf_token = response.headers.get("x-csrf-token")
if not xcsrf_token:
print(f"{Color(255, 0, 0)}ERROR{Color(255, 255, 255)} | An e... | 453 | Python | .py | 9 | 44.777778 | 157 | 0.690745 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,825 | checker.py | Aspectise_Bundle-Sniper/functions/checker.py | import aiohttp
import asyncio
import traceback
from src import cprint
from functions import purchase
async def start(self):
async with aiohttp.ClientSession(cookies={".ROBLOSECURITY": self.cookie}) as session:
while True:
try:
if not self.bundles:
... | 3,181 | Python | .py | 56 | 31.160714 | 138 | 0.430735 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,826 | get_product.py | Aspectise_Bundle-Sniper/functions/get_product.py | async def get(session, item):
async with session.post("https://apis.roblox.com/marketplace-items/v1/items/details", json={"itemIds": [item]}) as response:
if response.status == 200:
data = await response.json()
data = data[0]
return data.get("collectibleProductId")
... | 358 | Python | .py | 8 | 34.5 | 129 | 0.60114 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,827 | display.py | Aspectise_Bundle-Sniper/functions/display.py | from rgbprint import Color, gradient_print
import datetime
import time
import asyncio
import os
async def info(self):
banner = '''
██▄ ▄███▄ ██ ▄▄▄▄▀ ▄ █
█ █ █▀ ▀ █ █ ▀▀▀ █ █ █
... | 1,942 | Python | .py | 30 | 40.533333 | 166 | 0.331621 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,828 | checker2.py | Aspectise_Bundle-Sniper/functions/checker2.py | import aiohttp
import asyncio
import traceback
from src import cprint
from functions import purchase, get_product
async def start(self):
async with aiohttp.ClientSession(cookies={".ROBLOSECURITY": self.cookie}) as session:
while True:
try:
if not self.bundles:
... | 2,651 | Python | .py | 48 | 27.770833 | 144 | 0.396002 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,829 | purchase.py | Aspectise_Bundle-Sniper/functions/purchase.py | from src import cprint, csrf
import uuid
import traceback
import asyncio
async def start(self, session, pdata):
try:
xcsrf = csrf.get(self.cookie)
session.headers.update({"X-Csrf-Token": xcsrf})
payload = {
"collectibleItemId": pdata["cid"],
"expectedCurrency": 1,... | 1,940 | Python | .py | 46 | 29.76087 | 153 | 0.546321 | Aspectise/Bundle-Sniper | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,830 | conf.py | liebharc_homr/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to docume... | 2,555 | Python | .py | 58 | 42.448276 | 83 | 0.704674 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,831 | test_bounding_boxes.py | liebharc_homr/tests/test_bounding_boxes.py | import unittest
import numpy as np
from homr.bounding_boxes import BoundingEllipse, RotatedBoundingBox
empty = np.array([])
class TestBoundingBoxes(unittest.TestCase):
unit_size = 3
def test_is_overlapping_rotated_box_extrapolated(self) -> None:
box1 = RotatedBoundingBox(((100, 200)... | 2,974 | Python | .py | 44 | 58.181818 | 95 | 0.660813 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,832 | test_poetry_config.py | liebharc_homr/tests/test_poetry_config.py | import pathlib
import re
from platform import python_version
CURRENT_MINOR_VERSION = ".".join(python_version().split(".")[:2])
TEST_FILE_PATH = pathlib.Path(__file__).parent.resolve()
PYPROJECT_TOML_PATH = list(TEST_FILE_PATH.glob("../pyproject.toml"))
MAKEFILE_PATH = list(TEST_FILE_PATH.glob("../Makefile"))
PRECOMMI... | 1,527 | Python | .py | 33 | 39.969697 | 92 | 0.642616 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,833 | test_split_merge_symbols_primus.py | liebharc_homr/tests/test_split_merge_symbols_primus.py | import unittest
from homr.transformer.split_merge_symbols import merge_symbols, split_symbols
def split_merge(merged: str) -> list[str]:
actuallift, actualpitch, actualrhythm, _actualnotes = split_symbols([merged.replace("+", "\t")])
merged_again = merge_symbols(actualrhythm, actualpitch, actuallift)
ret... | 878 | Python | .py | 17 | 43.705882 | 176 | 0.678363 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,834 | test_tr_omr_parser.py | liebharc_homr/tests/test_tr_omr_parser.py | import unittest
from homr import constants
from homr.results import (
ClefType,
DurationModifier,
ResultChord,
ResultClef,
ResultDuration,
ResultMeasure,
ResultNote,
ResultPitch,
ResultStaff,
ResultTimeSignature,
)
from homr.tr_omr_parser import TrOMRParser
d... | 15,772 | Python | .py | 363 | 20.429752 | 412 | 0.373723 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,835 | test_music_xml_parser.py | liebharc_homr/tests/test_music_xml_parser.py | import unittest
from training.music_xml import music_xml_string_to_semantic
class TestMusicXmlParser(unittest.TestCase):
def test_parse_xml_with_backup(self) -> None:
self.maxDiff = None
# lc4987672.musicxml, measure 22
example = """<?xml version="1.0" encoding="UTF-8"?>
<scor... | 10,582 | Python | .py | 376 | 16.797872 | 95 | 0.43625 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,836 | test_result_model.py | liebharc_homr/tests/test_result_model.py | import unittest
from homr.results import ClefType, ResultClef, ResultPitch, move_pitch_to_clef
class TestResultModel(unittest.TestCase):
def test_change_staff(self) -> None:
treble = ResultClef(ClefType.treble(), 1)
bass = ResultClef(ClefType.bass(), 1)
self.assertEqual(
... | 3,289 | Python | .py | 46 | 61.282609 | 97 | 0.625427 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,837 | test_split_merge_symbols.py | liebharc_homr/tests/test_split_merge_symbols.py | import unittest
from homr.transformer.split_merge_symbols import (
convert_alter_to_accidentals,
merge_symbols,
split_symbols,
)
predlift = [
[
"nonote",
"nonote",
"nonote",
"lift_N",
"nonote",
"lift_N",
"nonote",
"lift_N",
"nonot... | 10,888 | Python | .py | 288 | 27.475694 | 1,138 | 0.56488 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,838 | test_model.py | liebharc_homr/tests/test_model.py | import unittest
import numpy as np
from homr.bounding_boxes import RotatedBoundingBox
from homr.model import MultiStaff, Staff, StaffPoint
def make_staff(number: int) -> Staff:
y_points = [10 * i + 100 * float(number) for i in range(5)]
return Staff([StaffPoint(0.0, y_points, 0)])
def make_co... | 1,464 | Python | .py | 31 | 38.387097 | 97 | 0.644728 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,839 | test_mix_datasets.py | liebharc_homr/tests/test_mix_datasets.py | import unittest
from training.transformer.mix_datasets import mix_training_sets
class TestMixDataSets(unittest.TestCase):
def test_mix_training_sets(self):
dataset1 = ["a", "b", "c", "d", "e", "f", "g"]
dataset2 = ["1", "2", "3", "5", "6"]
dataset3 = ["x", "y", "z"]
actual = mix_... | 589 | Python | .py | 13 | 37.538462 | 87 | 0.606643 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,840 | symbol_error_rate.py | liebharc_homr/validation/symbol_error_rate.py | import argparse
import os
from pathlib import Path
import cv2
import editdistance # type: ignore
from homr import download_utils
from homr.simple_logging import eprint
from homr.transformer.configs import Config
from homr.transformer.staff2score import Staff2Score
from training.musescore_svg import get_position_from... | 7,060 | Python | .py | 141 | 38.808511 | 100 | 0.601653 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,841 | rate_validation_result.py | liebharc_homr/validation/rate_validation_result.py | # mypy: disable-error-code="no-any-return, no-any-unimported"
import argparse
import glob
import os
import xml.etree.ElementTree as ET
import editdistance # type: ignore
import musicxml.xmlelement.xmlelement as mxl # type: ignore
from musicxml.parser.parser import _parse_node # type: ignore
from homr.sim... | 10,211 | Python | .py | 235 | 34.744681 | 103 | 0.623631 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,842 | title_detection.py | liebharc_homr/homr/title_detection.py | import re
import easyocr # type: ignore
from homr.debug import Debug
from homr.model import Staff
reader = easyocr.Reader(["de", "en"], gpu=False, verbose=False)
def cleanup_text(text: str) -> str:
"""
Remove all special characters from the text. Merge multiple whitespaces into a single space.... | 1,075 | Python | .py | 24 | 39.125 | 97 | 0.651208 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,843 | staff_parsing.py | liebharc_homr/homr/staff_parsing.py | import cv2
import numpy as np
from homr import constants
from homr.debug import Debug
from homr.image_utils import crop_image_and_return_new_top
from homr.model import InputPredictions, MultiStaff, Note, NoteGroup, Staff
from homr.results import (
ResultChord,
ResultClef,
ResultMeasure,
Resu... | 17,986 | Python | .py | 386 | 37.466321 | 104 | 0.625057 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,844 | staff_dewarping.py | liebharc_homr/homr/staff_dewarping.py | import cv2
import numpy as np
import PIL.Image
from skimage import transform
from homr.debug import Debug
from homr.model import Staff
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
class StaffDewarping:
def __init__(self, tform: transform.PiecewiseAffineTransform | None):
... | 6,448 | Python | .py | 143 | 36.972028 | 108 | 0.62207 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,845 | circle_of_fifths.py | liebharc_homr/homr/circle_of_fifths.py | import abc
from abc import ABC
from homr.simple_logging import eprint
circle_of_fifth_notes_positive = ["F", "C", "G", "D", "A", "E", "B"]
circle_of_fifth_notes_negative = list(reversed(circle_of_fifth_notes_positive))
def get_circle_of_fifth_notes(circle_of_fifth: int) -> list[str]:
if circle_of_fift... | 4,000 | Python | .py | 106 | 27.90566 | 97 | 0.573514 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,846 | xml_generator.py | liebharc_homr/homr/xml_generator.py | import musicxml.xmlelement.xmlelement as mxl # type: ignore
from homr import constants
from homr.results import (
DurationModifier,
ResultChord,
ResultClef,
ResultMeasure,
ResultNote,
ResultStaff,
ResultTimeSignature,
)
class XmlGeneratorArguments:
def __init__(self, l... | 8,535 | Python | .py | 188 | 38.271277 | 122 | 0.688972 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,847 | staff_parsing_tromr.py | liebharc_homr/homr/staff_parsing_tromr.py | import re
from collections import Counter
import cv2
import numpy as np
from homr import constants
from homr.debug import AttentionDebug
from homr.model import Staff
from homr.results import ClefType, ResultStaff, ResultTimeSignature
from homr.simple_logging import eprint
from homr.tr_omr_parser import TrOMRParser
fr... | 5,206 | Python | .py | 114 | 38.929825 | 97 | 0.676808 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,848 | simple_logging.py | liebharc_homr/homr/simple_logging.py | import sys
from typing import Any
def eprint(*args: Any, **kwargs: Any) -> None:
"""
A logger with differnt log levels felt overkill for this project.
So we just have one logger that logs to stderr.
"""
print(*args, file=sys.stderr, **kwargs) # noqa: T201
| 289 | Python | .py | 8 | 31.125 | 70 | 0.66426 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,849 | constants.py | liebharc_homr/homr/constants.py | number_of_lines_on_a_staff = 5
max_number_of_ledger_lines = 4
def tolerance_for_staff_line_detection(unit_size: float) -> float:
return unit_size / 3
def max_line_gap_size(unit_size: float) -> float:
return 5 * unit_size
def is_short_line(unit_size: float) -> float:
return unit_size / 5... | 2,408 | Python | .py | 54 | 39.222222 | 81 | 0.712189 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,850 | bounding_boxes.py | liebharc_homr/homr/bounding_boxes.py | import math
from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import Any, TypeVar, cast
import cv2
import cv2.typing as cvt
import numpy as np
from scipy import ndimage # type: ignore
from homr import constants
from homr.image_utils import crop_image
from homr.simple_lo... | 21,990 | Python | .py | 510 | 32.937255 | 105 | 0.576854 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,851 | autocrop.py | liebharc_homr/homr/autocrop.py | import cv2
import numpy as np
from homr.type_definitions import NDArray
def autocrop(img: NDArray) -> NDArray:
"""
Find the largest contour on the image, which is expected to be the paper of sheet music
and extracts it from the image. If no contour is found, then the image is assumed to be
... | 1,920 | Python | .py | 44 | 36.863636 | 108 | 0.648547 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,852 | image_utils.py | liebharc_homr/homr/image_utils.py | import numpy as np
from homr.type_definitions import NDArray
def _limit_x(image: NDArray, x: float) -> int:
return max(0, min(image.shape[1] - 1, int(round(x))))
def _limit_y(image: NDArray, y: float) -> int:
return max(0, min(image.shape[0] - 1, int(round(y))))
def crop_image(image: NDArray... | 999 | Python | .py | 22 | 39.863636 | 87 | 0.636079 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,853 | bar_line_detection.py | liebharc_homr/homr/bar_line_detection.py | import cv2
import numpy as np
from homr import constants
from homr.bounding_boxes import RotatedBoundingBox
from homr.model import BarLine, Staff
from homr.type_definitions import NDArray
def prepare_bar_line_image(image: NDArray) -> NDArray:
kernel = np.ones((5, 3), np.uint8)
result = cv2.dilate(... | 1,767 | Python | .py | 47 | 28.191489 | 99 | 0.61 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,854 | rest_detection.py | liebharc_homr/homr/rest_detection.py | import numpy as np
from homr import constants
from homr.bounding_boxes import RotatedBoundingBox
from homr.model import Rest, Staff
def add_rests_to_staffs(staffs: list[Staff], rests: list[RotatedBoundingBox]) -> list[Rest]:
result = []
central_staff_line_indexes = [1, 2]
for staff in staffs:
for... | 1,465 | Python | .py | 34 | 31.852941 | 96 | 0.596627 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,855 | results.py | liebharc_homr/homr/results.py | from enum import Enum
import numpy as np
from homr import constants
from homr.simple_logging import eprint
class ResultSymbol:
def __init__(self) -> None:
pass
class ClefType:
@staticmethod
def treble() -> "ClefType":
return ClefType(sign="G", line=2)
@staticmeth... | 13,970 | Python | .py | 327 | 33.021407 | 99 | 0.589635 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,856 | noise_filtering.py | liebharc_homr/homr/noise_filtering.py | import cv2
import numpy as np
from homr import constants
from homr.debug import Debug
from homr.model import InputPredictions
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
def estimate_noise(gray: NDArray) -> int:
H, W = gray.shape
M = np.array([[1, -2, 1], [-2,... | 4,418 | Python | .py | 95 | 37.242105 | 99 | 0.609642 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,857 | tr_omr_parser.py | liebharc_homr/homr/tr_omr_parser.py | from homr import constants
from homr.results import (
ClefType,
DurationModifier,
ResultChord,
ResultClef,
ResultDuration,
ResultMeasure,
ResultNote,
ResultPitch,
ResultStaff,
ResultTimeSignature,
get_min_duration,
)
from homr.simple_logging import eprint
c... | 7,247 | Python | .py | 176 | 29.017045 | 101 | 0.550562 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,858 | type_definitions.py | liebharc_homr/homr/type_definitions.py | from typing import Any
import numpy as np
Model = Any
NDArray = np.ndarray[Any, Any]
| 88 | Python | .py | 4 | 20.25 | 30 | 0.790123 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,859 | debug.py | liebharc_homr/homr/debug.py | import glob
import os
from collections.abc import Sequence
from itertools import chain
import cv2
import numpy as np
from homr.bounding_boxes import DebugDrawable
from homr.type_definitions import NDArray
class AttentionDebug:
def __init__(self, filename: str, image: NDArray, parent: "Debug") -> No... | 5,937 | Python | .py | 134 | 34.261194 | 108 | 0.609943 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,860 | accidental_rules.py | liebharc_homr/homr/accidental_rules.py | from homr.circle_of_fifths import get_circle_of_fifth_notes
from homr.results import ResultChord, ResultClef, ResultNote, ResultPitch, ResultStaff
def _keep_accidentals_until_cancelled(staff: ResultStaff) -> None:
"""
Implements the rule that accidentals are kept until
cancelled by a natural sign o... | 2,739 | Python | .py | 63 | 34.650794 | 92 | 0.639412 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,861 | download_utils.py | liebharc_homr/homr/download_utils.py | import os
import tarfile
import zipfile
import requests
from homr.simple_logging import eprint
def download_file(url: str, filename: str) -> None:
response = requests.get(url, stream=True, timeout=5)
total = int(response.headers.get("content-length", 0))
totalMb = round(total / 1024 / 1024)
last_per... | 3,126 | Python | .py | 73 | 29.178082 | 94 | 0.535879 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,862 | accidental_detection.py | liebharc_homr/homr/accidental_detection.py | from homr import constants
from homr.bounding_boxes import RotatedBoundingBox
from homr.model import Accidental, Staff
def add_accidentals_to_staffs(
staffs: list[Staff], accidentals: list[RotatedBoundingBox]
) -> list[Accidental]:
result = []
for staff in staffs:
for accidental in accidentals:
... | 1,364 | Python | .py | 33 | 30 | 79 | 0.606335 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,863 | model.py | liebharc_homr/homr/model.py | from abc import abstractmethod
from collections.abc import Callable
from enum import Enum
import cv2
import numpy as np
from typing_extensions import Self
from homr import constants
from homr.bounding_boxes import (
AngledBoundingBox,
BoundingBox,
BoundingEllipse,
DebugDrawable,
Rota... | 17,578 | Python | .py | 419 | 31.842482 | 98 | 0.578817 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,864 | color_adjust.py | liebharc_homr/homr/color_adjust.py | import math
import cv2
import numpy as np
import scipy # type: ignore
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
def get_dominant_color(
gray_scale: NDArray, color_range: range, default: int | None = None
) -> int | None:
if gray_scale.dtype != np.uint8:
... | 3,544 | Python | .py | 75 | 40.373333 | 101 | 0.67016 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,865 | main.py | liebharc_homr/homr/main.py | import argparse
import glob
import os
import sys
import cv2
import numpy as np
from homr import color_adjust, download_utils
from homr.accidental_detection import add_accidentals_to_staffs
from homr.accidental_rules import maintain_accidentals
from homr.autocrop import autocrop
from homr.bar_line_detection import (
... | 14,403 | Python | .py | 316 | 38.075949 | 99 | 0.67277 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,866 | note_detection.py | liebharc_homr/homr/note_detection.py | import cv2.typing as cvt
import numpy as np
from homr import constants
from homr.bounding_boxes import BoundingEllipse, DebugDrawable, RotatedBoundingBox
from homr.model import Note, NoteGroup, Staff, StemDirection, SymbolOnStaff
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
... | 8,635 | Python | .py | 204 | 31.70098 | 101 | 0.583642 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,867 | staff_detection.py | liebharc_homr/homr/staff_detection.py | from collections.abc import Generator, Iterable
import cv2
import cv2.typing as cvt
import numpy as np
from scipy import signal # type: ignore
from homr import constants
from homr.bounding_boxes import (
DebugDrawable,
RotatedBoundingBox,
create_rotated_bounding_box,
)
from homr.debug import... | 28,799 | Python | .py | 611 | 37.360065 | 101 | 0.619333 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,868 | brace_dot_detection.py | liebharc_homr/homr/brace_dot_detection.py | import cv2
import numpy as np
from homr import constants
from homr.bounding_boxes import RotatedBoundingBox
from homr.debug import Debug
from homr.model import MultiStaff, Staff
from homr.type_definitions import NDArray
def prepare_brace_dot_image(
symbols: NDArray, staff: NDArray, all_other: NDArray,... | 7,175 | Python | .py | 161 | 35.956522 | 100 | 0.652885 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,869 | resize.py | liebharc_homr/homr/resize.py | import numpy as np
from PIL import Image
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
def calc_target_image_size(image: Image.Image) -> tuple[int, int]:
# Estimate target size with number of pixels.
# Best number would be 3M~4.35M pixels.
w, h = image.size
pixels =... | 1,130 | Python | .py | 29 | 34.034483 | 99 | 0.643836 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,870 | decoder.py | liebharc_homr/homr/transformer/decoder.py | from math import ceil
from typing import Any
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from transformers import PreTrainedTokenizerFast # type: ignore
from x_transformers.x_transformers import ( # type: ignore
AbsolutePositionalEmbedding,
AttentionLayers,
Decode... | 14,741 | Python | .py | 348 | 32.488506 | 100 | 0.595534 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,871 | configs.py | liebharc_homr/homr/transformer/configs.py | import json
import os
from typing import Any
workspace = os.path.join(os.path.dirname(__file__))
class FilePaths:
def __init__(self) -> None:
self.checkpoint = os.path.join(
workspace, "pytorch_model_101-ba12ebef4606948816a06f4a011248d07a6f06da.pth"
)
self.rhythmtokenizer = os... | 4,701 | Python | .py | 111 | 32.990991 | 93 | 0.606471 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,872 | split_merge_symbols.py | liebharc_homr/homr/transformer/split_merge_symbols.py | import re
from homr import constants
from homr.circle_of_fifths import (
KeyTransformation,
NoKeyTransformation,
key_signature_to_circle_of_fifth,
)
from homr.simple_logging import eprint
from homr.transformer.configs import default_config
class SymbolMerger:
def __init__(self, keep_all_symbols_in_ch... | 14,180 | Python | .py | 332 | 32.503012 | 100 | 0.579535 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,873 | encoder.py | liebharc_homr/homr/transformer/encoder.py | from typing import Any
from timm.models.layers import StdConv2dSame # type: ignore
from timm.models.resnetv2 import ResNetV2 # type: ignore
from timm.models.vision_transformer import VisionTransformer # type: ignore
from timm.models.vision_transformer_hybrid import HybridEmbed # type: ignore
from homr.tran... | 1,593 | Python | .py | 40 | 31.125 | 92 | 0.635951 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,874 | tromr_arch.py | liebharc_homr/homr/transformer/tromr_arch.py | from typing import Any
import torch
from torch import nn
from homr.debug import AttentionDebug
from homr.transformer.configs import Config
from homr.transformer.decoder import get_decoder
from homr.transformer.encoder import get_encoder
class TrOMR(nn.Module):
def __init__(self, config: Config):
super()... | 1,677 | Python | .py | 47 | 27.787234 | 100 | 0.623305 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,875 | staff2score.py | liebharc_homr/homr/transformer/staff2score.py | import os
import albumentations as alb # type: ignore
import cv2
import safetensors
import torch
from albumentations.pytorch import ToTensorV2 # type: ignore
from homr.debug import AttentionDebug
from homr.transformer.configs import Config
from homr.transformer.tromr_arch import TrOMR
from homr.type_definitions imp... | 3,569 | Python | .py | 84 | 34.702381 | 108 | 0.638145 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,876 | inference.py | liebharc_homr/homr/segmentation/inference.py | import json
import os
from typing import Any
import numpy as np
import tensorflow as tf
from PIL import Image
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
class InferenceModel:
def __init__(self, model_path: str) -> None:
model, metadata = _load_model(mo... | 3,939 | Python | .py | 90 | 33.166667 | 94 | 0.554391 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,877 | config.py | liebharc_homr/homr/segmentation/config.py | import os
script_location = os.path.dirname(os.path.realpath(__file__))
unet_path = os.path.join(script_location, "unet_91-df68794a7f3420b749780deb1eba938911b3d0d3")
segnet_path = os.path.join(script_location, "segnet_89-f8076e6ee78bf998e291a56647477de80aa19f64")
unet_version = os.path.basename(unet_path).split("_")[... | 444 | Python | .py | 7 | 62 | 97 | 0.778802 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,878 | segmentation.py | liebharc_homr/homr/segmentation/segmentation.py | import hashlib
import lzma
import os
from pathlib import Path
import cv2
import numpy as np
from homr.segmentation import config
from homr.segmentation.inference import inference
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
def generate_pred(image: NDArray) -> tuple... | 4,276 | Python | .py | 103 | 31.941748 | 99 | 0.603619 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,879 | download.py | liebharc_homr/training/download.py | import os
from pathlib import Path
from homr.download_utils import download_file, untar_file, unzip_file
from homr.simple_logging import eprint
script_location = os.path.dirname(os.path.realpath(__file__))
git_root = Path(script_location).parent.absolute()
dataset_root = os.path.join(git_root, "datasets")
def downl... | 1,519 | Python | .py | 33 | 41.575758 | 99 | 0.738514 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,880 | music_xml.py | liebharc_homr/training/music_xml.py | import xml.etree.ElementTree as ET
import musicxml.xmlelement.xmlelement as mxl # type: ignore
from musicxml.parser.parser import _parse_node # type: ignore
from homr import constants
from homr.circle_of_fifths import KeyTransformation, circle_of_fifth_to_key_signature
from homr.simple_logging import eprint
class... | 14,131 | Python | .py | 312 | 36.592949 | 99 | 0.630585 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,881 | train.py | liebharc_homr/training/train.py | import argparse
import os
import sys
import tensorflow as tf
from homr.simple_logging import eprint
from training import download
from training.run_id import get_run_id
from training.segmentation import train
from training.segmentation.model_utils import save_model
from training.transformer.train import train_transfo... | 2,409 | Python | .py | 61 | 35.393443 | 89 | 0.711843 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,882 | musescore_svg.py | liebharc_homr/training/musescore_svg.py | import glob
import math
from xml.dom import minidom
from homr import constants
from homr.simple_logging import eprint
class SvgValidationError(Exception):
pass
class SvgRectangle:
def __init__(self, x: int, y: int, width: int, height: int):
self.x = x
self.y = y
self.width = width
... | 5,499 | Python | .py | 127 | 36.023622 | 100 | 0.626896 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,883 | show_examples_from_index.py | liebharc_homr/training/show_examples_from_index.py | # ruff: noqa: T201
import os
import sys
from typing import Any
import cv2
import numpy as np
from termcolor import colored
index_file_name = sys.argv[1]
number_of_samples_per_iteration = int(sys.argv[2])
index_file = open(index_file_name)
index_lines = index_file.readlines()
index_file.close()
np.random.shuffle(in... | 1,845 | Python | .py | 57 | 25.701754 | 77 | 0.586382 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,884 | convert_grandstaff.py | liebharc_homr/training/convert_grandstaff.py | import multiprocessing
import os
import platform
import stat
import sys
from pathlib import Path
import cv2
import numpy as np
import PIL
import PIL.Image
from scipy.signal import find_peaks # type: ignore
from torchvision import transforms as tr # type: ignore
from torchvision.transforms import Compose # type: ign... | 11,060 | Python | .py | 248 | 37.221774 | 99 | 0.648797 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,885 | run_id.py | liebharc_homr/training/run_id.py | import os
def get_run_id() -> str:
git_count = os.popen("git rev-list --count HEAD").read().strip() # noqa: S605, S607
git_head = os.popen("git rev-parse HEAD").read().strip() # noqa: S605, S607
return f"{git_count}-{git_head}"
| 244 | Python | .py | 5 | 45 | 88 | 0.628692 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,886 | convert_primus.py | liebharc_homr/training/convert_primus.py | import multiprocessing
import os
import random
from collections.abc import Generator
from pathlib import Path
import cv2
from homr.download_utils import download_file, untar_file
from homr.simple_logging import eprint
from homr.staff_parsing import add_image_into_tr_omr_canvas
from training.convert_grandstaff import ... | 3,815 | Python | .py | 90 | 36.411111 | 94 | 0.675304 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,887 | convert_lieder.py | liebharc_homr/training/convert_lieder.py | import json
import multiprocessing
import os
import platform
import random
import shutil
import stat
import sys
from io import BytesIO
from pathlib import Path
import cairosvg # type: ignore
import cv2
import numpy as np
from PIL import Image
from homr.download_utils import download_file, unzip_file
from homr.simple... | 9,664 | Python | .py | 214 | 36.060748 | 100 | 0.6176 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,888 | mix_datasets.py | liebharc_homr/training/transformer/mix_datasets.py | from typing import Any
import numpy as np
def _calc_number_of_files_to_take(
data_sources: list[dict[str, Any]], number_of_files: int
) -> list[int]:
files_to_take = [0 for _ in data_sources]
while number_of_files > 0:
total_weight = sum([s["weight"] for s in data_sources])
number_of_file... | 2,246 | Python | .py | 52 | 35.980769 | 98 | 0.632158 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,889 | train.py | liebharc_homr/training/transformer/train.py | import os
import shutil
import sys
import safetensors
import torch
import torch._dynamo
from transformers import Trainer, TrainingArguments # type: ignore
from homr.simple_logging import eprint
from homr.transformer.configs import Config
from homr.transformer.tromr_arch import TrOMR
from training.convert_grandstaff ... | 6,165 | Python | .py | 147 | 34.891156 | 108 | 0.666834 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,890 | data_loader.py | liebharc_homr/training/transformer/data_loader.py | import os
import random
from typing import Any
import numpy as np
from homr.simple_logging import eprint
from homr.transformer.configs import Config
from homr.transformer.decoder import tokenize
from homr.transformer.split_merge_symbols import split_semantic_file
from homr.transformer.staff2score import readimg
from ... | 7,711 | Python | .py | 193 | 30.569948 | 100 | 0.591747 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,891 | constant_min.py | liebharc_homr/training/segmentation/constant_min.py | from training.segmentation.dense_dataset_definitions import (
DENSE_DATASET_DEFINITIONS as DEF,
)
CLASS_CHANNEL_LIST = [
DEF.STEM + DEF.ALL_RESTS_EXCEPT_LARGE + DEF.BARLINE_BETWEEN + DEF.BARLINE_END,
DEF.NOTEHEADS_ALL,
DEF.ALL_CLEFS + DEF.ALL_KEYS + DEF.ALL_ACCIDENTALS,
]
CLASS_CHANNEL_MAP = {
col... | 489 | Python | .py | 12 | 37.833333 | 87 | 0.734177 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,892 | model_utils.py | liebharc_homr/training/segmentation/model_utils.py | import json
import os
from typing import Any
from training.segmentation.types import Model
def save_model(model: Model, metadata: dict[str, Any], model_path: str) -> None:
"""Save model and metadata"""
model.export(model_path) # Creates a folder with the model, we now add metadata
write_text_to_file(
... | 925 | Python | .py | 21 | 39.428571 | 84 | 0.690848 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,893 | build_label.py | liebharc_homr/training/segmentation/build_label.py | import os
import random
import sys
import cv2
import numpy as np
from PIL import Image
from homr.simple_logging import eprint
from homr.type_definitions import NDArray
from training.segmentation.constant_min import CHANNEL_NUM, CLASS_CHANNEL_MAP
from training.segmentation.dense_dataset_definitions import (
DENSE_... | 5,373 | Python | .py | 144 | 28.208333 | 93 | 0.552055 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,894 | unet.py | liebharc_homr/training/segmentation/unet.py | from typing import cast
import tensorflow as tf
import tensorflow.keras.layers as L
from tensorflow.keras import Input
from tensorflow.keras.layers import (
Activation,
Add,
Concatenate,
Conv2D,
Conv2DTranspose,
Dropout,
LayerNormalization,
)
from training.segmentation.types import Model
... | 10,695 | Python | .py | 236 | 39.525424 | 99 | 0.613235 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,895 | train.py | liebharc_homr/training/segmentation/train.py | import os
import random
from collections.abc import Callable, Generator, Iterator
from multiprocessing import Process, Queue
from typing import Any, cast
import augly.image as imaugs # type: ignore
import cv2
import numpy as np
import tensorflow as tf
from PIL import Image, ImageColor, ImageEnhance
from homr.simple_... | 21,226 | Python | .py | 477 | 33.926625 | 143 | 0.586347 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,896 | dense_dataset_definitions.py | liebharc_homr/training/segmentation/dense_dataset_definitions.py | class Symbols:
BACKGROUND = [0]
LEDGERLINE = [2]
BARLINE_BETWEEN = [3]
BARLINE_END = [4]
ALL_BARLINES = BARLINE_BETWEEN + BARLINE_END
REPEAT_DOTS = [7]
G_GLEF = [10]
C_CLEF = [11, 12]
F_CLEF = [13]
ALL_CLEFS = G_GLEF + C_CLEF + F_CLEF
NUMBERS = [19, 20]
TIME_SIGNATURE_SUB... | 3,238 | Python | .py | 120 | 20.733333 | 92 | 0.569641 | liebharc/homr | 8 | 3 | 2 | AGPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,897 | People-sDailyEpubCreator.py | ARRray0-o_People-sDailyEpubCreator/People-sDailyEpubCreator.py | from lxml import html
from datetime import datetime, timedelta
from ebooklib import epub
import requests
import os
import re
from urllib.parse import quote
import webbrowser
def fetch_articles(custom_date=None):
articles_data = []
today = custom_date if custom_date else datetime.now().strftime('%Y-%... | 9,793 | Python | .py | 182 | 36.456044 | 159 | 0.569245 | ARRray0-o/People-sDailyEpubCreator | 8 | 5 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,898 | config.py | lauratheq_lazywp/src/config.py | #!/usr/bin/python3
'''
Sets the log level. Possible levels:
NOTSET
DEBUG
INFO
WARN
ERROR
CRITICAL
'''
LOG_LEVEL = 'DEBUG'
| 155 | Python | .py | 11 | 10.636364 | 36 | 0.617021 | lauratheq/lazywp | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |
2,289,899 | logging.py | lauratheq_lazywp/src/logging.py | #!/usr/bin/python3
# TODO comments
import logging
class Logging:
logger = None
log_level = 0
log_levels = {
"NOTSET": 0,
"DEBUG": 10,
"INFO": 20,
"WARN": 30,
"ERROR": 40,
"CRITICAL": 50
}
def __init__(self, **kwargs):
'''
Initializes... | 1,295 | Python | .py | 43 | 21.209302 | 66 | 0.554464 | lauratheq/lazywp | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:43 PM (Europe/Amsterdam) |