BhumikaMak commited on
Commit
cc04a10
·
verified ·
1 Parent(s): 97c10d5

handle return type

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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 = os.path.join("./models", os.path.dirname(model_file.name))
170
- os.makedirs(output_dir, exist_ok=True) # FIXED: Create nested directories if needed
 
 
 
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
- f.write(model_file.data) # Save the uploaded file data
 
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