Spaces:
Running
on
Zero
Running
on
Zero
fix: file upload handling for Gradio NamedString objects
Browse files
app.py
CHANGED
@@ -27,17 +27,17 @@ def handle_file_upload(file):
|
|
27 |
if file is None:
|
28 |
return None, "No file uploaded"
|
29 |
|
30 |
-
filename =
|
31 |
-
formatted_title = sanitize_filename(filename)
|
32 |
|
33 |
input_path = os.path.join(INPUT_FOLDER, "wav", f"{formatted_title}.wav")
|
34 |
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|
35 |
|
36 |
-
|
37 |
-
|
38 |
|
39 |
return input_path, formatted_title
|
40 |
-
|
41 |
def run_inference(model_type, config_path, start_check_point, input_dir, output_dir, device_ids="0"):
|
42 |
command = [
|
43 |
"python", "inference.py",
|
|
|
27 |
if file is None:
|
28 |
return None, "No file uploaded"
|
29 |
|
30 |
+
filename = os.path.basename(file.name)
|
31 |
+
formatted_title = sanitize_filename(Path(filename).stem)
|
32 |
|
33 |
input_path = os.path.join(INPUT_FOLDER, "wav", f"{formatted_title}.wav")
|
34 |
os.makedirs(os.path.dirname(input_path), exist_ok=True)
|
35 |
|
36 |
+
# Copy the uploaded file to the input folder
|
37 |
+
shutil.copy(file.name, input_path)
|
38 |
|
39 |
return input_path, formatted_title
|
40 |
+
|
41 |
def run_inference(model_type, config_path, start_check_point, input_dir, output_dir, device_ids="0"):
|
42 |
command = [
|
43 |
"python", "inference.py",
|