Spaces:
Runtime error
Runtime error
Update wrapper.py
Browse files- wrapper.py +70 -17
wrapper.py
CHANGED
@@ -4,6 +4,23 @@ import os
|
|
4 |
import subprocess
|
5 |
import sys
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def main():
|
8 |
parser = argparse.ArgumentParser(description='Run YuE model with direct input')
|
9 |
parser.add_argument('--genre', type=str, required=True, help='Genre tags for the music')
|
@@ -15,34 +32,41 @@ def main():
|
|
15 |
|
16 |
args = parser.parse_args()
|
17 |
|
|
|
|
|
|
|
18 |
# Create temporary files for genre and lyrics
|
19 |
with tempfile.NamedTemporaryFile(mode='w', delete=False) as genre_file:
|
20 |
genre_file.write(args.genre)
|
21 |
genre_path = genre_file.name
|
|
|
|
|
22 |
|
23 |
with tempfile.NamedTemporaryFile(mode='w', delete=False) as lyrics_file:
|
24 |
lyrics_file.write(args.lyrics)
|
25 |
lyrics_path = lyrics_file.name
|
|
|
|
|
26 |
|
27 |
output_dir = '/home/user/app/output'
|
28 |
|
29 |
try:
|
30 |
-
|
31 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
32 |
-
|
33 |
-
print(f"Current directory: {current_dir}")
|
34 |
-
print("\nContents of current directory:")
|
35 |
-
print(os.listdir(current_dir))
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
print(os.listdir("./mm_tokenizer_v0.2_hf"))
|
40 |
-
else:
|
41 |
-
print("\nmm_tokenizer_v0.2_hf directory not found!")
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
'--stage1_model', 'm-a-p/YuE-s1-7B-anneal-en-cot',
|
47 |
'--stage2_model', 'm-a-p/YuE-s2-1B-general',
|
48 |
'--genre_txt', genre_path,
|
@@ -52,15 +76,44 @@ def main():
|
|
52 |
'--output_dir', output_dir,
|
53 |
'--cuda_idx', str(args.cuda_idx),
|
54 |
'--max_new_tokens', str(args.max_new_tokens)
|
55 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
print(f"\nOutput directory: {output_dir}")
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
finally:
|
63 |
# Clean up temporary files
|
|
|
64 |
os.unlink(genre_path)
|
65 |
os.unlink(lyrics_path)
|
66 |
|
|
|
4 |
import subprocess
|
5 |
import sys
|
6 |
|
7 |
+
def debug_environment():
|
8 |
+
"""Print debug information about the environment"""
|
9 |
+
print("\n=== Debug Information ===")
|
10 |
+
print(f"Current working directory: {os.getcwd()}")
|
11 |
+
print("\nDirectory contents:")
|
12 |
+
for root, dirs, files in os.walk("."):
|
13 |
+
level = root.replace(".", "").count(os.sep)
|
14 |
+
indent = " " * 4 * level
|
15 |
+
print(f"{indent}{os.path.basename(root)}/")
|
16 |
+
subindent = " " * 4 * (level + 1)
|
17 |
+
for f in files:
|
18 |
+
print(f"{subindent}{f}")
|
19 |
+
|
20 |
+
print("\nEnvironment variables:")
|
21 |
+
for key, value in os.environ.items():
|
22 |
+
print(f"{key}={value}")
|
23 |
+
|
24 |
def main():
|
25 |
parser = argparse.ArgumentParser(description='Run YuE model with direct input')
|
26 |
parser.add_argument('--genre', type=str, required=True, help='Genre tags for the music')
|
|
|
32 |
|
33 |
args = parser.parse_args()
|
34 |
|
35 |
+
print("\n=== Starting YuE Inference ===")
|
36 |
+
debug_environment()
|
37 |
+
|
38 |
# Create temporary files for genre and lyrics
|
39 |
with tempfile.NamedTemporaryFile(mode='w', delete=False) as genre_file:
|
40 |
genre_file.write(args.genre)
|
41 |
genre_path = genre_file.name
|
42 |
+
print(f"\nCreated genre file at: {genre_path}")
|
43 |
+
print(f"Genre content: {args.genre}")
|
44 |
|
45 |
with tempfile.NamedTemporaryFile(mode='w', delete=False) as lyrics_file:
|
46 |
lyrics_file.write(args.lyrics)
|
47 |
lyrics_path = lyrics_file.name
|
48 |
+
print(f"\nCreated lyrics file at: {lyrics_path}")
|
49 |
+
print(f"Lyrics content: {args.lyrics}")
|
50 |
|
51 |
output_dir = '/home/user/app/output'
|
52 |
|
53 |
try:
|
54 |
+
# Get the directory where wrapper.py is located
|
55 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
56 |
+
infer_script = os.path.join(current_dir, 'infer.py')
|
|
|
|
|
|
|
57 |
|
58 |
+
print(f"\nInference script path: {infer_script}")
|
59 |
+
print(f"Script exists: {os.path.exists(infer_script)}")
|
|
|
|
|
|
|
60 |
|
61 |
+
if os.path.exists('./mm_tokenizer_v0.2_hf'):
|
62 |
+
print("\nTokenizer directory contents:")
|
63 |
+
print(os.listdir('./mm_tokenizer_v0.2_hf'))
|
64 |
+
else:
|
65 |
+
print("\nWARNING: Tokenizer directory not found!")
|
66 |
+
|
67 |
+
print("\nExecuting inference command...")
|
68 |
+
command = [
|
69 |
+
'python', infer_script,
|
70 |
'--stage1_model', 'm-a-p/YuE-s1-7B-anneal-en-cot',
|
71 |
'--stage2_model', 'm-a-p/YuE-s2-1B-general',
|
72 |
'--genre_txt', genre_path,
|
|
|
76 |
'--output_dir', output_dir,
|
77 |
'--cuda_idx', str(args.cuda_idx),
|
78 |
'--max_new_tokens', str(args.max_new_tokens)
|
79 |
+
]
|
80 |
+
|
81 |
+
print(f"Command: {' '.join(command)}")
|
82 |
+
|
83 |
+
# Run the inference script
|
84 |
+
result = subprocess.run(command,
|
85 |
+
check=True,
|
86 |
+
capture_output=True,
|
87 |
+
text=True)
|
88 |
+
|
89 |
+
print("\nInference completed successfully!")
|
90 |
+
print("\nStdout:")
|
91 |
+
print(result.stdout)
|
92 |
+
|
93 |
+
if result.stderr:
|
94 |
+
print("\nStderr:")
|
95 |
+
print(result.stderr)
|
96 |
|
97 |
print(f"\nOutput directory: {output_dir}")
|
98 |
+
if os.path.exists(output_dir):
|
99 |
+
print("Generated files:")
|
100 |
+
for file in os.listdir(output_dir):
|
101 |
+
file_path = os.path.join(output_dir, file)
|
102 |
+
print(f"- {file_path} ({os.path.getsize(file_path)} bytes)")
|
103 |
+
else:
|
104 |
+
print("WARNING: Output directory does not exist!")
|
105 |
|
106 |
+
except subprocess.CalledProcessError as e:
|
107 |
+
print("\nError running inference script:")
|
108 |
+
print(f"Exit code: {e.returncode}")
|
109 |
+
print("\nStdout:")
|
110 |
+
print(e.stdout)
|
111 |
+
print("\nStderr:")
|
112 |
+
print(e.stderr)
|
113 |
+
raise
|
114 |
finally:
|
115 |
# Clean up temporary files
|
116 |
+
print("\nCleaning up temporary files...")
|
117 |
os.unlink(genre_path)
|
118 |
os.unlink(lyrics_path)
|
119 |
|