omaralaa2004 commited on
Commit
f63a436
·
verified ·
1 Parent(s): 8efdbe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -7,6 +7,8 @@ from typing import Dict, List, Tuple, Any
7
  import numpy as np
8
  import io
9
  import base64
 
 
10
 
11
  class UniversalCircuitGenerator:
12
  def __init__(self):
@@ -349,10 +351,15 @@ def create_interface():
349
 
350
  svg_content, description = generator.generate_circuit(user_input)
351
 
352
- # Convert SVG to displayable format
353
- svg_bytes = svg_content.encode('utf-8')
354
-
355
- return svg_bytes, description
 
 
 
 
 
356
 
357
  # Create Gradio interface
358
  interface = gr.Interface(
@@ -395,7 +402,7 @@ def create_interface():
395
  ["Linear power supply 5V"]
396
  ],
397
  theme=gr.themes.Soft(),
398
- allow_flagging="never"
399
  )
400
 
401
  return interface
 
7
  import numpy as np
8
  import io
9
  import base64
10
+ import tempfile
11
+ import os
12
 
13
  class UniversalCircuitGenerator:
14
  def __init__(self):
 
351
 
352
  svg_content, description = generator.generate_circuit(user_input)
353
 
354
+ # Save SVG to temporary file for Gradio
355
+ try:
356
+ with tempfile.NamedTemporaryFile(mode='w', suffix='.svg', delete=False) as f:
357
+ f.write(svg_content)
358
+ temp_file_path = f.name
359
+
360
+ return temp_file_path, description
361
+ except Exception as e:
362
+ return None, f"Error saving circuit image: {str(e)}"
363
 
364
  # Create Gradio interface
365
  interface = gr.Interface(
 
402
  ["Linear power supply 5V"]
403
  ],
404
  theme=gr.themes.Soft(),
405
+ flagging_mode="never"
406
  )
407
 
408
  return interface