Run this model with HF Jobs
Run osam36b/Arabic_Text_Classification_Using_SANAD_Dataset on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/osam36b/Arabic_Text_Classification_Using_SANAD_Dataset. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/osam36b/Arabic_Text_Classification_Using_SANAD_Dataset on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use osam36b/Arabic_Text_Classification_Using_SANAD_Dataset with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use osam36b/Arabic_Text_Classification_Using_SANAD_Dataset with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://osam36b/Arabic_Text_Classification_Using_SANAD_Dataset") - Notebooks
- Google Colab
- Kaggle
Upload app.py with huggingface_hub
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import gradio as grimport tensorflow as tffrom tensorflow.keras.preprocessing.sequence import pad_sequencesfrom tensorflow.keras.preprocessing.text import tokenizer_from_jsonimport pickleimport reimport os
# 1. تحميل الملفات والنموذجdef load_resources(): model = tf.keras.models.load_model('/content/exported_model/complaints_model.keras') with open('/content/exported_model/tokenizer.json', 'r', encoding='utf-8') as f: tokenizer_data = f.read() tokenizer = tokenizer_from_json(tokenizer_data) with open('/content/exported_model/label_encoder.pkl', 'rb') as f: encoder = pickle.load(f) return model, tokenizer, encoder
try: model, tokenizer, encoder = load_resources()except Exception as e: print(f"Error loading resources: {e}")
# 2. تنظيف ومعالجة النص العربيdef normalize(text): text = re.sub(r'[إأآا]', 'ا', text) text = re.sub(r'ى', 'ي', text) text = re.sub(r'ة', 'ه', text) return text
def clean_arabic(text): text = str(text) text = re.sub(r'[^\u0621-\u064A\s]', '', text) text = re.sub(r'(.)\1{2,}', r'\1', text) text = normalize(text) return re.sub(r'\s+', ' ', text).strip()
# 3. دالة التوقع والتحليلdef classify_arabic_text(text): if not text.strip(): return "الرجاء إدخال نص صالح" cleaned = clean_arabic(text) sequence = tokenizer.texts_to_sequences([cleaned]) padded = pad_sequences(sequence, maxlen=30, padding='post', truncating='post') predictions = model.predict(padded)[0] # بناء قاموس بالاحتمالات لكل فئة results = {} for i, class_name in enumerate(encoder.classes_): results[str(class_name)] = float(predictions[i]) return results
# 4. بناء واجهة Gradiointerface = gr.Interface( fn=classify_arabic_text, inputs=gr.Textbox(lines=5, placeholder="أدخل النص العربي هنا لتبدأ عملية التصنيف...", label="النص المدخل"), outputs=gr.Label(num_top_classes=3, label="التصنيفات المحتملة"), title="تصنيف النصوص العربية (Gradio)", description="تطبيق ذكاء اصطناعي لتصنيف النصوص والشكاوى العربية إلى فئاتها المناسبة باستخدام نموذج شبكة عصبية متكررة (RNN).", theme="soft")
if __name__ == "__main__": interface.launch(share=True)app.pyAdded+70