Spaces:
Sleeping
Sleeping
handle return type
Browse files
app.py
CHANGED
@@ -158,7 +158,6 @@ with gr.Blocks(css=custom_css) as interface:
|
|
158 |
if __name__ == "__main__":
|
159 |
interface.launch(share=True)
|
160 |
"""
|
161 |
-
|
162 |
import gradio as gr
|
163 |
import os
|
164 |
import subprocess
|
@@ -166,13 +165,16 @@ import subprocess
|
|
166 |
# Function to visualize the model
|
167 |
def visualize_model(model_file):
|
168 |
# Create the output directory if it doesn't exist
|
169 |
-
output_dir =
|
170 |
-
os.makedirs(output_dir, exist_ok=True) #
|
|
|
|
|
|
|
171 |
|
172 |
# Save the uploaded file
|
173 |
-
file_path = os.path.join("./models", model_file.name)
|
174 |
with open(file_path, "wb") as f:
|
175 |
-
|
|
|
176 |
|
177 |
# Start Netron server to visualize the model
|
178 |
port = 8081
|
|
|
158 |
if __name__ == "__main__":
|
159 |
interface.launch(share=True)
|
160 |
"""
|
|
|
161 |
import gradio as gr
|
162 |
import os
|
163 |
import subprocess
|
|
|
165 |
# Function to visualize the model
|
166 |
def visualize_model(model_file):
|
167 |
# Create the output directory if it doesn't exist
|
168 |
+
output_dir = "./models/tmp/gradio/"
|
169 |
+
os.makedirs(output_dir, exist_ok=True) # Create directories if needed
|
170 |
+
|
171 |
+
# Define the file path to save
|
172 |
+
file_path = os.path.join(output_dir, model_file.name)
|
173 |
|
174 |
# Save the uploaded file
|
|
|
175 |
with open(file_path, "wb") as f:
|
176 |
+
with open(model_file.name, "rb") as uploaded_file:
|
177 |
+
f.write(uploaded_file.read()) # FIXED: Properly read and write file data
|
178 |
|
179 |
# Start Netron server to visualize the model
|
180 |
port = 8081
|