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