Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Python version dependencies from Python>=3.10 to Python>=3.8. #14

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# derived from Microsoft Python dev container (https://github.com/microsoft/vscode-dev-containers/tree/main/containers/python-3)
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10
FROM mcr.microsoft.com/vscode/devcontainers/python:3.8

# Colab versions @2023-05-06
# Python: 3.10.11
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ jobs:
run: |
pytest

# test-py308:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Set up Python 3.8
# uses: actions/setup-python@v3
# with:
# python-version: "3.8"
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install pytest
# pip install torch==2.0.0+cpu torchaudio==2.0.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
# - name: Run tests
# run: |
# pytest
test-py308:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install torch==2.0.0+cpu torchaudio==2.0.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Run tests
run: |
pytest
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
repository = "https://github.com/tarepan/SpeechMOS"

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.8"
## Poetry is not good for version control of PyTorch (it has many many variants for a version, so poetry become confused)
## torch = "2.0.0"
## torchaudio = "2.0.1"
Expand Down
9 changes: 5 additions & 4 deletions speechmos/utmos22/fairseq_alt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""W2V2 model optimized to UTMOS22 strong learner inference. Origin cloned from FairSeq under MIT license (Copyright Facebook, Inc. and its affiliates., https://github.com/facebookresearch/fairseq/blob/main/LICENSE)."""

import math
from typing import List, Optional, Tuple

import torch
from torch import nn, Tensor
Expand Down Expand Up @@ -43,7 +44,7 @@ def forward(self, source: Tensor):
class ConvFeatureExtractionModel(nn.Module):
"""Feature Encoder."""

def __init__(self, conv_layers: list[tuple[int, int, int]]):
def __init__(self, conv_layers: List[Tuple[int, int, int]]):
super().__init__() # pyright: ignore [reportUnknownMemberType]

def block(n_in: int, n_out: int, k: int, stride: int, is_group_norm: bool = False):
Expand Down Expand Up @@ -137,7 +138,7 @@ def forward(self, x: Tensor) -> Tensor:
return x[:, :, : -1]


def pad_to_multiple(x: Tensor | None, multiple: int, dim: int = -1, value: float = 0) -> tuple[Tensor | None, int]:
def pad_to_multiple(x: Optional[Tensor], multiple: int, dim: int = -1, value: float = 0) -> Tuple[Optional[Tensor], int]:
"""Tail padding."""
# Inspired from https://github.com/lucidrains/local-attention/blob/master/local_attention/local_attention.py#L41
if x is None:
Expand Down Expand Up @@ -182,7 +183,7 @@ def __init__(
self.self_attn_layer_norm = nn.LayerNorm(feat)
self.final_layer_norm = nn.LayerNorm(feat)

def forward(self, x: Tensor, self_attn_padding_mask: Tensor | None):
def forward(self, x: Tensor, self_attn_padding_mask: Optional[Tensor]):
# Res[Attn-Do]-LN
residual = x
x = self.self_attn(x, x, x, self_attn_padding_mask)
Expand Down Expand Up @@ -214,7 +215,7 @@ def __init__(self, embed_dim: int, num_heads: int, dropout: float):
self.v_proj = nn.Linear(embed_dim, embed_dim, bias=True)
self.out_proj = nn.Linear(embed_dim, embed_dim, bias=True)

def forward(self, query: Tensor, key: Tensor, value: Tensor, key_padding_mask: Tensor | None) -> Tensor:
def forward(self, query: Tensor, key: Tensor, value: Tensor, key_padding_mask: Optional[Tensor]) -> Tensor:
"""
Args:
query :: (T, B, Feat)
Expand Down