sanjid commited on
Commit
1361040
1 Parent(s): b3d0d5f
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer
3
+ import torch
4
+ from fastai.text.all import *
5
+
6
+
7
+ # Define the path to your model
8
+ model_path = "models/origin-classifier-stage-2.pkl"
9
+
10
+ # Load the learner
11
+ learner_inf = load_learner(model_path)
12
+
13
+ # Create a mapping from class labels to indices
14
+ class_label_mapping = {label: idx for idx, label in enumerate(learner_inf.dls.vocab)}
15
+
16
+ # Define a function to make predictions
17
+ def predict_text(text):
18
+ prediction = learner_inf.blurr_predict(text)[0]
19
+ predicted_class_index = prediction['class_index']
20
+ predicted_class_label = list(class_label_mapping.keys())[list(class_label_mapping.values()).index(predicted_class_index)]
21
+ return predicted_class_label
22
+
23
+ # Create a Gradio interface
24
+ iface = gr.Interface(
25
+ fn=predict_text,
26
+ inputs="text",
27
+ outputs="text",
28
+ title="FoodOrigin Classification App",
29
+ description="Enter a text, and it will predict the class label.",
30
+ )
31
+
32
+ # Start the Gradio app
33
+ iface.launch()
label_types_encoded.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"Amish and Mennonite": 0, "Argentinian": 1, "Australian and New Zealander": 2, "Austrian": 3, "Bangladeshi": 4, "Belgian": 5, "Brazilian": 6, "Cajun and Creole": 7, "Canadian": 8, "Chilean": 9, "Chinese": 10, "Colombian": 11, "Cuban": 12, "Danish": 13, "Dutch": 14, "Filipino": 15, "Finnish": 16, "French": 17, "German": 18, "Greek": 19, "Indian": 20, "Indonesian": 21, "Israeli": 22, "Italian": 23, "Jamaican": 24, "Japanese": 25, "Jewish": 26, "Korean": 27, "Lebanese": 28, "Malaysian": 29, "Norwegian": 30, "Pakistani": 31, "Persian": 32, "Peruvian": 33, "Polish": 34, "Portuguese": 35, "Puerto Rican": 36, "Russian": 37, "Scandinavian": 38, "Soul Food": 39, "South African": 40, "Southern Recipes": 41, "Spanish": 42, "Swedish": 43, "Swiss": 44, "Tex-Mex": 45, "Thai": 46, "Turkish": 47, "Vietnamese": 48, "Australian and New Zealander Recipes": 49, "Cajun and Creole Recipes": 50, "Canadian Recipes": 51, "Chinese Recipes": 52, "Filipino Recipes": 53, "French Recipes": 54, "German Recipes": 55, "Greek Recipes": 56, "Indian Recipes": 57, "Italian Recipes": 58, "Japanese Recipes": 59, "Jewish Recipes": 60, "Korean Recipes": 61, "Polish Recipes": 62, "Scandinavian Recipes": 63, "Spanish Recipes": 64, "Thai Recipes": 65, "Vietnamese Recipes": 66}
origin-classifier-stage-2.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dafbc1f7af6bfd3afad4030fc21ad5639192be90f6aa11479a56526723acd86b
3
+ size 330579429
requirements.txt ADDED
Binary file (134 Bytes). View file