Spaces:
Dejansimic
/
Runtime error

fffiloni commited on
Commit
b1dbec0
·
verified ·
1 Parent(s): 0e550b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -86,7 +86,7 @@ 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", "infer.py",
92
  "--stage1_model", "m-a-p/YuE-s1-7B-anneal-en-cot",
@@ -97,25 +97,39 @@ def infer(genre_txt_content, lyrics_txt_content):
97
  "--stage2_batch_size", "4",
98
  "--output_dir", f"{output_dir}",
99
  "--cuda_idx", "0",
100
- "--max_new_tokens", "3000"
 
101
  ]
102
 
103
- # Execute the command
104
  try:
105
- subprocess.run(command, check=True)
106
- print("Command executed successfully!")
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- # Check and print the contents of the output folder
109
  output_files = os.listdir(output_dir)
110
  if output_files:
111
  print("Output folder contents:")
112
  for file in output_files:
113
  print(f"- {file}")
 
 
114
  else:
115
  print("Output folder is empty.")
116
- return None
117
  except subprocess.CalledProcessError as e:
118
  print(f"Error occurred: {e}")
 
119
  return None
120
  finally:
121
  # Clean up temporary files
 
86
  print(f"Output folder ensured at: {output_dir}")
87
 
88
 
89
+ # Command and arguments with additional parameters
90
  command = [
91
  "python", "infer.py",
92
  "--stage1_model", "m-a-p/YuE-s1-7B-anneal-en-cot",
 
97
  "--stage2_batch_size", "4",
98
  "--output_dir", f"{output_dir}",
99
  "--cuda_idx", "0",
100
+ "--max_new_tokens", "3000",
101
+ "--disable_offload_model" # Add this to prevent GPU/CPU transfer issues
102
  ]
103
 
 
104
  try:
105
+ # Run with environment variables to control CUDA
106
+ env = os.environ.copy()
107
+ env["CUDA_VISIBLE_DEVICES"] = "0"
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
+ print("Command output:", result.stdout)
117
+ print("Command errors:", result.stderr)
118
 
119
+ # Check output files
120
  output_files = os.listdir(output_dir)
121
  if output_files:
122
  print("Output folder contents:")
123
  for file in output_files:
124
  print(f"- {file}")
125
+ # TODO: Return the generated audio file path
126
+ return None
127
  else:
128
  print("Output folder is empty.")
129
+ return None
130
  except subprocess.CalledProcessError as e:
131
  print(f"Error occurred: {e}")
132
+ print("Error output:", e.stderr)
133
  return None
134
  finally:
135
  # Clean up temporary files