Spaces:
Configuration error
Configuration error
Kangarroar
commited on
Commit
•
882f6f6
1
Parent(s):
ec60f56
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import tempfile
|
|
8 |
import shutil
|
9 |
import requests
|
10 |
from pathlib import Path
|
11 |
-
temp_dir =
|
12 |
global ckpt_temp_file
|
13 |
global audio_temp_file
|
14 |
global config_temp_file
|
@@ -62,32 +62,31 @@ st.set_page_config(
|
|
62 |
st.title('DIFF-SVC Render')
|
63 |
|
64 |
###CKPT LOADER
|
65 |
-
|
66 |
-
ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt')
|
67 |
# Check if user uploaded a CKPT file
|
68 |
-
if ckpt is not None:
|
69 |
#TEMP FUNCTION
|
70 |
-
|
71 |
# Get the file contents as bytes
|
72 |
bytes_data = ckpt.getvalue()
|
73 |
# Write the bytes to the temporary file
|
74 |
temp.write(bytes_data)
|
75 |
-
|
76 |
# Print the temporary file name
|
77 |
print(temp.name)
|
78 |
-
st.success("File saved to: {}".format(ckpt_temp_file))
|
79 |
|
80 |
# Display the file path
|
81 |
-
if "ckpt_temp_file" in locals():
|
82 |
-
|
83 |
|
84 |
# File uploader
|
85 |
-
config = st.file_uploader("Choose your config", type= 'yaml')
|
86 |
|
87 |
# Check if user uploaded a config file
|
88 |
-
if config is not None:
|
89 |
#TEMP FUNCTION
|
90 |
-
|
91 |
# Get the file contents as bytes
|
92 |
bytes_data = config.getvalue()
|
93 |
# Write the bytes to the temporary file
|
@@ -97,15 +96,15 @@ if config is not None:
|
|
97 |
print(temp.name)
|
98 |
|
99 |
# Display the file path
|
100 |
-
if "config_temp_file" in locals():
|
101 |
-
|
102 |
|
103 |
-
audio = st.file_uploader("Choose your audio", type=["wav", "mp3"])
|
104 |
|
105 |
# Check if user uploaded an audio file
|
106 |
-
if audio is not None:
|
107 |
#TEMP FUNCTION
|
108 |
-
|
109 |
# Get the file contents as bytes
|
110 |
bytes_data = audio.getvalue()
|
111 |
# Write the bytes to the temporary file
|
@@ -115,8 +114,8 @@ if audio is not None:
|
|
115 |
print(temp.name)
|
116 |
|
117 |
# Display the file path
|
118 |
-
if "audio_temp_file" in locals():
|
119 |
-
|
120 |
# Add a text input for the title with a default value of 0
|
121 |
title = st.text_input("Key", value="0")
|
122 |
# Add a button to start the rendering process
|
|
|
8 |
import shutil
|
9 |
import requests
|
10 |
from pathlib import Path
|
11 |
+
temp_dir = os.path.expanduser("~/app")
|
12 |
global ckpt_temp_file
|
13 |
global audio_temp_file
|
14 |
global config_temp_file
|
|
|
62 |
st.title('DIFF-SVC Render')
|
63 |
|
64 |
###CKPT LOADER
|
65 |
+
with tempfile.TemporaryDirectory(dir=os.path.expanduser("~/app")) as temp_dir:
|
66 |
+
ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt')
|
67 |
# Check if user uploaded a CKPT file
|
68 |
+
if ckpt is not None:
|
69 |
#TEMP FUNCTION
|
70 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp:
|
71 |
# Get the file contents as bytes
|
72 |
bytes_data = ckpt.getvalue()
|
73 |
# Write the bytes to the temporary file
|
74 |
temp.write(bytes_data)
|
75 |
+
ckpt_temp_file = temp.name
|
76 |
# Print the temporary file name
|
77 |
print(temp.name)
|
|
|
78 |
|
79 |
# Display the file path
|
80 |
+
if "ckpt_temp_file" in locals():
|
81 |
+
st.success("File saved to: {}".format(ckpt_temp_file))
|
82 |
|
83 |
# File uploader
|
84 |
+
config = st.file_uploader("Choose your config", type= 'yaml')
|
85 |
|
86 |
# Check if user uploaded a config file
|
87 |
+
if config is not None:
|
88 |
#TEMP FUNCTION
|
89 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.yaml', delete=False) as temp:
|
90 |
# Get the file contents as bytes
|
91 |
bytes_data = config.getvalue()
|
92 |
# Write the bytes to the temporary file
|
|
|
96 |
print(temp.name)
|
97 |
|
98 |
# Display the file path
|
99 |
+
if "config_temp_file" in locals():
|
100 |
+
st.success("File saved to: {}".format(config_temp_file))
|
101 |
|
102 |
+
audio = st.file_uploader("Choose your audio", type=["wav", "mp3"])
|
103 |
|
104 |
# Check if user uploaded an audio file
|
105 |
+
if audio is not None:
|
106 |
#TEMP FUNCTION
|
107 |
+
with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp:
|
108 |
# Get the file contents as bytes
|
109 |
bytes_data = audio.getvalue()
|
110 |
# Write the bytes to the temporary file
|
|
|
114 |
print(temp.name)
|
115 |
|
116 |
# Display the file path
|
117 |
+
if "audio_temp_file" in locals():
|
118 |
+
st.success("File saved to: {}".format(audio_temp_file))
|
119 |
# Add a text input for the title with a default value of 0
|
120 |
title = st.text_input("Key", value="0")
|
121 |
# Add a button to start the rendering process
|