thurya commited on
Commit
d9c18f0
·
verified ·
1 Parent(s): fd26c97

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +20 -9
  2. app.py +39 -0
  3. class_names.json +6 -0
  4. model.h5 +3 -0
README.md CHANGED
@@ -1,12 +1,23 @@
 
1
  ---
2
- title: Flower Classifier Ar
3
- emoji: 📊
4
- colorFrom: yellow
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 5.47.2
8
- app_file: app.py
9
- pinned: false
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  ---
3
+ tags:
4
+ - image-classification
5
+ - flower-classifier
6
+ - tensorflow
7
+ - arabic
8
+ - gradio
9
+ library_name: tensorflow
 
10
  ---
11
 
12
+ # 🌼 مُصنّف الزهور باللغة العربية
13
+
14
+ هذا النموذج يصنّف الصور إلى 4 أنواع من الزهور:
15
+ - أقحوان
16
+ - هندباء
17
+ - توليب
18
+ - عباد الشمس
19
+
20
+ تم تدريبه باستخدام TensorFlow على مجموعة صور الزهور الشهيرة.
21
+
22
+ ## 🖥️ واجهة تفاعلية
23
+ يتم تشغيل واجهة Gradio تلقائيًا عند فتح الصفحة.
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from PIL import Image
3
+ import numpy as np
4
+ import tensorflow as tf
5
+ import gradio as gr
6
+ import json
7
+
8
+ # تحميل أسماء الفئات
9
+ with open("class_names.json", "r", encoding="utf-8") as f:
10
+ index_to_arabic = json.load(f)
11
+ index_to_arabic = {int(k): v for k, v in index_to_arabic.items()}
12
+ arabic_names = [index_to_arabic[i] for i in sorted(index_to_arabic.keys())]
13
+
14
+ # تحميل النموذج
15
+ model = tf.keras.models.load_model("model.h5")
16
+
17
+ def predict_flower(img):
18
+ if img is None:
19
+ return {"⚠️ يرجى رفع صورة": 1.0}
20
+ if img.mode != 'RGB':
21
+ img = img.convert('RGB')
22
+ img = img.resize((150, 150))
23
+ img_array = np.array(img) / 255.0
24
+ img_array = np.expand_dims(img_array, axis=0)
25
+ preds = model.predict(img_array, verbose=0)[0]
26
+ if np.max(preds) < 0.6:
27
+ return {"❌ لا يمكن التعرف على الصورة": 1.0}
28
+ return {arabic_names[i]: float(preds[i]) for i in range(len(arabic_names))}
29
+
30
+ iface = gr.Interface(
31
+ fn=predict_flower,
32
+ inputs=gr.Image(type="pil", label="ارفع صورة زهرة 🌸"),
33
+ outputs=gr.Label(),
34
+ title="🌼 مُصنّف الزهور (عربي)",
35
+ description="يدعم: أقحوان، هندباء، توليب، عبادالشمس"
36
+ )
37
+
38
+ if __name__ == "__main__":
39
+ iface.launch()
class_names.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "0": "الاقحوان",
3
+ "1": "الهدباء",
4
+ "2": "توليب",
5
+ "3": "عباد الشمس"
6
+ }
model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2ff848383ab699a214faf55ca416db0f5aefa4104017cf4c4a74e82bb215a4a
3
+ size 41514392