Spaces:
Running
on
A100
Running
on
A100
Update app.py
Browse files
app.py
CHANGED
@@ -86,9 +86,10 @@ def infer(genre_txt_content, lyrics_txt_content):
|
|
86 |
print(f"Output folder ensured at: {output_dir}")
|
87 |
|
88 |
|
89 |
-
# Command and arguments
|
90 |
command = [
|
91 |
-
"python", "
|
|
|
92 |
"--stage1_model", "m-a-p/YuE-s1-7B-anneal-en-cot",
|
93 |
"--stage2_model", "m-a-p/YuE-s2-1B-general",
|
94 |
"--genre_txt", f"{genre_txt_path}",
|
@@ -98,38 +99,53 @@ def infer(genre_txt_content, lyrics_txt_content):
|
|
98 |
"--output_dir", f"{output_dir}",
|
99 |
"--cuda_idx", "0",
|
100 |
"--max_new_tokens", "3000",
|
101 |
-
"--disable_offload_model"
|
102 |
]
|
103 |
|
|
|
104 |
try:
|
105 |
-
# Run with
|
106 |
-
|
107 |
-
|
108 |
-
result = subprocess.run(
|
109 |
-
command,
|
110 |
-
check=True,
|
111 |
-
env=env,
|
112 |
stdout=subprocess.PIPE,
|
113 |
stderr=subprocess.PIPE,
|
114 |
-
text=True
|
|
|
|
|
115 |
)
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
127 |
else:
|
128 |
-
print("
|
129 |
-
|
130 |
-
|
|
|
131 |
print(f"Error occurred: {e}")
|
132 |
-
print("Error output:", e.stderr)
|
133 |
return None
|
134 |
finally:
|
135 |
# Clean up temporary files
|
|
|
86 |
print(f"Output folder ensured at: {output_dir}")
|
87 |
|
88 |
|
89 |
+
# Command and arguments
|
90 |
command = [
|
91 |
+
"python", "-u", # Add -u for unbuffered output
|
92 |
+
"infer.py",
|
93 |
"--stage1_model", "m-a-p/YuE-s1-7B-anneal-en-cot",
|
94 |
"--stage2_model", "m-a-p/YuE-s2-1B-general",
|
95 |
"--genre_txt", f"{genre_txt_path}",
|
|
|
99 |
"--output_dir", f"{output_dir}",
|
100 |
"--cuda_idx", "0",
|
101 |
"--max_new_tokens", "3000",
|
102 |
+
"--disable_offload_model"
|
103 |
]
|
104 |
|
105 |
+
# Execute the command
|
106 |
try:
|
107 |
+
# Run process with real-time output
|
108 |
+
process = subprocess.Popen(
|
109 |
+
command,
|
|
|
|
|
|
|
|
|
110 |
stdout=subprocess.PIPE,
|
111 |
stderr=subprocess.PIPE,
|
112 |
+
text=True,
|
113 |
+
bufsize=1,
|
114 |
+
universal_newlines=True
|
115 |
)
|
116 |
+
|
117 |
+
# Print output in real-time
|
118 |
+
while True:
|
119 |
+
output = process.stdout.readline()
|
120 |
+
error = process.stderr.readline()
|
121 |
+
|
122 |
+
if output:
|
123 |
+
print(f"Output: {output.strip()}")
|
124 |
+
if error:
|
125 |
+
print(f"Error: {error.strip()}")
|
126 |
+
|
127 |
+
# Check if process has finished
|
128 |
+
if process.poll() is not None:
|
129 |
+
break
|
130 |
+
|
131 |
+
# Get the return code
|
132 |
+
return_code = process.poll()
|
133 |
|
134 |
+
if return_code == 0:
|
135 |
+
print("Command executed successfully!")
|
136 |
+
output_files = os.listdir(output_dir)
|
137 |
+
if output_files:
|
138 |
+
print("Output folder contents:")
|
139 |
+
for file in output_files:
|
140 |
+
print(f"- {file}")
|
141 |
+
else:
|
142 |
+
print("Output folder is empty.")
|
143 |
else:
|
144 |
+
print(f"Command failed with return code {return_code}")
|
145 |
+
|
146 |
+
return None
|
147 |
+
except Exception as e:
|
148 |
print(f"Error occurred: {e}")
|
|
|
149 |
return None
|
150 |
finally:
|
151 |
# Clean up temporary files
|