stzhao commited on
Commit
444d5c7
1 Parent(s): 041e4a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -35,7 +35,7 @@ def plot_vectors(file):
35
 
36
  # Save the plot to a buffer
37
  buf = BytesIO()
38
- plt.savefig(buf, format='png')
39
  buf.seek(0)
40
  plt.close()
41
 
@@ -44,7 +44,7 @@ def plot_vectors(file):
44
  img_str = base64.b64encode(buf.getvalue()).decode('utf-8')
45
 
46
  # Return the base64-encoded image string
47
- return f"data:image/png;base64,{img_str}"
48
  except Exception as e:
49
  return str(e)
50
 
@@ -52,7 +52,7 @@ def plot_vectors(file):
52
  iface = gr.Interface(
53
  fn=plot_vectors,
54
  inputs=gr.File(label="Upload a .npy file containing a 2D array of 1D vectors"),
55
- outputs=gr.Image(type="pil"),
56
  examples=[["random_array.npy"]] # Example file
57
  )
58
 
 
35
 
36
  # Save the plot to a buffer
37
  buf = BytesIO()
38
+ plt.savefig("result.png")
39
  buf.seek(0)
40
  plt.close()
41
 
 
44
  img_str = base64.b64encode(buf.getvalue()).decode('utf-8')
45
 
46
  # Return the base64-encoded image string
47
+ return "result.png"
48
  except Exception as e:
49
  return str(e)
50
 
 
52
  iface = gr.Interface(
53
  fn=plot_vectors,
54
  inputs=gr.File(label="Upload a .npy file containing a 2D array of 1D vectors"),
55
+ outputs=gr.Image(type="filepath", label="Visualization Result"),
56
  examples=[["random_array.npy"]] # Example file
57
  )
58