Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from gradio_client import Client
|
| 3 |
import os
|
| 4 |
|
| 5 |
BACKEND_SPACE = "CleanSong-AI/Main-tool-backend-main"
|
|
@@ -11,14 +11,18 @@ def clean_song(file_path):
|
|
| 11 |
client = Client(BACKEND_SPACE)
|
| 12 |
|
| 13 |
result = client.predict(
|
| 14 |
-
file_path,
|
| 15 |
api_name="/predict"
|
| 16 |
)
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
|
|
|
| 22 |
|
| 23 |
# ------------------------------------------------------------
|
| 24 |
# UI
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio_client import Client, handle_file
|
| 3 |
import os
|
| 4 |
|
| 5 |
BACKEND_SPACE = "CleanSong-AI/Main-tool-backend-main"
|
|
|
|
| 11 |
client = Client(BACKEND_SPACE)
|
| 12 |
|
| 13 |
result = client.predict(
|
| 14 |
+
handle_file(file_path), # ✅ REQUIRED
|
| 15 |
api_name="/predict"
|
| 16 |
)
|
| 17 |
|
| 18 |
+
# Normalize HF return types
|
| 19 |
+
if isinstance(result, (list, tuple)):
|
| 20 |
+
result = result[0]
|
| 21 |
|
| 22 |
+
if isinstance(result, dict) and "name" in result:
|
| 23 |
+
result = result["name"]
|
| 24 |
|
| 25 |
+
return result
|
| 26 |
|
| 27 |
# ------------------------------------------------------------
|
| 28 |
# UI
|