Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,23 @@ import datetime
|
|
7 |
import subprocess
|
8 |
import os
|
9 |
from inference import postprocess_inst_names
|
10 |
-
|
11 |
-
# 如果你的 inference、convert 等逻辑和原来一致,可以直接用
|
12 |
from inference import inference_patch
|
13 |
from convert import abc2xml, xml2, pdf2img
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# 读取 prompt 组合
|
17 |
with open('prompts.txt', 'r') as f:
|
@@ -141,6 +153,7 @@ def update_page(direction, data):
|
|
141 |
return new_image, prev_btn_state, next_btn_state, data
|
142 |
|
143 |
|
|
|
144 |
def generate_music(period, composer, instrumentation):
|
145 |
"""
|
146 |
需要保证每次 yield 的返回值数量一致。
|
|
|
7 |
import subprocess
|
8 |
import os
|
9 |
from inference import postprocess_inst_names
|
|
|
|
|
10 |
from inference import inference_patch
|
11 |
from convert import abc2xml, xml2, pdf2img
|
12 |
|
13 |
+
try:
|
14 |
+
import spaces
|
15 |
+
USING_SPACES = True
|
16 |
+
except ImportError:
|
17 |
+
USING_SPACES = False
|
18 |
+
import zero
|
19 |
+
|
20 |
+
|
21 |
+
def gpu_decorator(func):
|
22 |
+
if USING_SPACES:
|
23 |
+
return spaces.GPU(func)
|
24 |
+
else:
|
25 |
+
return func
|
26 |
+
|
27 |
|
28 |
# 读取 prompt 组合
|
29 |
with open('prompts.txt', 'r') as f:
|
|
|
153 |
return new_image, prev_btn_state, next_btn_state, data
|
154 |
|
155 |
|
156 |
+
@gpu_decorator
|
157 |
def generate_music(period, composer, instrumentation):
|
158 |
"""
|
159 |
需要保证每次 yield 的返回值数量一致。
|