Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,8 +88,7 @@ def infer(genre_txt_content, lyrics_txt_content):
|
|
| 88 |
|
| 89 |
# Command and arguments
|
| 90 |
command = [
|
| 91 |
-
"python", "
|
| 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}",
|
|
@@ -104,47 +103,19 @@ def infer(genre_txt_content, lyrics_txt_content):
|
|
| 104 |
|
| 105 |
# Execute the command
|
| 106 |
try:
|
| 107 |
-
|
| 108 |
-
|
| 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 |
-
#
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 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(
|
| 145 |
-
|
| 146 |
return None
|
| 147 |
-
except
|
| 148 |
print(f"Error occurred: {e}")
|
| 149 |
return None
|
| 150 |
finally:
|
|
|
|
| 88 |
|
| 89 |
# Command and arguments
|
| 90 |
command = [
|
| 91 |
+
"python", "infer.py",
|
|
|
|
| 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}",
|
|
|
|
| 103 |
|
| 104 |
# Execute the command
|
| 105 |
try:
|
| 106 |
+
subprocess.run(command, check=True)
|
| 107 |
+
print("Command executed successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
# Check and print the contents of the output folder
|
| 110 |
+
output_files = os.listdir(output_dir)
|
| 111 |
+
if output_files:
|
| 112 |
+
print("Output folder contents:")
|
| 113 |
+
for file in output_files:
|
| 114 |
+
print(f"- {file}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
else:
|
| 116 |
+
print("Output folder is empty.")
|
|
|
|
| 117 |
return None
|
| 118 |
+
except subprocess.CalledProcessError as e:
|
| 119 |
print(f"Error occurred: {e}")
|
| 120 |
return None
|
| 121 |
finally:
|