HaruthaiAi commited on
Commit
a4d104f
·
verified ·
1 Parent(s): a3ebbda

Fix display bug in analyze_all() – ensure correct plotting

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -1,11 +1,9 @@
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
4
- from matplotlib import pyplot as plt
5
  from scipy.fft import fft2, fftshift
6
  from scipy.ndimage import sobel, gaussian_filter
7
- import tempfile
8
- import os
9
 
10
  def analyze_all(image):
11
  gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
@@ -71,16 +69,12 @@ def analyze_all(image):
71
  ax.set_title(title)
72
  ax.axis('off')
73
  plt.tight_layout()
74
-
75
- temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
76
- plt.savefig(temp_file.name)
77
- plt.close(fig)
78
- return temp_file.name
79
 
80
  demo = gr.Interface(
81
  fn=analyze_all,
82
  inputs=gr.Image(type="numpy", label="Upload Painting Image"),
83
- outputs=gr.Image(type="filepath", label="18 Technique Analysis Grid"),
84
  title="🧠 Tree Oil Painting – 18 Supreme Techniques Viewer",
85
  description="Upload any painting image to analyze brushstroke structure using AI Sunny's 18 Technique model."
86
  )
 
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
4
+ import matplotlib.pyplot as plt
5
  from scipy.fft import fft2, fftshift
6
  from scipy.ndimage import sobel, gaussian_filter
 
 
7
 
8
  def analyze_all(image):
9
  gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
 
69
  ax.set_title(title)
70
  ax.axis('off')
71
  plt.tight_layout()
72
+ return fig
 
 
 
 
73
 
74
  demo = gr.Interface(
75
  fn=analyze_all,
76
  inputs=gr.Image(type="numpy", label="Upload Painting Image"),
77
+ outputs=gr.Plot(label="18 Technique Analysis Grid"),
78
  title="🧠 Tree Oil Painting – 18 Supreme Techniques Viewer",
79
  description="Upload any painting image to analyze brushstroke structure using AI Sunny's 18 Technique model."
80
  )