Hiratax commited on
Commit
42dc939
·
verified ·
1 Parent(s): 5ecc70a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: keras
3
+ tags:
4
+ - image-classification
5
+ - food-recognition
6
+ - food-vision
7
+ - uecfood256
8
+ - tensorflow
9
+ datasets:
10
+ - uecfood256
11
+ pipeline_tag: image-classification
12
+ ---
13
+
14
+ # Food Recognition Model (UECFOOD256)
15
+
16
+ This model is a deep learning classifier capable of recognizing **256 different types of food**. It was trained using **TensorFlow/Keras** on the **UECFOOD256** dataset.
17
+
18
+ ## Model Details
19
+ - **Model Architecture:** [INSERT BASE MODEL HERE, e.g., MobileNetV2 / EfficientNetB0] (Fine-tuned)
20
+ - **Dataset:** UECFOOD256 (256 food categories)
21
+ - **Framework:** TensorFlow / Keras
22
+ - **Task:** Image Classification (Multi-class)
23
+
24
+ ## Intended Use
25
+ This model is designed to take an image of food as input and output the specific food category name. It is useful for:
26
+ - Calorie tracking apps
27
+ - Dietary monitoring
28
+ - Food logging automation
29
+
30
+ ## How to Use
31
+
32
+ You can load this model directly in Python using the `huggingface_hub` library.
33
+
34
+ **Important:** This model requires a `class_names.txt` file (included in the repo) to map the model's integer predictions back to readable food names.
35
+
36
+ ### Inference Code
37
+
38
+ ```python
39
+ import numpy as np
40
+ from huggingface_hub import from_pretrained_keras, hf_hub_download
41
+ from keras.preprocessing import image
42
+ import tensorflow as tf
43
+
44
+ # 1. Define the Repo ID
45
+ repo_id = "Hiratax/food-recognition-model"
46
+
47
+ # 2. Load the Model
48
+ print("Loading model...")
49
+ model = from_pretrained_keras(repo_id)
50
+
51
+ # 3. Load the Class Names Mapping
52
+ class_names_path = hf_hub_download(repo_id=repo_id, filename="class_names.txt")
53
+ with open(class_names_path, 'r') as f:
54
+ class_names = [line.strip() for line in f.readlines()]
55
+
56
+ # 4. Prediction Function
57
+ def predict_food(img_path):
58
+ # Resize image to 224x224 (Standard for this model)
59
+ img = image.load_img(img_path, target_size=(224, 224))
60
+ img_array = image.img_to_array(img)
61
+ img_batch = np.expand_dims(img_array, axis=0)
62
+
63
+ # Predict
64
+ predictions = model.predict(img_batch)
65
+ predicted_index = np.argmax(predictions[0])
66
+ confidence = np.max(predictions[0])
67
+
68
+ return class_names[predicted_index], confidence
69
+
70
+ # 5. Run on an image
71
+ # food, conf = predict_food("my_sushi.jpg")
72
+ # print(f"Prediction: {food} ({conf:.2f})")