Merge pull request #41 from hykilpikonna/main
Remove torchvision dependency and solve pytorch vulnerability
This commit is contained in:
+4
-1
@@ -350,4 +350,7 @@ MigrationBackup/
|
|||||||
.ionide/
|
.ionide/
|
||||||
dist/
|
dist/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
._*
|
._*
|
||||||
|
|
||||||
|
venv/
|
||||||
|
root_path/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from torch.utils.data import Dataset
|
from torch.utils.data import Dataset
|
||||||
from torchvision.datasets.utils import download_url
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
from pathlib import Path
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import os
|
import os
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
@@ -74,9 +74,29 @@ class ESC50(AudioDataset):
|
|||||||
return len(self.audio_paths)
|
return len(self.audio_paths)
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
download_url(self.url, self.root, self.filename)
|
# Download file using requests
|
||||||
|
import requests
|
||||||
|
file = Path(self.root) / self.filename
|
||||||
|
if file.is_file():
|
||||||
|
return
|
||||||
|
|
||||||
|
r = requests.get(self.url, stream=True)
|
||||||
|
|
||||||
# extract file
|
# To prevent partial downloads, download to a temp file first
|
||||||
|
tmp = file.with_suffix('.tmp')
|
||||||
|
tmp.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
with open(tmp, 'wb') as f:
|
||||||
|
pbar = tqdm(unit=" MB", bar_format=f'{file.name}: {{rate_noinv_fmt}}')
|
||||||
|
|
||||||
|
for chunk in r.iter_content(chunk_size=1024):
|
||||||
|
if chunk:
|
||||||
|
pbar.update(len(chunk) / 1024 / 1024)
|
||||||
|
f.write(chunk)
|
||||||
|
|
||||||
|
# move temp file to correct location
|
||||||
|
tmp.rename(file)
|
||||||
|
|
||||||
|
# # extract file
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
with ZipFile(os.path.join(self.root, self.filename), 'r') as zip:
|
with ZipFile(os.path.join(self.root, self.filename), 'r') as zip:
|
||||||
zip.extractall(path=self.root)
|
zip.extractall(path=self.root)
|
||||||
|
|||||||
Generated
+1146
-1001
File diff suppressed because it is too large
Load Diff
@@ -13,12 +13,10 @@ packages = [
|
|||||||
python = "^3.8"
|
python = "^3.8"
|
||||||
librosa = "^0.10.1"
|
librosa = "^0.10.1"
|
||||||
numpy = "^1.23.0"
|
numpy = "^1.23.0"
|
||||||
numba = "^0.58.0"
|
|
||||||
pandas = "^2.0.0"
|
pandas = "^2.0.0"
|
||||||
torch = "^2.1.0"
|
torch = "^2.1.0"
|
||||||
torchaudio = "^2.1.0"
|
torchaudio = "^2.1.0"
|
||||||
torchlibrosa = "^0.1.0"
|
torchlibrosa = "^0.1.0"
|
||||||
torchvision = "^0.16.0"
|
|
||||||
tqdm = "^4.66.1"
|
tqdm = "^4.66.1"
|
||||||
transformers = "^4.34.0"
|
transformers = "^4.34.0"
|
||||||
pyyaml = "^6.0.1"
|
pyyaml = "^6.0.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user