admin commited on
Commit
55bec7f
·
1 Parent(s): 821f1db

only leave en

Browse files
Files changed (3) hide show
  1. app.py +19 -23
  2. convert.py +2 -6
  3. utils.py +1 -7
app.py CHANGED
@@ -186,45 +186,41 @@ def infer(region: str):
186
  os.makedirs(TEMP_DIR, exist_ok=True)
187
  parser = argparse.ArgumentParser()
188
  args = get_args(parser)
189
- return generate_music(args, TEYVAT[region])
190
 
191
 
192
  if __name__ == "__main__":
193
  warnings.filterwarnings("ignore")
194
  with gr.Blocks() as demo:
195
- gr.Markdown(
196
- """
197
- <center>欢迎使用此创空间, 此创空间基于 Tunesformer 开源项目制作,完全免费。</center>
198
- <center>Welcome to this space based on the Tunesformer open source project, which is totally free!</center>"""
199
- )
200
  with gr.Row():
201
  with gr.Column():
202
  region_opt = gr.Dropdown(
203
- choices=list(TEYVAT.keys()),
204
- value="蒙德 Mondstadt",
205
- label="地区风格 Region",
206
  )
207
- gen_btn = gr.Button("生成 Generate")
208
  gr.Markdown(
209
  """
210
- <center>
211
- 当前模型还在调试中,计划在原神主线杀青后,所有国家地区角色全部开放后,二创音乐会齐全且样本均衡,届时重新微调模型并添加现实风格筛选辅助游戏各国家输出强化学习,以提升输出区分度与质量。<br>The current model is still in debugging, the plan is in the Genshin Impact after the main line is killed, all countries and regions after all the characters are open, the second creation of the concert will be complete and the sample is balanced, at that time to re-fine-tune the model and add the reality of the style of screening to assist in the game of each country's output to strengthen the learning in order to enhance the output differentiation and quality.
 
212
 
213
- 数据来源 (Data source): <a href="https://musescore.org">MuseScore</a><br>
214
- Tag 嵌入数据来源 (Tags source): <a href="https://genshin-impact.fandom.com/wiki/Genshin_Impact_Wiki">Genshin Impact Wiki | Fandom</a><br>
215
- 模型基础 (Model base): <a href="https://github.com/sander-wood/tunesformer">Tunesformer</a>
216
 
217
- 注:崩铁方面数据工程正在运作中,未来也希望随主线杀青而基线化。<br>Note: Data engineering on the Star Rail is in operation, and will hopefully be baselined in the future as well with the mainline kill.</center>"""
218
  )
219
 
220
  with gr.Column():
221
- wav_output = gr.Audio(label="音频 (Audio)", type="filepath")
222
- dld_midi = gr.File(label="下载 MIDI (Download MIDI)")
223
- pdf_score = gr.File(label="下载 PDF 乐谱 (Download PDF)")
224
- dld_xml = gr.File(label="下载 MusicXML (Download MusicXML)")
225
- dld_mxl = gr.File(label="下载 MXL (Download MXL)")
226
- abc_output = gr.Textbox(label="abc notation", show_copy_button=True)
227
- img_score = gr.Image(label="五线谱 (Staff)", type="filepath")
228
 
