grover101 commited on
Commit
8588783
·
verified ·
1 Parent(s): 9308a47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -7
app.py CHANGED
@@ -5,12 +5,11 @@ import pathlib
5
  plt = platform.system()
6
  if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
7
 
8
- def old_or_not(x):
9
  return x[0].isupper()
10
 
11
-
12
- learn = load_learner('model.pkl')
13
-
14
 
15
  categories = ['New_car', 'Old_car']
16
 
@@ -18,9 +17,26 @@ def classify_image(img):
18
  pred, idx, probs = learn.predict(img)
19
  return dict(zip(categories, map(float, probs)))
20
 
 
21
  image = gr.inputs.Image(shape=(192, 192))
22
  label = gr.outputs.Label()
23
- examples = ['new_car_2.jpg', 'new_car_4.jpg', 'old_car_7.jpg', 'old_car_12.jpg']
24
 
25
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
26
- intf.launch(inline=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  plt = platform.system()
6
  if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
7
 
8
+ def old_or_not(x):
9
  return x[0].isupper()
10
 
11
+ # Assuming 'model.pkl' is in the same directory as this script
12
+ learn = load_learner('model.pkl') # Replace with the appropriate path if needed
 
13
 
14
  categories = ['New_car', 'Old_car']
15
 
 
17
  pred, idx, probs = learn.predict(img)
18
  return dict(zip(categories, map(float, probs)))
19
 
20
+ # Use Image component with correct shape argument
21
  image = gr.inputs.Image(shape=(192, 192))
22
  label = gr.outputs.Label()
 
23
 
24
+ examples = [
25
+ 'new_car_2.jpg',
26
+ 'new_car_4.jpg',
27
+ 'old_car_7.jpg',
28
+ 'old_car_12.jpg',
29
+ ]
30
+
31
+ # Improved interface creation for clarity
32
+ interface = gr.Interface(
33
+ fn=classify_image,
34
+ inputs=image,
35
+ outputs=label,
36
+ examples=examples,
37
+ title="Image Classification", # Optional title for the interface
38
+ description="Classify an image as 'New_car' or 'Old_car'", # Optional description
39
+ )
40
+
41
+ # Launch the interface
42
+ interface.launch(inline=False)