Unearthed commited on
Commit
cdc6eb5
·
verified ·
1 Parent(s): eef6b7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -21
app.py CHANGED
@@ -18,20 +18,15 @@ import tensorflow as tf
18
  model = tf.keras.models.load_model("stone_artifact_classifier.h5", compile=False, custom_objects={"RandomHeight": tf.keras.layers.RandomHeight, "RandomWidth": tf.keras.layers.RandomWidth})
19
  #model = tf.keras.models.load_model("stone_artifact_classifier.h5", compile=False)
20
 
21
-
22
-
23
-
24
-
25
-
26
  # Replace with your classes
27
  class_names = ["arrowheads", "axehammerstones", "scrapers"]
28
 
29
- from tensorflow.keras.applications.efficientnet import preprocess_input
30
 
 
31
 
32
  def predict(img):
33
  """Predict function for Gradio"""
34
-
35
  img = img.convert("RGB").resize(IMG_SIZE)
36
  x = np.array(img)
37
  x = preprocess_input(x)
@@ -40,25 +35,14 @@ def predict(img):
40
  # top = np.argmax(preds)
41
  return {class_names[i]: float(preds[i]) for i in range(len(preds))}
42
 
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
  # Gradio interface
57
  iface = gr.Interface(
 
58
  inputs=gr.Image(type="pil"),
59
  outputs=gr.Label(num_top_classes=len(class_names)),
60
  title="Stone Artifact Classifier",
61
  description="Upload an image of an artifact and the model will classify it."
62
  )
63
 
64
- iface.launch()
 
 
18
  model = tf.keras.models.load_model("stone_artifact_classifier.h5", compile=False, custom_objects={"RandomHeight": tf.keras.layers.RandomHeight, "RandomWidth": tf.keras.layers.RandomWidth})
19
  #model = tf.keras.models.load_model("stone_artifact_classifier.h5", compile=False)
20
 
 
 
 
 
 
21
  # Replace with your classes
22
  class_names = ["arrowheads", "axehammerstones", "scrapers"]
23
 
24
+ IMG_SIZE = (224, 224) # change this to your model's expected size
25
 
26
+ from tensorflow.keras.applications.efficientnet import preprocess_input
27
 
28
  def predict(img):
29
  """Predict function for Gradio"""
 
30
  img = img.convert("RGB").resize(IMG_SIZE)
31
  x = np.array(img)
32
  x = preprocess_input(x)
 
35
  # top = np.argmax(preds)
36
  return {class_names[i]: float(preds[i]) for i in range(len(preds))}
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  # Gradio interface
39
  iface = gr.Interface(
40
+ fn=predict,
41
  inputs=gr.Image(type="pil"),
42
  outputs=gr.Label(num_top_classes=len(class_names)),
43
  title="Stone Artifact Classifier",
44
  description="Upload an image of an artifact and the model will classify it."
45
  )
46
 
47
+ iface.launch()
48
+