229
  gen_btn.click(
230
  infer,
 
186
  os.makedirs(TEMP_DIR, exist_ok=True)
187
  parser = argparse.ArgumentParser()
188
  args = get_args(parser)
189
+ return generate_music(args, region)
190
 
191
 
192
  if __name__ == "__main__":
193
  warnings.filterwarnings("ignore")
194
  with gr.Blocks() as demo:
 
 
 
 
 
195
  with gr.Row():
196
  with gr.Column():
197
  region_opt = gr.Dropdown(
198
+ choices=TEYVAT,
199
+ value="Mondstadt",
200
+ label="Region",
201
  )
202
+ gen_btn = gr.Button("Generate")
203
  gr.Markdown(
204
  """
205
+ Welcome to this space based on the Tunesformer open source project, which is totally free!
206
+
207
+ The current model is still in debugging, the plan is in the Genshin Impact after the main line is killed, all countries and regions after all the characters are open, the second creation of the concert will be complete and the sample is balanced, at that time to re-fine-tune the model and add the reality of the style of screening to assist in the game of each country's output to strengthen the learning in order to enhance the output differentiation and quality.
208
 
209
+ Data source: <a href="https://musescore.org">MuseScore</a><br>
210
+ Tags source: <a href="https://genshin-impact.fandom.com/wiki/Genshin_Impact_Wiki">Genshin Impact Wiki | Fandom</a><br>
211
+ Model base: <a href="https://github.com/sander-wood/tunesformer">Tunesformer</a>
212
 
213
+ Note: Data engineering on the Star Rail is in operation, and will hopefully be baselined in the future as well with the mainline kill."""
214
  )
215
 
216
  with gr.Column():
217
+ wav_output = gr.Audio(label="Audio", type="filepath")
218
+ dld_midi = gr.File(label="Download MIDI")
219
+ pdf_score = gr.File(label="Download PDF")
220
+ dld_xml = gr.File(label="Download MusicXML")
221
+ dld_mxl = gr.File(label="Download MXL")
222
+ abc_output = gr.Textbox(label="ABC notation", show_copy_button=True)
223
+ img_score = gr.Image(label="Staff", type="filepath")
224
 
225
  gen_btn.click(
226
  infer,
convert.py CHANGED
@@ -27,17 +27,14 @@ def xml2(xml_path: str, target_fmt: str):
27
  def pdf2img(pdf_path: str):
28
  output_path = pdf_path.replace(".pdf", ".jpg")
29
  doc = fitz.open(pdf_path)
30
- # 创建一个图像列表
31
  images = []
32
  for page_number in range(doc.page_count):
33
  page = doc[page_number]
34
- # 将页面渲染为图像
35
  image = page.get_pixmap()
36
- # 将图像添加到列表
37
  images.append(
38
  Image.frombytes("RGB", [image.width, image.height], image.samples)
39
  )
40
- # 竖向合并图像
41
  merged_image = Image.new(
42
  "RGB", (images[0].width, sum(image.height for image in images))
43
  )
@@ -45,9 +42,8 @@ def pdf2img(pdf_path: str):
45
  for image in images:
46
  merged_image.paste(image, (0, y_offset))
47
  y_offset += image.height
48
- # 保存合并后的图像为JPG
49
  merged_image.save(output_path, "JPEG")
50
- # 关闭PDF文档
51
  doc.close()
52
  return output_path
53
 
 
27
  def pdf2img(pdf_path: str):
28
  output_path = pdf_path.replace(".pdf", ".jpg")
29
  doc = fitz.open(pdf_path)
 
30
  images = []
31
  for page_number in range(doc.page_count):
32
  page = doc[page_number]
 
33
  image = page.get_pixmap()
 
34
  images.append(
35
  Image.frombytes("RGB", [image.width, image.height], image.samples)
36
  )
37
+
38
  merged_image = Image.new(
39
  "RGB", (images[0].width, sum(image.height for image in images))
40
  )
 
42
  for image in images:
43
  merged_image.paste(image, (0, y_offset))
44
  y_offset += image.height
45
+
46
  merged_image.save(output_path, "JPEG")
 
47
  doc.close()
48
  return output_path
49
 
utils.py CHANGED
@@ -7,13 +7,7 @@ import subprocess
7
  from tqdm import tqdm
8
  from modelscope import snapshot_download
9
 
10
- TEYVAT = {
11
- "蒙德 Mondstadt": "Mondstadt",
12
- "璃月 Liyue": "Liyue",
13
- "稻妻 Inazuma": "Inazuma",
14
- "须弥 Sumeru": "Sumeru",
15
- "枫丹 Fontaine": "Fontaine",
16
- }
17
  WEIGHTS_PATH = (
18
  snapshot_download("Genius-Society/hoyoMusic", cache_dir="./__pycache__")
19
  + "/weights.pth"
 
7
  from tqdm import tqdm
8
  from modelscope import snapshot_download
9
 
10
+ TEYVAT = ["Mondstadt", "Liyue", "Inazuma", "Sumeru", "Fontaine"]
 
 
 
 
 
 
11
  WEIGHTS_PATH = (
12
  snapshot_download("Genius-Society/hoyoMusic", cache_dir="./__pycache__")
13
  + "/weights.pth"