iBrokeTheCode commited on
Commit
fca4028
Β·
1 Parent(s): 5ff38a4

chore: Add samples for a quick app run

Browse files
.gitignore CHANGED
@@ -3,6 +3,8 @@ __pycache__/
3
  *.py[codz]
4
  *$py.class
5
 
 
 
6
  # C extensions
7
  *.so
8
 
 
3
  *.py[codz]
4
  *$py.class
5
 
6
+ *.csv
7
+
8
  # C extensions
9
  *.so
10
 
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
 
3
- from predictor import predict
4
 
5
  # πŸ“Œ CUSTOM CSS
6
  css_code = """
@@ -56,7 +56,7 @@ with gr.Blocks(
56
  gr.Markdown("## πŸ“ Classification Inputs")
57
 
58
  mode_radio = gr.Radio(
59
- choices=["Multimodal", "Text Only", "Image Only"],
60
  value="Multimodal",
61
  label="Choose Classification Mode:",
62
  )
@@ -64,14 +64,14 @@ with gr.Blocks(
64
  text_input = gr.Textbox(
65
  label="Product Description:",
66
  placeholder="e.g., Apple iPhone 15 Pro Max 256GB",
67
- lines=2,
68
  )
69
 
70
  image_input = gr.Image(
71
  label="Product Image",
72
  type="filepath",
73
  visible=True,
74
- height=350,
75
  width="100%",
76
  )
77
 
@@ -88,9 +88,9 @@ with gr.Blocks(
88
  """**πŸ’‘ How to use this app**
89
 
90
  This app classifies a product based on its description and image.
91
- - **Multimodal:** Uses both text and image for the most accurate prediction.
92
- - **Text Only:** Uses only the product description.
93
- - **Image Only:** Uses only the product image.
94
  """
95
  )
96
 
@@ -100,6 +100,28 @@ with gr.Blocks(
100
  label="Predict category", num_top_classes=5
101
  )
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  # πŸ“Œ ABOUT TAB
104
  with gr.TabItem("ℹ️ About"):
105
  gr.Markdown("""
@@ -137,6 +159,7 @@ The final classification is performed by a Multi-layer Perceptron (MLP) trained
137
  ## Performance Summary
138
 
139
  The following table summarizes the performance of all models trained in this project.
 
140
  <br>
141
 
142
  | Model | Modality | Accuracy | Macro Avg F1-Score | Weighted Avg F1-Score |
 
1
  import gradio as gr
2
 
3
+ from app_predictor import predict
4
 
5
  # πŸ“Œ CUSTOM CSS
6
  css_code = """
 
56
  gr.Markdown("## πŸ“ Classification Inputs")
57
 
58
  mode_radio = gr.Radio(
59
+ choices=["Multimodal", "Image Only", "Text Only"],
60
  value="Multimodal",
61
  label="Choose Classification Mode:",
62
  )
 
64
  text_input = gr.Textbox(
65
  label="Product Description:",
66
  placeholder="e.g., Apple iPhone 15 Pro Max 256GB",
67
+ lines=1,
68
  )
69
 
70
  image_input = gr.Image(
71
  label="Product Image",
72
  type="filepath",
73
  visible=True,
74
+ height=300,
75
  width="100%",
76
  )
77
 
 
88
  """**πŸ’‘ How to use this app**
89
 
90
  This app classifies a product based on its description and image.
91
+ - **Multimodal:** The most accurate mode, using both the image and a detailed description for prediction.
92
+ - **Image Only:** Highly effective for visual products, relying solely on the product image.
93
+ - **Text Only:** Less precise, this mode requires a very descriptive and specific product description to achieve good results.
94
  """
95
  )
96
 
 
100
  label="Predict category", num_top_classes=5
101
  )
102
 
103
+ # πŸ“Œ EXAMPLES SECTION
104
+ gr.Examples(
105
+ examples=[
106
+ [
107
+ "Multimodal",
108
+ "Red Electric Guitar – Stratocaster Style, 6-String, White Pickguard, Solid-Body, Ideal for Rock & Roll",
109
+ "./assets/sample.jpeg",
110
+ ],
111
+ ["Image Only", None, "./assets/sample.jpeg"],
112
+ [
113
+ "Text Only",
114
+ "Red Electric Guitar – Stratocaster Style, 6-String, White Pickguard, Solid-Body, Ideal for Rock & Roll",
115
+ None,
116
+ ],
117
+ ],
118
+ label="Select an example to pre-fill the inputs, then click the 'Classify Product' button.",
119
+ inputs=[mode_radio, text_input, image_input],
120
+ # outputs=output_label,
121
+ # fn=predict,
122
+ # cache_examples=True,
123
+ )
124
+
125
  # πŸ“Œ ABOUT TAB
126
  with gr.TabItem("ℹ️ About"):
127
  gr.Markdown("""
 
159
  ## Performance Summary
160
 
161
  The following table summarizes the performance of all models trained in this project.
162
+
163
  <br>
164
 
165
  | Model | Modality | Accuracy | Macro Avg F1-Score | Weighted Avg F1-Score |
predictor.py β†’ app_predictor.py RENAMED
File without changes
assets/sample.jpeg ADDED

Git LFS Details

  • SHA256: 970dbfc3e9632eeb49a0bbdf468f5eb277e6e120bea7e2838a8ace26df2188d7
  • Pointer size: 129 Bytes
  • Size of remote file: 5.23 kB