asaderu commited on
Commit
ad20374
1 Parent(s): ce46431

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -19
app.py CHANGED
@@ -7,23 +7,14 @@ import cv2
7
  import numpy as np
8
  from tensorflow.keras.preprocessing.image import img_to_array
9
  from tensorflow.keras.models import load_model
10
- print("[INFO] loading network...")
 
11
  model = load_model('daging128.model')
12
  mlb = pickle.loads(open('daging128.pickle', "rb").read())
13
 
14
  labels = ['Busuk', 'Segar', 'Setengah']
15
 
16
- def prosesgambar(gambar):
17
- # load the image
18
- image = gambar
19
- output = imutils.resize(image, width=400)
20
-
21
- # pre-process the image for classification
22
- image = cv2.resize(image, (94, 94))
23
- image = image.astype("float") / 255.0
24
- image = img_to_array(image)
25
- image = np.expand_dims(image, axis=0)
26
- return image
27
 
28
 
29
  def gambaran(image):
@@ -38,13 +29,6 @@ def gambaran(image):
38
  return labels[idxs[0]]
39
 
40
 
41
- def prediksi(gambar):
42
- a = np.round(model.predict(prosesgambar(gambar)), 4)[0].tolist()
43
- if a.index(max(a)) == 1:
44
- pred = "Segar"
45
- else:
46
- pred = "Busuk"
47
- return pred
48
 
49
  demo = gr.Interface(gambaran, gr.Image(shape=(128, 128)), "text")
50
  demo.launch()
 
7
  import numpy as np
8
  from tensorflow.keras.preprocessing.image import img_to_array
9
  from tensorflow.keras.models import load_model
10
+ import pickle
11
+
12
  model = load_model('daging128.model')
13
  mlb = pickle.loads(open('daging128.pickle', "rb").read())
14
 
15
  labels = ['Busuk', 'Segar', 'Setengah']
16
 
17
+
 
 
 
 
 
 
 
 
 
 
18
 
19
 
20
  def gambaran(image):
 
29
  return labels[idxs[0]]
30
 
31
 
 
 
 
 
 
 
 
32
 
33
  demo = gr.Interface(gambaran, gr.Image(shape=(128, 128)), "text")
34
  demo.launch()