Matej commited on
Commit
5e00ad7
1 Parent(s): adf8c13

remove gr.dropdown

Browse files
Files changed (1) hide show
  1. my_app.py +12 -12
my_app.py CHANGED
@@ -4,7 +4,7 @@ from huggingface_hub import from_pretrained_keras
4
 
5
  # Load your trained models
6
  model1 = from_pretrained_keras("ml-debi/EfficientNetB0-Food101")
7
- model2 = from_pretrained_keras("ml-debi/EfficientNetB0-Food101")
8
 
9
  with open('classes.txt', 'r') as f:
10
  classes = [line.strip() for line in f]
@@ -16,11 +16,11 @@ model1_info = """
16
  This model is based on the EfficientNetB0 architecture and was trained on the Food101 dataset.
17
  """
18
 
19
- model2_info = """
20
- ### Model 2 Information
21
 
22
- This model is based on the EfficientNetB0 architecture and was trained on augmented data, providing improved generalization.
23
- """
24
 
25
  def preprocess(image):
26
  print("before resize", image.shape)
@@ -30,15 +30,15 @@ def preprocess(image):
30
  print("After expanddims", image.shape)
31
  return image
32
 
33
- def predict(model_selection, image):
34
  # Choose the model based on the dropdown selection
35
- print("---model_selection---", model_selection) #
36
- model = model1 if model_selection == "EfficentNetB0 Fine Tune" else model2
37
 
38
- print(model.summary())
39
 
40
  image = preprocess(image)
41
- prediction = model.predict(image)
42
  print("model prediction", prediction)
43
  predicted_class = classes[int(tf.argmax(prediction, axis=1))]
44
  confidence = tf.reduce_max(prediction).numpy()
@@ -46,10 +46,10 @@ def predict(model_selection, image):
46
 
47
  iface = gr.Interface(
48
  fn=predict,
49
- inputs=[gr.Dropdown(["EfficentNetB0 Fine Tune", "EfficentNetB0 Fine Tune Augmented"]), gr.Image()],
50
  outputs=[gr.Textbox(label="Predicted Class"), gr.Textbox(label="Confidence")],
51
  title="Transfer Learning Mini Project",
52
- description=f"{model1_info}\n\n{model2_info}",
53
  )
54
 
55
  iface.launch()
 
4
 
5
  # Load your trained models
6
  model1 = from_pretrained_keras("ml-debi/EfficientNetB0-Food101")
7
+ #model2 = from_pretrained_keras("ml-debi/EfficientNetB0-Food101")
8
 
9
  with open('classes.txt', 'r') as f:
10
  classes = [line.strip() for line in f]
 
16
  This model is based on the EfficientNetB0 architecture and was trained on the Food101 dataset.
17
  """
18
 
19
+ #model2_info = """
20
+ #### Model 2 Information
21
 
22
+ #This model is based on the EfficientNetB0 architecture and was trained on augmented data, providing improved generalization.
23
+ #"""
24
 
25
  def preprocess(image):
26
  print("before resize", image.shape)
 
30
  print("After expanddims", image.shape)
31
  return image
32
 
33
+ def predict(image):
34
  # Choose the model based on the dropdown selection
35
+ #print("---model_selection---", model_selection) #
36
+ #model = model1 if model_selection == "EfficentNetB0 Fine Tune" else model2
37
 
38
+ #print(model.summary())
39
 
40
  image = preprocess(image)
41
+ prediction = model1.predict(image)
42
  print("model prediction", prediction)
43
  predicted_class = classes[int(tf.argmax(prediction, axis=1))]
44
  confidence = tf.reduce_max(prediction).numpy()
 
46
 
47
  iface = gr.Interface(
48
  fn=predict,
49
+ inputs=[gr.Image()],
50
  outputs=[gr.Textbox(label="Predicted Class"), gr.Textbox(label="Confidence")],
51
  title="Transfer Learning Mini Project",
52
+ description=f"{model1_info}\n",
53
  )
54
 
55
  iface.launch()