File size: 1,998 Bytes
fa98f1c 958473e fa98f1c 958473e 2022859 fa98f1c 958473e 2022859 958473e fa98f1c c9d4907 fa98f1c c9d4907 958473e c9d4907 958473e fa98f1c c9d4907 958473e c9d4907 958473e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import typer
import torch
import subprocess
from pathlib import Path
from expert import UpstreamExpert
SUBMISSION_FILES = ["README.md", "expert.py", "model.pt"]
SAMPLE_RATE = 16000
SECONDS = [2, 1.8, 3.7]
app = typer.Typer()
@app.command()
def validate():
# Check that all the expected files exist
for file in SUBMISSION_FILES:
if not Path(file).is_file():
raise ValueError(f"File {file} not found! Please include {file} in your submission")
try:
upstream = UpstreamExpert(ckpt="model.pt")
wavs = [torch.rand(round(SAMPLE_RATE * sec)) for sec in SECONDS]
results = upstream(wavs)
assert isinstance(results, dict)
tasks = ["PR", "SID", "ER", "ASR", "ASV", "SD", "QbE", "ST", "SS", "SE", "secret"]
for task in tasks:
hidden_states = results.get(task, "hidden_states")
assert isinstance(hidden_states, list)
for state in hidden_states:
assert isinstance(state, torch.Tensor)
assert state.dim() == 3, "(batch_size, max_sequence_length_of_batch, hidden_size)"
assert state.shape == hidden_states[0].shape
for task in tasks:
downsample_rate = upstream.get_downsample_rates(task)
assert isinstance(downsample_rate, int)
except:
print("Please check the Upstream Specification on https://superbbenchmark.org/challenge")
raise
typer.echo("All submission files validated!")
typer.echo("Now you can upload these files to huggingface's Hub.")
@app.command()
def upload(submission_name: str):
subprocess.call("git pull origin main".split())
subprocess.call(["git", "add", "."])
subprocess.call(["git", "commit", "-m", f"Upload Upstream: {submission_name} "])
subprocess.call(["git", "push"])
typer.echo("Upload successful!")
typer.echo("Now, please go to https://superbbenchmark.org/submit to make a submission.")
if __name__ == "__main__":
app()
|