Spaces:
Running
Running
Upload 2 files
Browse files- app.py +23 -22
- requirements.txt +16 -16
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import os
|
3 |
import datetime
|
4 |
import pytz
|
|
|
5 |
|
6 |
def current_time():
|
7 |
current = datetime.datetime.now(pytz.timezone('Asia/Shanghai')).strftime("%Y年-%m月-%d日 %H时:%M分:%S秒")
|
@@ -9,7 +10,6 @@ def current_time():
|
|
9 |
|
10 |
print(f"[{current_time()}] 开始部署空间...")
|
11 |
|
12 |
-
from pathlib import Path
|
13 |
print(f"[{current_time()}] 日志:安装 - 必要包")
|
14 |
os.system("pip install -r ./requirements.txt")
|
15 |
print(f"[{current_time()}] 日志:安装 - gsutil")
|
@@ -25,6 +25,14 @@ os.system("python3 -m pip install -e .")
|
|
25 |
print(f"[{current_time()}] 日志:Python - 更新 Python 包管理器 pip")
|
26 |
os.system("python3 -m pip install --upgrade pip")
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
# 安装 mt3
|
29 |
print(f"[{current_time()}] 日志:Git - 克隆 Github 的 MT3 模型到当前目录")
|
30 |
os.system("git clone --branch=main https://github.com/magenta/mt3")
|
@@ -43,14 +51,6 @@ os.system("gsutil -q -m cp -r gs://mt3/checkpoints .")
|
|
43 |
print(f"[{current_time()}] 日志:gsutil - 复制 SoundFont 文件到当前目录")
|
44 |
os.system("gsutil -q -m cp gs://magentadata/soundfonts/SGM-v2.01-Sal-Guit-Bass-V1.3.sf2 .")
|
45 |
|
46 |
-
# 安装 airio
|
47 |
-
print(f"[{current_time()}] 日志:Git - 克隆 Github 的 airio 到当前目录")
|
48 |
-
os.system("git clone --branch=main https://github.com/google/airio")
|
49 |
-
print(f"[{current_time()}] 日志:文件 - 移动 airio 到当前目录并重命名为 airio_tmp 并删除")
|
50 |
-
os.system("mv airio airio_tmp; mv airio_tmp/* .; rm -r airio_tmp")
|
51 |
-
print(f"[{current_time()}] 日志:Python - 使用 pip 安装 当前目录内的 Python 包")
|
52 |
-
os.system("python3 -m pip install -e .")
|
53 |
-
|
54 |
#@title 导入和定义
|
55 |
print(f"[{current_time()}] 日志:导入 - 必要工具")
|
56 |
import functools
|
@@ -110,7 +110,7 @@ class InferenceModel(object):
|
|
110 |
self.batch_size = 8
|
111 |
self.outputs_length = 1024
|
112 |
self.sequence_length = {'inputs': self.inputs_length,
|
113 |
-
|
114 |
|
115 |
self.partitioner = t5x.partitioning.PjitPartitioner(
|
116 |
model_parallel_submesh=None, num_partitions=1)
|
@@ -120,7 +120,8 @@ class InferenceModel(object):
|
|
120 |
self.spectrogram_config = spectrograms.SpectrogramConfig()
|
121 |
self.codec = vocabularies.build_codec(
|
122 |
vocab_config=vocabularies.VocabularyConfig(
|
123 |
-
|
|
|
124 |
self.vocabulary = vocabularies.vocabulary_from_codec(self.codec)
|
125 |
self.output_features = {
|
126 |
'inputs': seqio.ContinuousFeature(dtype=tf.float32, rank=2),
|
@@ -314,14 +315,14 @@ article = "<p style='text-align: center'>出错了?试试把文件转换为MP3
|
|
314 |
examples=[['canon.flac'], ['download.wav']]
|
315 |
|
316 |
gr.Interface(
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
|
|
2 |
import os
|
3 |
import datetime
|
4 |
import pytz
|
5 |
+
from pathlib import Path
|
6 |
|
7 |
def current_time():
|
8 |
current = datetime.datetime.now(pytz.timezone('Asia/Shanghai')).strftime("%Y年-%m月-%d日 %H时:%M分:%S秒")
|
|
|
10 |
|
11 |
print(f"[{current_time()}] 开始部署空间...")
|
12 |
|
|
|
13 |
print(f"[{current_time()}] 日志:安装 - 必要包")
|
14 |
os.system("pip install -r ./requirements.txt")
|
15 |
print(f"[{current_time()}] 日志:安装 - gsutil")
|
|
|
25 |
print(f"[{current_time()}] 日志:Python - 更新 Python 包管理器 pip")
|
26 |
os.system("python3 -m pip install --upgrade pip")
|
27 |
|
28 |
+
# 安装 airio
|
29 |
+
print(f"[{current_time()}] 日志:Git - 克隆 Github 的 airio 到当前目录")
|
30 |
+
os.system("git clone --branch=main https://github.com/google/airio")
|
31 |
+
print(f"[{current_time()}] 日志:文件 - 移动 airio 到当前目录并重命名为 airio_tmp 并删除")
|
32 |
+
os.system("mv airio airio_tmp; mv airio_tmp/* .; rm -r airio_tmp")
|
33 |
+
print(f"[{current_time()}] 日志:Python - 使用 pip 安装 当前目录内的 Python 包")
|
34 |
+
os.system("python3 -m pip install -e .")
|
35 |
+
|
36 |
# 安装 mt3
|
37 |
print(f"[{current_time()}] 日志:Git - 克隆 Github 的 MT3 模型到当前目录")
|
38 |
os.system("git clone --branch=main https://github.com/magenta/mt3")
|
|
|
51 |
print(f"[{current_time()}] 日志:gsutil - 复制 SoundFont 文件到当前目录")
|
52 |
os.system("gsutil -q -m cp gs://magentadata/soundfonts/SGM-v2.01-Sal-Guit-Bass-V1.3.sf2 .")
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
#@title 导入和定义
|
55 |
print(f"[{current_time()}] 日志:导入 - 必要工具")
|
56 |
import functools
|
|
|
110 |
self.batch_size = 8
|
111 |
self.outputs_length = 1024
|
112 |
self.sequence_length = {'inputs': self.inputs_length,
|
113 |
+
'targets': self.outputs_length}
|
114 |
|
115 |
self.partitioner = t5x.partitioning.PjitPartitioner(
|
116 |
model_parallel_submesh=None, num_partitions=1)
|
|
|
120 |
self.spectrogram_config = spectrograms.SpectrogramConfig()
|
121 |
self.codec = vocabularies.build_codec(
|
122 |
vocab_config=vocabularies.VocabularyConfig(
|
123 |
+
num_velocity_bins=num_velocity_bins)
|
124 |
+
)
|
125 |
self.vocabulary = vocabularies.vocabulary_from_codec(self.codec)
|
126 |
self.output_features = {
|
127 |
'inputs': seqio.ContinuousFeature(dtype=tf.float32, rank=2),
|
|
|
315 |
examples=[['canon.flac'], ['download.wav']]
|
316 |
|
317 |
gr.Interface(
|
318 |
+
inference,
|
319 |
+
gr.inputs.Audio(type="filepath", label="输入"),
|
320 |
+
[gr.outputs.File(label="输出")],
|
321 |
+
title=title,
|
322 |
+
description=description,
|
323 |
+
article=article,
|
324 |
+
examples=examples,
|
325 |
+
allow_flagging=False,
|
326 |
+
allow_screenshot=False,
|
327 |
+
enable_queue=True
|
328 |
+
).launch()
|
requirements.txt
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
nest-asyncio
|
2 |
pyfluidsynth
|
3 |
-
absl-py
|
4 |
-
ddsp
|
5 |
-
flax
|
6 |
-
gin-config
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
tensorflow_cpu
|
18 |
-
tensorflow-datasets
|
19 |
-
|
|
|
1 |
nest-asyncio
|
2 |
pyfluidsynth
|
3 |
+
absl-py
|
4 |
+
ddsp
|
5 |
+
flax
|
6 |
+
gin-config
|
7 |
+
gradio
|
8 |
+
immutabledict
|
9 |
+
librosa
|
10 |
+
mir_eval
|
11 |
+
note_seq
|
12 |
+
numpy
|
13 |
+
pretty_midi
|
14 |
+
scikit-learn
|
15 |
+
scipy
|
16 |
+
seqio
|
17 |
tensorflow_cpu
|
18 |
+
tensorflow-datasets
|
19 |
+
t5
|