Siyun He commited on
Commit
ce867e1
·
1 Parent(s): c5b0f8b
Files changed (2) hide show
  1. app.py +1 -6
  2. classification.py +4 -0
app.py CHANGED
@@ -2,17 +2,12 @@ import gradio as gr
2
  from classification import classify_image
3
  import pickle
4
 
5
- # Load the pre-trained classifiers
6
- clf_glcm = pickle.load(open('clf_glcm.pkl', 'rb'))
7
- clf_lbp = pickle.load(open('clf_lbp.pkl', 'rb'))
8
-
9
-
10
  # Create a Gradio interface with a dropdown menu for algorithm selection
11
  iface = gr.Interface(
12
  fn=classify_image,
13
  inputs=[
14
  gr.Image(type='numpy', label="Upload an Image"),
15
- gr.Dropdown(choices=['GLCM', 'LBP'], label="Algorithm", value='GLCM')
16
  ],
17
  outputs='text',
18
  title='Texture Classification',
 
2
  from classification import classify_image
3
  import pickle
4
 
 
 
 
 
 
5
  # Create a Gradio interface with a dropdown menu for algorithm selection
6
  iface = gr.Interface(
7
  fn=classify_image,
8
  inputs=[
9
  gr.Image(type='numpy', label="Upload an Image"),
10
+ gr.Dropdown(choices=['GLCM', 'LBP'], label="Algorithm", value='GLCM'),
11
  ],
12
  outputs='text',
13
  title='Texture Classification',
classification.py CHANGED
@@ -77,6 +77,10 @@ def classify_image(image, algorithm):
77
  # Suppress the warning about feature names
78
  warnings.filterwarnings("ignore", message="X does not have valid feature names")
79
 
 
 
 
 
80
  # If the image is a NumPy array, it's already loaded
81
  if isinstance(image, np.ndarray):
82
  img = cv2.resize(image, (128, 128))
 
77
  # Suppress the warning about feature names
78
  warnings.filterwarnings("ignore", message="X does not have valid feature names")
79
 
80
+ # Load the pre-trained classifiers
81
+ clf_glcm = pickle.load(open('clf_glcm.pkl', 'rb'))
82
+ clf_lbp = pickle.load(open('clf_lbp.pkl', 'rb'))
83
+
84
  # If the image is a NumPy array, it's already loaded
85
  if isinstance(image, np.ndarray):
86
  img = cv2.resize(image, (128, 128))