prithivMLmods commited on
Commit
55a6126
·
verified ·
1 Parent(s): b96f45e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -8,6 +8,7 @@ from augmented_waste_classifier import waste_classification
8
  from age_classification import age_classification
9
  from mnist_digits import classify_digit
10
  from fashion_mnist_cloth import fashion_mnist_classification
 
11
 
12
  # Main classification function that calls the appropriate model based on selection.
13
  def classify(image, model_name):
@@ -29,6 +30,8 @@ def classify(image, model_name):
29
  return classify_digit(image)
30
  elif model_name == "fashion_mnist":
31
  return fashion_mnist_classification(image)
 
 
32
  else:
33
  return {"Error": "No model selected"}
34
 
@@ -36,7 +39,8 @@ def classify(image, model_name):
36
  def select_model(model_name):
37
  model_variants = {
38
  "gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
39
- "gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary", "fashion_mnist": "secondary"
 
40
  }
41
  model_variants[model_name] = "primary"
42
  return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
@@ -53,15 +57,16 @@ with gr.Blocks() as demo:
53
  gym_workout_btn = gr.Button("Gym Workout Classification", variant="secondary")
54
  waste_btn = gr.Button("Waste Classification", variant="secondary")
55
  mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
56
- fashion_mnist_btn = gr.Button("Fashion MNIST", variant="secondary")
 
57
 
58
  selected_model = gr.State("age")
59
  gr.Markdown("### Current Model:")
60
  model_display = gr.Textbox(value="age", interactive=False)
61
  selected_model.change(lambda m: m, selected_model, model_display)
62
 
63
- buttons = [gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn, age_btn, mnist_btn, fashion_mnist_btn]
64
- model_names = ["gender", "emotion", "dog breed", "deepfake", "gym workout", "waste", "age", "mnist", "fashion_mnist"]
65
 
66
  for btn, name in zip(buttons, model_names):
67
  btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)
 
8
  from age_classification import age_classification
9
  from mnist_digits import classify_digit
10
  from fashion_mnist_cloth import fashion_mnist_classification
11
+ from indian_western_food_classify import food_classification
12
 
13
  # Main classification function that calls the appropriate model based on selection.
14
  def classify(image, model_name):
 
30
  return classify_digit(image)
31
  elif model_name == "fashion_mnist":
32
  return fashion_mnist_classification(image)
33
+ elif model_name == "food":
34
+ return food_classification(image)
35
  else:
36
  return {"Error": "No model selected"}
37
 
 
39
  def select_model(model_name):
40
  model_variants = {
41
  "gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
42
+ "gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary",
43
+ "fashion_mnist": "secondary", "food": "secondary"
44
  }
45
  model_variants[model_name] = "primary"
46
  return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
 
57
  gym_workout_btn = gr.Button("Gym Workout Classification", variant="secondary")
58
  waste_btn = gr.Button("Waste Classification", variant="secondary")
59
  mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
60
+ fashion_mnist_btn = gr.Button("Fashion MNIST Classification", variant="secondary")
61
+ food_btn = gr.Button("Indian/Western Food", variant="secondary")
62
 
63
  selected_model = gr.State("age")
64
  gr.Markdown("### Current Model:")
65
  model_display = gr.Textbox(value="age", interactive=False)
66
  selected_model.change(lambda m: m, selected_model, model_display)
67
 
68
+ buttons = [gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn, age_btn, mnist_btn, fashion_mnist_btn, food_btn]
69
+ model_names = ["gender", "emotion", "dog breed", "deepfake", "gym workout", "waste", "age", "mnist", "fashion_mnist", "food"]
70
 
71
  for btn, name in zip(buttons, model_names):
72
  btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)